-
Notifications
You must be signed in to change notification settings - Fork 254
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
Add platformID/platformSpecificID/languageID support to getFont* #139
base: master
Are you sure you want to change the base?
Conversation
EOT does not have the same modifications, which may cause problems. |
Also add setData function to facilitate users to modify font information. Example:
|
Well, in the sense that I mentioned before, the definition changed, but the user usage and test unit did not, which is the issue to discuss because it breaks backward compatibility. (Define a widely used default value, or select one randomly/with certain rules) |
For sure I'll probably have some thoughts on what we can do here. I'll let you know after I've had a chance to review. |
I discovered a problem: I tried to cache the fonts to process again on subsequent calls, but I got an unpack error. For this I tried to copy it using clone but it doesn't work. After observation, I found that it seems to modify the file, and the subsequently opened file will replace the previously loaded file, which may not be good for continuous subset and setData. Loading font files repeatedly may reduce performance. Additionally, this may cause a problem: the pointer to the load file is never fclose. I added a workaround to solve this problem: when the user calls open again, we keep the pointer to the previous file. This way, the user can close the new file and return to the previous file by calling the revert method. At the same time, users can also close two files at the same time directly through the close method. After testing, without modifying the font information, continuous use of setsubset will not affect the generated glyphs. I don't quite understand the principle of this font library. Edit: |
Adding this functionality would make it possible to obtain data for different platforms or languages, and might also prevent conflicts for the same nameID.
This is a font for testing:
方正兰亭圆_GBK_准.ttf.zip
For example: do a simple test on the original version
Mac (1,0,0,1) Font Family: FZLanTingYuan-M-GBK
Microsoft (3,1,1033,1) Font Family: FZLanTingYuan-M-GBK
You'll find that it may not match the output you expected for the language or platform.
The essential reason for this problem is that the name class is able to parse but does not set enough information when parse.
Therefore, this PR adds a way for users to obtain information on any platform or language. The trade-off is that if the user doesn't know the type they want to deal with, they have to guess to get the font information. So, this is where optimization is needed. (For example assume the default value 3,1,1033?)
Use PR's version (omitting duplicate code):
Edit: reduce is not work, because I haven't modified it yet.