Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't always use the notdef glyph for missing glyph in TTF font #79

Open
mojavelinux opened this issue Feb 23, 2020 · 0 comments
Open

Comments

@mojavelinux
Copy link
Contributor

In a TTF font, ttfunk doesn't seem to always use the notdef glyph when a glyph cannot be found.

This is a tricky bug to reproduce because it largely depends on what other characters are present and what glyphs the font provides. For certain fonts, when certain combinations of characters are used, the notdef glyph gets replaced with what appears to be a random glyph.

Here's an example that uses a font in the prawn data folder:

Prawn::Document.generate 'out.pdf' do
  def register_font data
    font_families.update(data.each_with_object({}) do |(key, val), accum|
      accum[key.to_s] = val
    end)
  end

  register_font Custom: { normal: 'PRAWN_DIR/data/fonts/Dustismo_Roman.ttf' }

  font 'Custom' do
    text "ĂĄǺ\u0200\u0202ÆǼĆÇĈĊČĎĐÐḌDZDzDŽDžÈÉÊËĒĔĖĘẼĚẸ\u0204\u0206ƏǴĜĞĠĢĤĦḤĬÌÍÎÏİĨĪĮỊ\u0208\u020aĹ"
  end
end

In the generated PDF, we see an "L" in the position of the second to last character. If you copy that and paste it into an editor, you'll see the correct glyph. (See https://www.fileformat.info/info/unicode/char/020a/index.htm). So the problem appears to be what's being displayed from the font, not the text that's stored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant