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

Incorrect contour extraction and rendering of DFKai-SB glyphs #1303

Open
drott opened this issue Jan 7, 2025 · 5 comments
Open

Incorrect contour extraction and rendering of DFKai-SB glyphs #1303

drott opened this issue Jan 7, 2025 · 5 comments
Assignees

Comments

@drott
Copy link
Contributor

drott commented Jan 7, 2025

https://rtsh.es/test/dfkai_pdf.html hosts a PDF.js view of a PDF that displays glyphs from Microsofts's DFKai-SB font
https://learn.microsoft.com/en-us/typography/font-list/dfkai-sb

Two of the glyphs appear compressed with incomplete contour shapes.

Image

vs expected:

Image

I'll try to provide a further reduction.

The font is available as an attachment of the upstream bug report: https://issues.chromium.org/387045808

@drott drott added this to the Skrifa for Chrome milestone Jan 7, 2025
@dfrg dfrg self-assigned this Jan 7, 2025
@drott
Copy link
Contributor Author

drott commented Jan 7, 2025

The font is available as an attachment of the upstream bug report: https://issues.chromium.org/387045808

Sorry, the font is not, only the PDF that embeds it. I am working on extracting it.

@drott
Copy link
Contributor Author

drott commented Jan 7, 2025

Font extracted from PDF by setting breakpoints on CSS FontFace creation in the pdf.js code.

dfkai.zip

<name>
    <namerecord nameID="0" platformID="1" platEncID="0" langID="0x0" unicode="True">
      (c) Copyright DynaLab Inc. 1992-1998
    </namerecord>
    <namerecord nameID="1" platformID="1" platEncID="0" langID="0x0" unicode="True">
      DFKai-SB
    </namerecord>
[...]
    <namerecord nameID="5" platformID="1" platEncID="0" langID="0x0" unicode="True">
      Version 5.01
    </namerecord>
    <namerecord nameID="6" platformID="1" platEncID="0" langID="0x0" unicode="True">
      DFKaiShu-SB-Estd-BF
    </namerecord>
[...]
  </name>

@drott
Copy link
Contributor Author

drott commented Jan 7, 2025

@drott
Copy link
Contributor Author

drott commented Jan 7, 2025

@dfrg
Copy link
Member

dfrg commented Jan 7, 2025

So it turns out that this is one of the "tricky" fonts that requires the bytecode interpreter to generate a correct outline. If I run these through skrifa with the target set to Mono, I get the intended results.

Since our API doesn't handle hinting internally, this isn't something we can just fix. What we can do is copy FreeType's tricky font detection and expose it as a method (maybe OutlineGlyphCollection::require_interpreter()). If that returns true then the user should apply hinting (with the Mono target). This method won't be fast since it requires checking the name table and potentially computing checksums so for Skia, this should be done when creating a typeface.

dfrg added a commit that referenced this issue Jan 7, 2025
Implements the family name part of FreeType's "tricky" font detection. This is sufficient to address the problematic font in #1303.

Adds an `OutlineGlyphCollection::require_interpreter()` method that can be used to determine if hinting (with the interpreter engine) is required to correctly render glyphs from the font.

FreeType has some additional checks on length/checksums of various tables. I'll do that in a follow up.
dfrg added a commit that referenced this issue Jan 8, 2025
Implements the family name part of FreeType's "tricky" font detection. This is sufficient to address the problematic font in #1303.

Adds an `OutlineGlyphCollection::require_interpreter()` method that can be used to determine if hinting (with the interpreter engine) is required to correctly render glyphs from the font.

FreeType has some additional checks on length/checksums of various tables. I'll do that in a follow up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants