3514 Commits

Author SHA1 Message Date
Cosimo Lupo
e1d340cc65
[Tests] use absolute imports and add __init__.py where relevant
We can't use relative imports any more since the tests are now located outside the package.

I had to add __init__.py to Tests/feaLib/ so that pytest does not get confused by the presence
of two test files with the same basename: i.e. Tests/feaLib/builder_test.py and Tests/feaLib/builder_test.py

https://github.com/pytest-dev/pytest/issues/774
http://stackoverflow.com/questions/12582503/py-test-test-discovery-failure-when-tests-in-different-directories-are-called
2017-01-16 09:14:13 +00:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00
Cosimo Lupo
c54d7548e9 Delete .gitattributes as no longer needed
this was needed when we were using setuptools_scm/versioneer to add version to git archives
2017-01-15 21:35:52 +00:00
Cosimo Lupo
7ddef61691
Bump version: 3.5.0 → 3.5.1.dev0 2017-01-14 15:22:43 +00:00
Cosimo Lupo
40a44f39d0
Release 3.5.0 2017-01-14 15:22:42 +00:00
Cosimo Lupo
69a532cfbb
Update changelog 2017-01-14 12:11:38 +00:00
Cosimo Lupo
29f0a99a06
[t2CharStringPen] add docstring to T2CharStringPen to explain how 'roundTolerance' works 2017-01-14 12:11:21 +00:00
Cosimo Lupo
5479090856 Merge pull request #804 from anthrotype/t2pen-round
[t2CharStringPen] add "roundTolerance" option
2017-01-14 11:40:51 +00:00
Cosimo Lupo
8891f4185e
[t2CharStringPen] allow tolerance to be > 0.5
See https://github.com/fonttools/fonttools/pull/804#issuecomment-272559973
2017-01-13 22:32:10 +00:00
Sascha Brawer
849734d5b5 [avar] Adjust avar header to OpenType 1.8.1 erratum
https://www.microsoft.com/typography/otspec/errata.htm

No behavioral changes, no changes in API, no changes in binary format.
Resolves https://github.com/fonttools/fonttools/issues/807
2017-01-13 15:46:20 +01:00
Cosimo Lupo
c63fea0f8f
[subset] when no --output-file=, use INPUT_FILE.subset.{extension}
We should probably use cliTools.makeOutputFileName here for consistency with ttx,
but I know some prefer the approach taken by pyftsubset so I don't want force this.

Howver, I find it a bit annoying that when one is too lazy (like me) to specify
the --output-file=, the subsetter outputs a file ending with an invalid ".subset" extension, which Finder or Windows Explorer don't recongize as a font, and so one has to rename it anyway.

This makes the '.subset' string is inserted between the file name and its original extension (if any).
2017-01-13 12:50:46 +00:00
Cosimo Lupo
f168c0ccb5
[subset] allow to pass --options=... before the fontfile positional argument
The code in main() assumes that the first of the args which are not consumed by Options.parse_opts(args) is the positional argument (ie. does not start with  '--') for the input font file, and that is what the usage() says too.

However I find it myself writing --options=... first, and then at the end the positional arguments, as is the convention for many other Unix tools.

This patch makes this possible, while also keeping the current behavior.
2017-01-13 12:47:00 +00:00
Cosimo Lupo
2c142d7390
Update changelog 2017-01-13 11:35:40 +00:00
Cosimo Lupo
ff07d30c33
[Snippets] remove apply-feature-file; this is now feaLib/__main__.py 2017-01-13 11:26:50 +00:00
Cosimo Lupo
48c12bda63
[feaLib] add __main__.py so one can call fonttools feaLib
This is the same as Snippets/apply-feature-file.py

Fixes #569
2017-01-13 11:26:26 +00:00
Cosimo Lupo
a0e74f7e69
move ttx.makeOutputFileName to new misc.cliTools module
so it can be reused for other console scripts
2017-01-13 11:16:01 +00:00
Cosimo Lupo
456e159a5a
[t2CharStringPen] raise ValueError if tolerance not in range 0 <= t <= 0.5 2017-01-13 09:34:42 +00:00
Cosimo Lupo
0a9800b109
[t2CharStringPen] use abs() instead of math.fabs()
abs ends up calling fabs for floats anyway, and is a bit faster if 'number' is an int
2017-01-13 09:25:49 +00:00
Cosimo Lupo
3165fa9703
[t2CharStringPen] always round the advance widths regardless of roundTolerance
hmtx only can have integer values, so it would be weird to have widths as float in CFF...
2017-01-12 22:38:28 +00:00
Cosimo Lupo
adac78591d
[t2CharStringPen] restore default rounding; tolerance must be between 0 and .5 2017-01-12 21:34:59 +00:00
Cosimo Lupo
20375ca41c
[t2CharStringPen_test] add tests for coordinate rounding and basic pen commands 2017-01-12 19:53:38 +00:00
Cosimo Lupo
834d0d4cca
[t2CharStringPen] disable rounding coordinates; add 'roundTolerance' argument
Rounding of coordinates is now disabled by default.

The pen now accepts an optional 'roundTolerance' float, with values between
0 and 1 (default is 0).

Values >= 0.5 mean round all coordinates to integers.

Values between 0 and 0.5 mean round only when the absolute difference
between the original float and the rounded integer is within the tolerance

Fixes #769
2017-01-12 19:48:55 +00:00
Cosimo Lupo
cb94d6c4cd [feaLib] fix check for redefined glyph between multiple markClass definitions (#803)
* [feaLib.ast] fix checking multiple markClass definitions don't redefine same glyphs

As pointed out by @mhosken, we are looking in the wrong list for glyphs
that have already been defined in a previous markClass definition.

With this patch, the current markClass.fea test case fails becuase it defines 'acute'
twice for the same @TOP_MARKS class:

fontTools.feaLib.error.FeatureLibError: Lib/fontTools/feaLib/testdata/markClass.fea:6:5: Glyph acute already defined at Lib/fontTools/feaLib/testdata/markClass.fea:3:1

Also see conversation at:
3b79d51755 (r94622074)

* feaLib/testdat/markClass.fea: remove duplicate 'acute' in @TOP_MARKS

Now the test pass, after 45c77b7

* [feaLib.builder_test] test case for redefined glyph in multiple markClass definitions
2017-01-12 15:39:21 +01:00
Cosimo Lupo
04c1c68d18
Update changelog 2017-01-12 14:35:48 +00:00
Cosimo Lupo
ea8608c168
[minor] whitespace 2017-01-12 13:36:06 +00:00
Cosimo Lupo
3dd31c8689
[feaLib.builder_test] minor refactoring in check_fea2fea_file 2017-01-12 13:21:20 +00:00
Cosimo Lupo
3bd0788a37
[feaLib] use generator expressions with "".join(), instead of list comprehensions
This should be a bit more efficient as we don't need to create a temporary list
object before passing it to "".join() method of str; the latter accepts any
Iterable
2017-01-12 11:49:54 +00:00
Martin Hosken
7387f0eebf
Put back buggy code that we don't want to deal with yet 2017-01-12 11:34:44 +00:00
Martin Hosken
7d01f365ea
Tidy up spacing, make generic fea2fea checker 2017-01-12 11:34:44 +00:00
Martin Hosken
15f4cfa2d3
whitespace reallignment for self.ast in fealib parser 2017-01-12 11:34:43 +00:00
Martin Hosken
4044abfeb3
Add .feax test file extension to project manifest 2017-01-12 11:34:43 +00:00
Martin Hosken
a23da5384b
Add ast subclassing, extension commands and an example test 2017-01-12 11:34:43 +00:00
Cosimo Lupo
a8cafa3600
Update changelog 2017-01-12 11:15:57 +00:00
Cosimo Lupo
2a4b3d5814
[Snippets] add otf2ttf.py using cu2qu for CFF -> TrueType conversion
See discussion at https://github.com/fonttools/fonttools/issues/802

Derived from:
https://github.com/googlei18n/cu2qu/issues/47
2017-01-12 11:02:41 +00:00
Sascha Brawer
3ef8b0dbba [gvar] Add unit tests for gvar.fromXML() and gvar.toXML() 2017-01-11 15:35:56 +01:00
Sascha Brawer
963b63b536 [cvar] Mention implementation of cvar table in NEWS 2017-01-11 15:18:41 +01:00
Sascha Brawer
f5465d6d6e [gvar] Add unit tests for gvar.compile() and gvar.decompile() 2017-01-11 15:15:44 +01:00
Cosimo Lupo
64bdb589c4 Merge pull request #799 from anthrotype/man-page-install-dir
always install manpage; allow to override destination via env var
2017-01-11 13:21:24 +00:00
Cosimo Lupo
dcc95e10d9
Update changelog 2017-01-11 13:18:58 +00:00
Cosimo Lupo
530533ec60
setup.py: allow to override default "share/man" via environment variable
Apparently on some BSD systems man pages go to /usr/man instead of /usr/share/man.
It's too complicated to keep track of all the nuances of Linux distros so package maintainers can simply override the default via a $FONTTOOLS_MANPATH env variable

Fixes #84
2017-01-11 13:18:57 +00:00
Cosimo Lupo
46fdd14bb1
[Doc] move man pages to Doc/man/man1 sub-folder
it's better to group man pages in a separate sub-folder in case we add alternative doc formats in the future, or if we add additional man pages.

This also allows to read man pages directly from the source tree, e.g. via `export MANPATH=Doc/man`, or `man -M Doc/man ttx`
2017-01-11 13:18:57 +00:00
Cosimo Lupo
fb6d3f6356
setup.py: always install ttx manpage (even when not used); remove platform-specific branch
It's not a good thing that we build different wheel packages (with/without data_files) according to the platform we build them with.
After all, these wheels are meant to be "universal".

Even when manpages can't be used on a target platform (e.g. Windows), their mere presence should not do any harm; they are simply copied to a 'share/man' folder relative to the python prefix. On Unix systems (Linux, Homebrew, etc.) this is usually `/usr` or `/usr/local`, so `man ttx` just works (TM).

Note that other popular python tools like IPython or Sympy also install manpages the same way we do here with ttx, and they do that unconditionally for all platforms.

As regards issue #796, whereby attempting to `sudo pip install fonttools` fails because the manpage file is copied to a SIP-protected location on OSX El Capitan and above:

Users who still wish to install fonttools globally with sudo (and are not scared after googling 'why sudo pip is bad'), can still use the '--install-data' option of setup.py install to modify the data_files base installation directory.

If you install with pip (recommended over `python setup.py install`), you can use --install-option to pass through installation options to setup.py (which is run by pip when installing from source).

For example, to install man pages to /usr/local/share/man/man1/*.1 you could pass "/usr/local" as the base directory for --install-data, like so:

sudo -H /usr/bin/python -m pip install --install-option="--install-data=/usr/local" fonttools
2017-01-11 13:18:57 +00:00
Cosimo Lupo
49bcbb916b
consistently do sys.exit(unittest.main()) in all test modules
So that when run as scrips they report test failures with exit code

Follow up on b7bb391033ef3255c90134da3d7aef50d2d5326d
2017-01-11 13:05:35 +00:00
Cosimo Lupo
2e2125f173
[minor] remove redundant sys import 2017-01-11 12:24:04 +00:00
Cosimo Lupo
e5dbc85463
[mtiLib] add __main__.py to allow running package as module
This now works:

$ fonttools mtiLib

or which is the same:

$ python -m fontTools.mtiLib
2017-01-11 12:15:33 +00:00
Cosimo Lupo
b7bb391033
don't use sys.exit(...) inside main(), but only under if __name__ == "__main__"
The convention is that sys.exit(...) is called only if a module is run as a script,
and that main() entry points use return statements to report exit codes: 0 (or None)
for successful execution, or any non-zero integer for errors.

E.g. see the console scripts generated when installing with pip.
2017-01-11 12:10:58 +00:00
Cosimo Lupo
ae05b2a583
[logging] for runnable modules, spell out module name instead of using __name__
If a module is run as script, as in `python module.py` or when using
`runpy.run_module()`, then __name__ == "__main__".

So when we instantiate modules' loggers with `logging.getLogger(__name__)`,
those loggers' name may become "__main__" when run as scripts, and hence
fall outside of the "fontTools" logging namespace.

fontTools.configureLogger() by default only configures the "fontTools"
library loggers, anything outside of it (e.g. logger called "__main__")
is not attached a handler.

So here I name loggers explicitly instead of relying on __name__, but
only for modules which can be run as "__main__".

Fixes #801
2017-01-11 11:58:17 +00:00
Behdad Esfahbod
0cc1721b8d [MVAR] Update for OT 1.8.1 rename 2017-01-10 11:01:06 -08:00
Behdad Esfahbod
84c584cfc9 [cmap] When compiling format 0, fill in non-existing entries
Fixup for 88026de5100e4b3cedf0424bcc033f76782eb99e

Fixes https://github.com/fonttools/fonttools/issues/800
2017-01-10 10:48:48 -08:00
Sascha Brawer
155ec67ae6 [cvar] Implement cvar table 2017-01-10 17:57:04 +01:00