Skip to content

Is the calculation of maxComponentDepth really correct? #62

@be5invis

Description

@be5invis

Since FV is always complaining about maxComponentDepth being too small for Iosevka I walked into its source to see how it analyzes the component depth of a particular glyph. And the logic in GetCompositeGlyphStats (https://github.com/Microsoft/Font-Validator/blob/master/OTFontFileVal/val_maxp.cs#L371) seems that, every time you recurse DOWN you increase a counter, which may perform incorrect number in a complex glyph like this:

2785 [
  2665 [        <- trigger nComponentDepth++
    2601 [      <- trigger nComponentDepth++
      2597 [    <- trigger nComponentDepth++
        2595    <- trigger nComponentDepth++
        2595
      ]
      2595
    ]
    2595
  ]
  2601 [
    2597 [       <- trigger nComponentDepth++
      2595       <- trigger nComponentDepth++ 
      2595
    ]
    2595
  ]
]

The recursion depth of glyph 2785 is 4 (2785 → 2665 → 2601 → 2597 → 2595) but FV increased the counter by two more times when looking inside its second reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions