-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fallback code for openTypeOS2UnicodeRanges and #254
Fallback code for openTypeOS2UnicodeRanges and #254
Conversation
Thanks Khaled! I'll review this tomorrow. Just one thing. You know that the fonttools' might be worth merging with your own work to avoid duplication. |
Setting some Unicode range seems to be required by some applications on Windows. I don’t have the exact details, but fonts that don’t set Unicode range and code pages fail on Windows. People who don’t like the fallaback, can always set openTypeOS2UnicodeRanges explicitly. This should have been in fontInfoData.py, but there is no way to access the ttFont there.
Dropped my Unicode ranges implementation and used fontTools’, they seem to be equivalent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Khaled, this looks good to me.
So you basically chose a few "key" character for each codepage range and when they are present, set the bit accordingly. How did you come up with them?
It would be nice if these were documented.
Lib/ufo2ft/outlineCompiler.py
Outdated
def _calcCodepageRanges(self): | ||
codepageRanges = set() | ||
|
||
unicodes = [i for i in self.unicodeToGlyphNameMapping.keys() if i is not None] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the keys in that mapping are never None, you don't need to check if i is not None
. If we do checks like that elsewhere, we need to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I copied that from somewhere else in the same file.
Lib/ufo2ft/outlineCompiler.py
Outdated
hasCP866 = 0 | ||
hasCP869 = 0 | ||
for code in unicodes: | ||
if code == 0x00DE and hasAscii: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this magic constant hex digits, would be nice to have comments showing what characters they refer to.
maybe you could use byteord('Þ')
(defined in fontTools.misc.py23
) so it's clear what these characters are.
Lib/ufo2ft/outlineCompiler.py
Outdated
if hasCP708 and hasLineart: | ||
codepageRanges.add(61) # Arabic; ASMO 708 | ||
|
||
return list(codepageRanges) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can stay a set. the intListToNum
only checks if some integer is contained in that sequence
I think this would also need some accompanying test cases, especially since there're so many |
The code pages code is basically a translation of the code from FontForge (as mentioned in the commit message), I don’t what is the rationale behind it, but it seems to work. Alternatively, we can just do the same as Unicode ranges and if any character of the code page is present set the corresponding bit, but I don’t know if this will work. |
ok, I missed that. |
Direct translation of FontForge implementation, hopefully it is time tested…
I see you wrote the unicode literals in the code directly instead of their hex codes, that's good. However, I don't understand how come the tests on Python 2.7 did not fail with |
gonna fix it myself, thanks |
Thanks Cosimo! |
I don’t have the exact details, but fonts that don’t set Unicode range and code pages fail on Windows. With this code fonts built with fontmake without setting
openTypeOS2UnicodeRanges
andopenTypeOS2UnicodeRanges
work on Windows.