-
Notifications
You must be signed in to change notification settings - Fork 593
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
cmap table that maps a code point to GID 0 #2031
Comments
For comparison, |
I agree, we should just remove 0 from collected unicodes of OpenType fonts. |
Simple patch please. |
That was wrong. I'm fixing correctly now. Existing code tried to do this correctly, but apparently doesn't in some places. Investigating. |
Humm. I don't see where in the code this is happening. Khaled, can you point out to what mapping in the font is causing this? I'm failing to find it. Can you please debug and submit a PR? Ideally with a test? Thanks. |
I’ll try to debug later, here is the test code I used to check this: #include <assert.h>
#include <stdio.h>
#include <hb.h>
int
main(int argc, char** argv)
{
if (argc < 2)
{
fprintf(stderr, "Usage: %s font\n", argv[0]);
return 1;
}
hb_blob_t *blob = hb_blob_create_from_file(argv[1]);
hb_face_t *face = hb_face_create(blob, 0);
hb_font_t *font = hb_font_create(face);
hb_set_t *codes = hb_set_create();
hb_face_collect_unicodes(face, codes);
size_t count = hb_set_get_population(codes);
hb_codepoint_t code = HB_SET_VALUE_INVALID;
hb_codepoint_t glyph = 0;
while (hb_set_next(codes, &code))
{
hb_font_get_nominal_glyph(font, code, &glyph))
fprintf(stdout, "U+%04X => %04d\n", code, glyph);
assert(glyph);
}
hb_blob_destroy(blob);
hb_face_destroy(face);
hb_font_destroy(font);
hb_set_destroy(codes);
}
|
I’m guessing it is this code: harfbuzz/src/hb-ot-cmap-table.hh Lines 345 to 362 in ce11df1
When |
Right. So the font declares a range mapping 0 to 0? That's pretty weird. Humm. Yeah I don't remember Format4 in enough detail to figure out what that one does... [...hours pass...] Yeah I'm also convinced it's that blind |
The font has a format 12 subtable which has the same issue. I don’t know how to make a font like this and can’t subset away the other subtable with FontTools since it will rather helpfully fix the subtable, so the test I’m adding will be testing only the subtable HarfBuzz end up selecting (format 12 in this case). I’m not sure if other subtable formats need fixing as well. |
Thanks. It's a bummer that we have to do this check for all ranges. The Format12/13 can be further optimized but I'm happy to not do that unless proven necessary. Thanks! |
Fixed by dd28884 I believe |
The pull request is not yet merged. |
Oh ok |
The font
cmunrm.otf
has a format 4cmap
subtable that map U+0000 to GID 0, and this seems to causehb_face_collect_unicodes()
to include U+0000, but the spec says:So shouldn’t HarfBuzz skip U+0000 then? Furthermore,
hb_font_get_nominal_glyph()
returnsfalse
for U+0000 in this font, which is rather inconsistent.The text was updated successfully, but these errors were encountered: