If a FeatureVariationRecord with the same ConditionTable exists re-use
it and append FeatureTableSubstitutionRecord’s.
Without this, in the following feature code only the first lookup will
be applied since there will be two FeatureVariationRecord with the same
ConditionTable, so the first will be matched and the other will be
skipped:
conditionset test {
wght 600 1000;
wdth 150 200;
} test;
variation ccmp test {
sub e by a;
} ccmp;
variation rlig test {
sub b by c;
} rlig;
With this change only one FeatureVariationRecord will be created with
two FeatureTableSubstitutionRecord’s.
Currently, addFeatureVariationsRaw always deletes existing GSUB.FeatureVariations and overwrites them with the newly built records.
It doesn't have to, though. If the features for which we are adding feature variations are not already "variable", we can simply append the DS-rules-generated records to the FeatureVariations.
We raise an error if the existing FeatureVariations already reference the same feature tags used for the DS rules, as that could generate ambiguity/undefined logic.
* Add default auto doc options
* Ensure all references are unique
* Use anonymous links to avoid duplicate references
* Remove default options, fix wrong module name
* Don’t index repeated class
* Remove repeated classes included through automodule
* Fix warnings
* We don’t use our own static directory
* Correctly format XML in docs
* Fix indentation
* Fix overline
* Bring TOC to top
* Fix definition list
* Offset definition lists and examples
* Fix erroneous markup
* Fix markup
* Already included in automodule
* Fix args markup
* Correct markup for example
* Don’t reindex repeated module
* Correct XML code block markup
* Fix markup errors, change example to doctest
* Correct list markup
* Make ttx docstring both valid RST and valid help output
* Various other boring markup fixes
* Fix example indenting
* Make docstring valid RST and valid help output
* Mock import for reportlab
* It’s ok if manual links don’t appear in toctrees
* Oops typo, I guess doctests are useful
* Allow feature variations to be active across the entire space
* Add test with empty condition set
* Skip initial box instead of removing it
* Correct comment
this is done automatically upon compiling; however it's good to do it here
as well, in case one wants to pass the updated font directly to other modules
like 'subset' which requires these fields to be present -- without having
to first compile and decompile.
the buildGSUB function creates an empty GSUB with no FeatureRecords, so the
FeatureIndex list should be empty initially; the index of the newly created
rvrn feature record will be appended later on by addFeatureVariationsRaw
function.
See 0283b1f.
By finishing overlayBox() to cull remainder box when possible, we generate
far fewer spurious boxes, if any.
For the featureVars_test.py test case, this now generates optimal output,
that is, 2*n - 1 boxes.
Running time for n=20 stays at 0.06s, which is probably Python startup
time.
Running time for n=100 is down from 2.5s with unoptimized new algorithm,
to 0.17s for this and number of output boxes from 5050 to the optimal 199.
Fixes#1372 again
Whereas previous algorithm had exponential running time and return
value size, new one has quadratic.
For featureVars_test.py test case, for example, which is a pathological
test case of n sliding intervals, the number of output intervals of
various algorithms are:
- Previous algorithm: 2**n - 1
- New algorithm: n*(n-1)/2
- Optimal algorithm: 2*n - 1
Ie, we go from exponential to quadratic, whereas in this case the optimal
solution is linear.
Running time of said test, for n=20, goes from over 20s, to 0.06s.
The algorithm can be improved. The overlayBox() function currently does
not try to shrink the remainder box. Doing that will probably bring us
to optimal solution for this test case.
Fixes https://github.com/fonttools/fonttools/pull/1372
One test is failing. Needs to be investigated that new output is correct,
and test expectations updated.