-
Notifications
You must be signed in to change notification settings - Fork 44
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
Extract a better property dict from TTF fonts #697
Conversation
self.style = style | ||
self.variant = variant | ||
self.weight = weight | ||
self.stretch = stretch | ||
self.face_index = face_index |
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.
This change is integrating the face_index
pieces that we're introduced by #605 to the refactored font parsing code.
variant = "normal" | ||
for value in ("capitals", "small-caps"): | ||
if value in name.lower(): | ||
for value in ("capitals", "small-caps", "smallcaps"): |
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.
I made this addition because there's a font named "Bodoni 72 Smallcaps Book" on macOS.
# For backwards compatibility with previous parsing behavior | ||
style_prop = full_name |
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.
We used to use the full_name
when checking the style and weight of a font.
# We only care about records in English | ||
plat, lang = rec.platformID, rec.langID | ||
if not ((plat in _plat_ids and lang == _english_id) | ||
or (plat == _ms_plat_id and lang in _ms_english_ids)): | ||
continue |
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.
We need this check to pick up older TTF/TTC files and newer OTF files (which use the Microsoft plaformID
)
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.
LGTM
Okie dokie. Onward and upward I guess... |
This fixes the font properties bugs pointed out by #391, but since it's happening in the refactored font code the issue remains open.
The core change here is to make
get_ttf_prop_dict
better.Before:
After:
Now that
style
is extracted, we can use it instead of thefull_name
of the font (which we used to callsfnt4
) when checking the weight of the font.As an added bonus, we're now using fonttools string decoding instead of the ad-hoc decoding implemented in #365