2739 Commits

Author SHA1 Message Date
Behdad Esfahbod
0baeb5921b [otBase] Shuffle 2016-02-10 17:26:53 +07:00
Behdad Esfahbod
f65fc6f872 [otBase] Simplify _doneWriting() slightly
Should have NO functional change.
2016-02-10 17:03:46 +07:00
Behdad Esfahbod
74e629e600 [subset] Retain GSUB ScriptRecords, even if they are empty
This slightly bloats subset fonts, but fixes:
https://bugzilla.mozilla.org/show_bug.cgi?id=1080739#c15
https://github.com/behdad/fonttools/issues/518

At some point we might want to do something smarter based
on Unicode script of retained characters.
2016-02-10 16:22:24 +07:00
Sascha Brawer
809698611e [feaLib] Fix SequenceIndex in ChainContextPos
In the long term, we might want to make a different low-level API
for building ChainContextPos lookups; for now, this should fix the
current bug with SequenceIndex.

Resolves https://github.com/behdad/fonttools/issues/517.
2016-02-09 15:38:18 +01:00
Sascha Brawer
873f3570af [feaLib] Emit ChainContextPos before dependent SinglePos
There should be no semantic difference from this change,
since dependent lookups (the chain targets) are never directly
invoked by a feature. But the output of feaLib becomes more
similar to the output of makeotf, which helps debugging.
2016-02-09 09:25:54 +01:00
Sascha Brawer
5ab852277d [feaLib] Emit context-free contextual chains to SinglePos
Before this change, we had only emitted a SinglePos (GPOS type 1) lookup
for a statement like `pos A' B' 20`; after this change, we always emit a
chain rule even if there is no context. There is a semantic difference if
the rule is preceded by a `ignore pos` statement. Omitting context-free
contextual chains was actually not a (premature) optimization, but an
artifact that came from the representation of glyph patterns.

https://github.com/behdad/fonttools/issues/516
2016-02-09 09:00:06 +01:00
Sascha Brawer
bd6bea0f7f [feaLib] Allow non-disjoint markClasses
After this change, feaLib generates the exact same output as makeotf
for the test case in `bug453.fea`. Before this change, feaLib had
rejected the input as malformed.

Our new behavior is in blatant violation of the OpenType Feature File
Syntax specification, which writes: "NOTE! If a GDEF table is not
explicitly defined in the feature file, [...] all mark glyph classes
must be disjoint". However:

1. makeotf does not enforce this constraint;
2. existing feature files happily define non-disjoint markClasses;
3. existing tools such as the Glyphs font editor generate feature files
   with non-disjoint markClasses;
4. it is not obvious what the intention of this constraint would be.

Therefore, fewLib now follows the makeotf implementation, intentionally
ignoring what is mandated by the specification. I've proposed a spec change
at https://github.com/adobe-type-tools/afdko/issues/106.

Resolves https://github.com/behdad/fonttools/issues/453.
2016-02-08 10:27:31 +01:00
Cosimo Lupo
464057a4db [tox.ini] set *Test pattern for pytest's python_classes
The glob pattern determines which classes are considered for test collection by pytest.
We already follow this pattern for the unittest.TestCase derived subclasses
(which are collected regardless of this option).
2016-02-07 17:42:55 +00:00
Cosimo Lupo
3d68c07830 [.appveyor.yml] no need to upload sdist to 'artifacts'
this should save us a few extra seconds
2016-02-07 02:17:20 +00:00
Cosimo Lupo
ecf721fa7b Merge pull request #515 from anthrotype/pytest
use pytest to collect and run unittests and doctests
2016-02-07 02:12:05 +00:00
Cosimo Lupo
16f29ffd6d [loggingTools] use ellipsis for doctests when printing time
appveyor can be *very* slow

https://ci.appveyor.com/project/anthrotype/fonttools/build/job/pdrl7o5ggan7qlej
2016-02-07 01:19:45 +00:00
Cosimo Lupo
e30ad7e8a7 [woff2_test] import sstruct from fontTool.misc
oops.
2016-02-07 01:19:45 +00:00
Cosimo Lupo
7c6744e639 [py23_test] pass os.environ copy instead of empty dict to avoid issue on Windows
Otherwise I get this:
Fatal Python error: Failed to initialize Windows random API (CryptoGen)

https://ci.appveyor.com/project/anthrotype/fonttools/build/job/qhf8d89or4d5hiyd

see: http://bugs.python.org/issue20614
2016-02-07 01:19:45 +00:00
Cosimo Lupo
4a783326b8 [py23_test] need to use os.pathsep as Windows uses ";", not ":" 2016-02-07 01:19:45 +00:00
Cosimo Lupo
4874264dd9 [py23_test] pass the sys.path as PYTHONPATH to python subprocess
Apparently I need to do that, or the child python process does not see fontTools in the path.

Another workaround woud be to ensure that fontTools is installed, at least in editable or develop mode (via `pip install -e .`). But the way we temporarily extend the PYTHONPATH in run-test.sh is less intrusive.
2016-02-07 01:19:45 +00:00
Cosimo Lupo
3495029726 [.travis/install.sh] pip install from dev-requirements.txt 2016-02-07 01:19:45 +00:00
Cosimo Lupo
93d9356439 [.appveyor.yml] use tox to run pytest in a virtual environment; remove extra scripts
It seems like Appveyor no longer needs the batch script to configure the MSVC compiler variables.
Also, since appveyor already comes with all the python versions we need, we don't need the install.ps1 script any more.

Brotli is now installed by tox from requirements.txt inside the test virtualenv.
2016-02-07 01:18:30 +00:00
Cosimo Lupo
627a54d76f [requirements.txt] install Brotli from v0.3.0 tagged release 2016-02-07 01:04:20 +00:00
Cosimo Lupo
258cb84c52 [dev-requirements.txt] add pytest and tox to dev-requirements.txt
In theory only pytest would be required for devs to run the tests locally, but we also use tox for setting up the test virtualenvs on the CI.
2016-02-07 01:04:20 +00:00
Cosimo Lupo
41dff8456e [run-test.sh] use pytest to collect tests
This way test discovery will work not only with the current unittest and doctest modules, but also with pytest's own kind of tests.

When run with no argument, the shell script will call the py.test command, which will scan the whole Lib/fontTools directory for all relevant tests.

If args are provided, tests are filtered if any of the substrings specified
match. The filtering works not only on the modules' file names (as the previous grep approach), but also on the names of the test functions, classes and methods. Pretty cool, huh?

We can still specify whether to run pytest with python -2 or -3 (provided pytest is installed on both Python versions).
And we don't need to print the python version any more as pytest does it for us.
Finally, there's no need to export PYTHONPATH -- pytest takes care of that too!
2016-02-07 01:03:39 +00:00
Cosimo Lupo
118045abf0 [tox.ini] tell pytest to only collect tests from *_test.py modules; set pytest 'minversion' to 2.8
the glob pattern will restricts the search only for pytest's kind of tests; it has no effect on methods of unittest.TestCase derived class, since pytest still uses unittest's own collection framework to collect those.

The 'minversion' is required to support some of the latest advanced features.
The current py.test is 2.8.7. You can update it with `pip install --upgrade pytest`.
2016-02-06 20:59:00 +00:00
Cosimo Lupo
568b4e9129 [tox.ini] use 'testpaths' to tell py.test where to look for tests
this to avoid picking up undesired tests by accident when running `py.test` command without specific dirs or files
2016-02-06 17:12:01 +00:00
Sascha Brawer
d03ce3c119 [feaLib] Add unit test for the ignore pos statement
There are no examples for `ignore pos` in the OpenType Feature File
Syntax specification, therefore using a made-up example for the test.
The output from feaLib is identical to what makeotf generates.

Resolves https://github.com/behdad/fonttools/issues/503.
2016-02-06 12:13:03 +01:00
Sascha Brawer
b5d1124f43 [feaLib] Handle the ignore pos statement
https://github.com/behdad/fonttools/issues/503
2016-02-06 11:14:27 +01:00
Sascha Brawer
4a23f8eb85 [feaLib] Add unit test with spec section 5.f.ii, example 4
This is another test case for the `ignore sub` statement.
After the recent changes to feaLib, the output is now identical
to the output generated by makeotf.

https://github.com/behdad/fonttools/issues/503
2016-02-05 15:55:53 +01:00
Sascha Brawer
ec9077a566 [feaLib] Merge SingleSubst chain targets
This makes the output of feaLib more compact, using a similar technique
as seems to be used by makeotf.

After this change, feaLib generates output that more similar to makeotf:

* For the test cases in `bug512.fea` and `bug463.fea`, feaLib now
  generates the exact same output as makeotf v2.0.90.

* For the test cases in `GSUB_6.fea`, it is hard to say because makeotf
  crashes on the test file; our test contains language constructs that
  are valid according to the spec, but didn't yet get implemented by makeotf.
  When commenting out those constructs, feaLib generates the exact same
  output as makeotf v2.0.90.

* For the test cases in `feature_aalt.fea`, the output of feaLib is now
  structually the same as the output of makeotf v2.0.90.  However, two
  lookups are in different order. feaLib's ordering reflects the order
  of statements in the compiled input source; no idea why makeotf would
  want to reverse the ordering. Since this ordering difference only
  affects the _targets_ of chain substitutions, there is no semantic
  difference.

Resolves https://github.com/behdad/fonttools/issues/512.
2016-02-05 15:12:07 +01:00
Sascha Brawer
1ddfe24338 [feaLib] Support multiple chain contexts after ignore sub
Although this construct is in violation of the `ignore sub` grammar
given by the current OpenType Feature File syntax specification,
the very same specification document illustrates (in example 3
of section 5.f.ii) the `ignore sub` statement with a comma-separated
list of backgrack/input/lookahead triples.

See https://github.com/adobe-type-tools/afdko/issues/105 for a request
to amend the OpenType Feature File syntax specification.

After this code change, feaLib can now parse testdata/spec5f_ii_3.fea;
the output is identical to what is generated by Adobe's makeotf tool.

https://github.com/behdad/fonttools/issues/503
2016-02-05 11:02:29 +01:00
Sascha Brawer
a862f70880 [feaLib] Add unit test for spec section 5.f.ii, example 2
Output is identical to makeotf.
2016-02-05 08:35:18 +01:00
Cosimo Lupo
f8453d8a01 Merge pull request #510 from davelab6/patch-2
Snippets/README -> README.md, link to other utils
2016-02-04 18:15:56 +00:00
Dave Crossland
b49763c50a Snippets/README -> README.md, link to other utils
Closes #467
2016-02-04 13:14:34 -05:00
Sascha Brawer
27e23f9a95 [feaLib] Emit context-free chains to single substitutions
Resolves https://github.com/behdad/fonttools/issues/509
2016-02-04 16:45:05 +01:00
Sascha Brawer
dba1d6666b [feaLib] Emit chains to LigatureSubst even without backtrack or lookahead
https://github.com/behdad/fonttools/issues/506
2016-02-04 15:31:29 +01:00
Sascha Brawer
ea4a4e34b3 [feaLib] Reverse lookup order for chained single substitutions
This makes feaLib's output more similar to output from makeotf.
Resolves https://github.com/behdad/fonttools/issues/507.
2016-02-04 15:07:47 +01:00
Sascha Brawer
3d6cf0d8e6 [feaLib] Reverse lookup order for chained multiple substitutions
https://github.com/behdad/fonttools/issues/507
2016-02-04 14:46:22 +01:00
Sascha Brawer
7574260bed [feaLib] Reverse lookup order for chained alternate substitutions
For this construct, makeotf throws an error: "Contextual alternate
rule not yet supported". If it had been implemented, we speculate
that the ordering would likely be the same as with other contextual
substitutions (the chain comes before, not after, the dependent lookup).

https://github.com/behdad/fonttools/issues/507
2016-02-04 14:34:45 +01:00
Sascha Brawer
e8a4b341f3 [feaLib] Reverse lookup order for chained ligature substitutions
https://github.com/behdad/fonttools/issues/507
2016-02-04 14:24:48 +01:00
Cosimo Lupo
f6b8445515 [subset] catch OptionError exception, print usage + error and throw exit code 2 2016-02-04 12:17:01 +00:00
Sascha Brawer
ab7b86005e [feaLib] Implement the ignore substitution statement
https://github.com/behdad/fonttools/issues/503
2016-02-04 11:39:03 +01:00
Sascha Brawer
aae350c84a [feaLib] Change semantics of script statement
Before this change, the `script` statement had inherited global
defaults. After this change, it overrides them. The new behavior
matches the behavior of makeotf v2.0.90.

Resolves https://github.com/behdad/fonttools/issues/505.

For the test case of https://github.com/behdad/fonttools/issues/501,
which was about an unrelated problem, feaLib now produces the exact
same output as makeotf v2.0.90.
2016-02-04 10:31:33 +01:00
Sascha Brawer
f9a236f54e [feaLib] Allow script and language statements in named lookup blocks
Although the specification writes the exact opposite, makeotf does
accept script and language statements inside named lookup blocks.
Since Glyphs.app (and possibly other tools, too) produce feature files
that make use of this syntax, enforcing the spec would break existing
files.

Resolves https://github.com/behdad/fonttools/issues/501.
2016-02-04 09:52:20 +01:00
Sascha Brawer
a3f70370fe [feaLib] Add a unit test for compiling enum pos statements
Example from section 6b.ii of the OpenType Feature File specification.
2016-02-04 09:23:46 +01:00
Sascha Brawer
a1fa968576 [feaLib] Use a different approach to synthesizing feature aalt
Resolves https://github.com/behdad/fonttools/issues/502.
2016-02-03 17:38:38 +01:00
Sascha Brawer
edb1ed0fcc [feaLib] Synthesize alternate substitutions for feature aalt
After this change, feaLib synthesizes the same lookups as makeotf v2.0.90
for `feature aalt` in the example of section 8.a of the OpenType Feature
File specification.
2016-02-03 15:17:37 +01:00
Sascha Brawer
bf79ceb2f2 [feaLib] Disallow lookup blocks inside feature aalt
The new behavior matches how makeotf v2.0.90 interprets
the OpenType Feature File Specification.
2016-02-03 11:39:50 +01:00
Cosimo Lupo
f998cf1126 [ttLib] use boolean instead of int
I know it's same, but this looks more 'pythonic'
2016-02-02 18:26:50 +00:00
Cosimo Lupo
84d6f076a3 [ttLib] call XMLWriter.close() only if 'fileOrPath' is a path, not when it's a file
This allows to call `TTFont.saveXML` with an already open file/stream (e.g. sys.stdout or a StringIO) without it being abruptly closed at the end.

We do the same elsewhere when we reiceive file handles instead of path names, so we might do it here too.
2016-02-02 18:25:43 +00:00
Sascha Brawer
faeba0c0c0 [feaLib] Support lookups with mixed glyph/class-based kerning
Resolves https://github.com/behdad/fonttools/issues/456
2016-02-02 18:24:48 +01:00
Cosimo Lupo
14e1389d84 Merge pull request #500 from davelab6/patch-1
otBase.py log level adjustment
2016-02-02 15:11:48 +00:00
Dave Crossland
17007a36d6 otBase.py log level adjustment
Change log level of 'Attempting to fix OTLOffsetOverflowError' from warning to debug to close #499
2016-02-02 10:06:10 -05:00
Sascha Brawer
c64019b3c6 [otlLib] Move building of class-based PairPos sutables from feaLib to otlLib 2016-02-02 15:17:01 +01:00