Skip to content

FontViewer: Composite Glyph Rendering #10

@paulushub

Description

@paulushub

First, the cast to SimpleGlyph in the following rendering codes is not correct, throwing exceptions for nested composite glyphs. Try rendering Glyph ID 126 in the font NotoSerif-Thin.ttf.

    private void paintCompositeGlyph(Graphics2D g, CompositeGlyph composite) {
      for (int i = 0; i < composite.numGlyphs(); i++) {
        int glyphIndex = composite.glyphIndex(i);
        int offset = loca.glyphOffset(glyphIndex);
        int length = loca.glyphLength(glyphIndex);
        if (length != 0) {
          SimpleGlyph simple = (SimpleGlyph) glyf.glyph(offset, length);    // <--- Here
          int deltaX = composite.argument1(i);
          int deltaY = composite.argument2(i);
          paintSimpleGlyph(g, simple, deltaX, deltaY);
        }
      }
    }

Next, checking for the nested composite glyph and calling the paintCompositeGlyph(...) recursively seems to work but rendering is incomplete and will not render the denominator in some fractional representations like 1/4 (where the 4 is not rendered in fonts like NotoSerif-Thin.ttf).
The denominator is actually rendered but clipped off the screen (it seems deltaY is very large).

What is the best way to fix the nested rendering of composite glyphs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions