Skip to content
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

Support new AFDKO variable layout syntax #2228

Closed
wants to merge 293 commits into from

Conversation

simoncozens
Copy link
Collaborator

@simoncozens simoncozens commented Mar 18, 2021

Implements the variable scalar and conditional feature format proposed in this AFDKO discussion:

pos A B' <0 (wght=200:-100 wght=900:-150 wght=900,wdth=150:-120) 0 0> C' D;

@davelab6
Copy link
Contributor

@simoncozens simoncozens changed the title Support variable scalars in feature file Support new AFDKO variable layout syntax May 24, 2021
@simoncozens simoncozens marked this pull request as ready for review May 24, 2021 14:24
@simoncozens
Copy link
Collaborator Author

OK, something odd seems to have happen to main since I started writing this, because it passed tests until I rebased. What is happening is that when builder_test does:

        self.expect_ttx(font, self.getpath("%s.ttx" % name))
        # Check that:
        # 1) tables do compile (only G* tables as long as we have a mock font)
        # 2) dumping after save-reload yields the same TTX dump as before
        for tag in ('GDEF', 'GSUB', 'GPOS'):
            if tag in font:
                data = font[tag].compile(font)
                font[tag].decompile(data, font)
        self.expect_ttx(font, self.getpath("%s.ttx" % name))

the first TTX is correct, but after compile/decompile roundtripping, additional comments for FeatureVariationCount, ConditionCount and LookupCount have been added to the TTX:

--- /Users/simon/others-repos/fonttools/Tests/feaLib/data/variable_conditionset.ttx
+++ /var/folders/js/26vkgd8s5x15c5kwbhq2c2jw0000gn/T/tmpp1m8cmke/tmp1.ttx
@@ -39,10 +39,8 @@
     </LookupList>
     <FeatureVariations>
       <Version value="0x00010000"/>
-      <!-- FeatureVariationCount=1 -->
       <FeatureVariationRecord index="0">
         <ConditionSet>
-          <!-- ConditionCount=1 -->
           <ConditionTable index="0" Format="1">
             <AxisIndex value="0"/>
             <FilterRangeMinValue value="0.625"/>
@@ -54,7 +52,6 @@
           <SubstitutionRecord index="0">
             <FeatureIndex value="0"/>
             <Feature>
-              <!-- LookupCount=1 -->
               <LookupListIndex index="0" value="0"/>
             </Feature>
           </SubstitutionRecord>

Obviously I can't keep both tests happy. I'm not sure what to do about this.

@anthrotype
Copy link
Member

the meaning of that tests is, if you're building those FeatureVariations and Feature records, you need to make sure the *Count fields are set at build time, and not rely on the compiler which will (re)set those for you; that way dumping to TTX straight after constructing the table objects will give the same output as building followed by compile.
The expected variable_conditionset.ttx should have those count fields set, but from that diff it looks like it has not.

@anthrotype
Copy link
Member

it passed tests until I rebased

I'm not exactly sure what would have changed in the meantime

@simoncozens
Copy link
Collaborator Author

Got it, thank you.

@ctrlcctrlv
Copy link
Contributor

Please rebase again when you get a chance @simoncozens. I need a commit later in history.

simoncozens and others added 19 commits October 22, 2021 08:35
Previously otlLib was generating None if the values themselves were
empty even if the value format was non-empty.  This happened to work
for compiling to binary since the compiler handles Value=None.

But this was confusing varLib.merger module (as in when building
variable fonts from such otlLib-built master GSUB/GPOS tables, without
roundtripping to OTF/TTF binary first), because in varLib.merger,
a None means "this master doesn't provide that info; skip it"; whereas
in a PairPos table a None as generated by otlLib simply meant "all
values are zero", which is different from "this master doesn't
provide this value".

This fixes that, such that ufo2ft can build variable-font without
saving masters to binary.

Part of googlefonts/ufo2ft#486
…ubst

The format values for those are automatically handled in
postRead/preWrite to choose optimal format.  As such, don't write them
in XML.  Reduces noise.

fonttools#2236 (comment)
@simoncozens
Copy link
Collaborator Author

Ack, messed this up. Will reopen.

@simoncozens
Copy link
Collaborator Author

-> #2432

@simoncozens simoncozens deleted the fealib-variable-scalar branch October 22, 2021 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet