-
Notifications
You must be signed in to change notification settings - Fork 475
[varLib.mutator] Add support for macOS overlap rendering flag in instantiateVariableFont #1518
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
[varLib.mutator] Add support for macOS overlap rendering flag in instantiateVariableFont #1518
Conversation
…of the glyf table, glyph first Outline Flag byte to 1 addresses macOS-specific inverted rendering issue with overlapping contours
… of macOS overlap rendering flag setting
Thanks Chris. I’m thinking that maybe we should always set that bit 6 by default when instancing a varfont with mutator. |
Not sure. According to docs that I've come across the answer seems to be that they should not but I've done no testing to confirm this.
OK. No problem. I will change it. Thanks for taking a look at this Cosimo. |
By the way, I also came across this information in the Microsoft docs re: overlapping contours between the components of compound glyphs:
Something that we should be addressing in the same fashion as the OVERLAP_SIMPLE issue here? |
Composite glyphs with overlapping components are less common. I’m leaning towards tackling that separately, and only when/if need arises. |
Letters with cedilla (ç Ç ş Ş) and with ogonek (Ą ą Ę ę) come to mind as possible common cases. |
I suggest doing The Right Thing™ which is setting this bit by default. If someone later asks for making it configurable and shows a valid need for it, then it can be made so. |
@khaledhosny I am re-working this to make setting the bit the default behavior. Are you suggesting that we eliminate the flag to turn this behavior off in the command line executable? |
Or better stated, that we not replace the current switch that turns the behavior on when it is non-default with a switch to turn it off when it is default... |
Yes. If we don’t know of a valid reason why the flag should not be set, then it is just over-engineering to make an option for it. This discussion is deep into bikeshedding already, so please do whatever you feel is sensible. |
@miguelsousa Shall we open a new issue report to investigate this? I haven't looked into the compound glyph / bit10 setting issue and can't verify that the same rendering problem that we are addressing here exists. |
Sounds good. Thanks. |
…rary flagOverlapSimple constant
… instantiateVariableFont function Also removes command line switch from varLib.mutator executable and eliminates unnecessary unit test. This new default behavior breaks the mutator unit tests
This revision was made as a result of the new default instantiateVariableFont behavior that sets OVERLAP_SIMPLE flag to 1. This modifies the expected ttx XML to include overlap="1" setting on first point of contour definitions
bf5d5eb : revision to set OVERLAP_SIMPLE bit to 1 by default in e4c2e2e : fixes unit test expected ttx files with GTG on my end based upon requests for changes so far. Let me know if there is anything else that you need. |
Yeah, I think we should enable both OVERLAP_SIMPLE and OVERLAP_COMPOUND flags by default. They are supposed to force the rasterizer to use nonzero fill rule, which is the only one supported for variable fonts, hence should also be for the static instances derived from the latter. |
From Microsoft OT docs for Composite Glyph Flag OVERLAP_COMPOUND:
Something like this do that? flagOverlapSimple = 0x40 # defined in ttLib.tables._g_l_y_f
OVERLAP_COMPOUND = 0x0400 # defined in ttLib.tables._g_l_y_f
for glyph_name in glyf.keys():
glyph = glyf[glyph_name]
if glyph.isComposite():
glyph.components[0].flags |= OVERLAP_COMPOUND
elif glyph.numberOfContours > 0:
glyph.flags[0] |= flagOverlapSimple |
@chrissimpkins yes, that patch should work. I'm slightly annoyed by the stylistic difference (camelCase vs SNAKE_CASE) in the two constant names, but I guess it's too late to change that. |
…files this adds expected flags for new OVERLAP_COMPOUND (bit 10) set to 1 by default in the instantiateVariableFont function
… to 1 adds this to instantiateVariableFont function
…s parameter to overlap
@miguelsousa this PR now sets the OVERLAP_COMPOUND bit by default in the |
@khaledhosny We now set |
thanks Chris! |
I added back a |
Note that |
Associated IR: #1281 #730
Associated PR: #1316
Edd Harrington came across the macOS overlapping contour rendering issue that is described in https://github.com/twardoch/test-fonts/tree/master/varia/160413-EvenOddTT with instances that were built from variable fonts using a
fontTools.varLib.mutator.instantiateVariableFont
based Python 3 script. Instance font glyphs with overlapping contours render with inverted "holes" at the sites of overlap when viewed in Chrome 73.0.3683.27 on macOS 10.14.3.From Microsoft
glyf
table documentation:Cosimo provided the source for the visually verified fix in our VF-> static build script and this PR adds this source to the fontTools library using a new parameter in the
instantiateVariableFont
function. These changes set the OVERLAP_SIMPLE bit to 1 by default during execution of this function and on execution of thefonttools varLib.mutator
command line executable.It also includes:
- a new--setbit6
switch to activate this new, non-default setting withfonttools varLib.mutator
on the command line- new test +*.ttx
test fileEDIT: After discussions in this thread, this PR also modifies
instantiateVariableFont
function to set the OVERLAP_COMPOUND bit to 1 in composite glyphs by default too.