84 Commits

Author SHA1 Message Date
Behdad Esfahbod
ea505154df [gvar] Avoid a copy in compileGlyph_() 2021-04-08 15:50:52 -06:00
Behdad Esfahbod
b811c3f3f3 [gvar] Remove use of bytesjoin() 2021-04-08 12:18:58 -06:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
justvanrossum
b4c5b07741 sort XML output by glyph name 2020-04-29 16:31:54 +02:00
Chris Simpkins
791f619029 refactor array.tostring to array.tobytes
the array.tostring method is deprecated
2019-08-29 23:21:22 -04:00
Chris Simpkins
12814aa7b1 refactor array.fromstring to array.frombytes
fromstring is a deprecated array method
2019-08-29 22:58:42 -04:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
fb914c93c4
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-04 14:15:14 +01:00
Cosimo Lupo
aef41419f2
gvar: log the glyph name if any exception is caught when decompiling deltas 2019-04-03 10:54:54 +01:00
Cosimo Lupo
742b1d784a gvar: minor whitespace
mixed tab/spaces freak out my vim
2019-03-08 15:56:38 -08:00
Behdad Esfahbod
349cd94d17 [graphite] Fix for big-endian
Make all "if sys.byteorder..." and "byteswap" be on the same line for
earsier grep verification.

Fixes https://github.com/fonttools/fonttools/issues/1311
2018-09-05 21:12:53 -07:00
Behdad Esfahbod
f82128f25d Kill progress argument
Fixes https://github.com/fonttools/fonttools/issues/1008

Doesn't touch xmlReader / xmlWriter modules.
2018-01-25 17:30:23 -08:00
Sascha Brawer
155ec67ae6 [cvar] Implement cvar table 2017-01-10 17:57:04 +01:00
Sascha Brawer
689008a4f5 [gvar/cvar] Rename decompileVariationTuples to decompileVariationTupleStore
For consistency with the terminology of the OpenType 1.8 specification,
and for symetry with the compileVariationTupleStore function.
2017-01-09 19:00:39 +01:00
Sascha Brawer
5d3eae404c [cvar] Compile TupleVariationStores in common library 2017-01-09 17:34:45 +01:00
Sascha Brawer
c3d68a684e [cvar] Move compileSharedTuples() to module TupleVariation 2017-01-09 17:01:43 +01:00
Sascha Brawer
87d854e881 [cvar] Move decompilation of shared tuples to TupleVariation.py 2017-01-09 14:25:16 +01:00
Sascha Brawer
24a02fedd7 [cvar] Refactor decompilation of tuple variation stores 2017-01-09 14:05:52 +01:00
Sascha Brawer
7c082600d3 [cvar] Move decompilation for single TupleVariation out of gvar
Rename local variables to match terminology of OpenType 1.8 specification
2017-01-09 12:14:12 +01:00
Sascha Brawer
980ee57b0e [gvar] Rename gvar.decompileSharedCoords() to decompileSharedTuples()
The new name is consistent with the terminology of the OpenType 1.8
specification, which calls the decoded structure the `SharedTuples`
array.
2017-01-05 14:18:52 +01:00
Sascha Brawer
039cb48927 [gvar] Move gvar.computeMinMaxCoord() to TupleVariation.inferRegion()
Document what this helper function does, using terminology from
the OpenType 1.8 specification.
2017-01-05 13:35:27 +01:00
Sascha Brawer
39c4ef621c [cvar] Change warning message for out-of-range points 2017-01-05 08:55:36 +01:00
Sascha Brawer
01f95fc190 [gvar] Rename header fields to match OpenType specification
The initial implementation had been written with Apple's TrueType
specification, before OpenType supported variations.
2017-01-04 16:24:32 +01:00
Sascha Brawer
271987a89f [gvar] Adjust comment about broken variation fonts on macOS 2017-01-04 14:31:52 +01:00
Sascha Brawer
3420bb116c [gvar] Move TupleVariation to its own source file
The TupleVariation structure is used both for `gvar` and `cvar`.
2017-01-04 14:07:38 +01:00
Sascha Brawer
1d28abdb65 [gvar] Rename GlyphVariation to TupleVariation
In the OpenType 1.8 specification, this is called TupleVariation
so let's be consistent with the spec. (The initial implementation
in fonttools pre-dates OpenType 1.8).
2017-01-04 12:41:55 +01:00
Sascha Brawer
a837a3950f [gvar] Use flag names from OpenType 1.8
FontTools has initially been implemented using the Apple TrueType
specification.  When OpenType adopted variations, some identifier
names were changed.
2017-01-03 17:09:47 +01:00
Behdad Esfahbod
8e46c6a121 [varLib] Err if gvar tuples have unknown location axes 2016-09-27 19:49:41 +02:00
Behdad Esfahbod
9c037fc826 [gvar] Add TODO 2016-07-16 21:22:20 -07:00
Behdad Esfahbod
b1eeaa5151 [gvar] Fix point encoding
Where more than one run is used, it's only the first run's first point
that is absolute, all other values are relative.

Similar fix landing in FreeType soon.  Fixes lizzard glyph (glyphname
"dollar") in Zycon.
2016-07-15 18:15:17 -07:00
Behdad Esfahbod
40198a2dec [gvar] Use array.array to decode deltas 2016-03-21 10:12:26 -07:00
Behdad Esfahbod
9987b7e14e [gvar] Use array.array to decode deltas 2016-03-21 10:12:26 -07:00
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Sascha Brawer
53e7db624a [GX] Make it easier to construct ‘fvar’ tables from code
In the previous table-driven implementation, client code had to
know the internals of the ‘fvar’ structure for correctly adding
variation axes to a font. In the new implementation, clients
do not have to futz around with binary offsets (which makes it
more likely that tools build correct fonts).
2015-06-24 15:05:03 +02:00
Behdad Esfahbod
37e6e6a380 Use dict comprehension now that we don't support Python 2.6 2015-06-11 17:05:15 -07:00
Sascha Brawer
7f6d2af45a [GX] Optimize ‘gvar’ tables for tuples affecting all points in a glyph
After this change, round-tripping through TTX shrinks the size of all
our test fonts. Specifically, Skia.ttf shrinks from 478K to 473K,
JamRegular.ttf from 113K to 107K, and BuffaloGalRegular from 67K to 61K.
2015-06-10 11:19:06 +02:00
Sascha Brawer
4bbc1f7e83 [GX] In ‘gvar’ code, rename numPoints to numPointsInGlyph
This make the code easier to understand, especially since there
is a diffence between numPointsInGlyph, numPointsInRun and
numPointsInData.

Also, we now pass numPointsInGlyph to compilePoints() to later
enable an optimization where numPointsInData == numPointsInGlyph.
However, this change does not yet make that optimization.
2015-06-10 10:54:08 +02:00
Sascha Brawer
f121b070f7 [GX] Emit correct number of points for long ‘gvar’ tuples
Before this change, the compilePoints() routine would wrongly clear
the most-significant bit of the lower byte in its binary output.

An example glyph affected by this bug was “perthousand.oldstyle” in
the version of Skia.ttf that Apple ships with MacOS X Yosemite 10.10.3.

Although the broken code path was exercised in the unit tests, the
length of the test input just happened to have the affected bit clear,
which is why this bug did not get caught by the previous test cases.
2015-06-10 09:46:18 +02:00
Sascha Brawer
1426431c2f [GX] Minor: Removed unneeded variable in “gvar” handling code 2015-06-09 15:17:58 +02:00
Sascha Brawer
1d211ff058 [GX] Removed unused function argument in ‘gvar’ handling code 2015-06-09 15:08:01 +02:00
Sascha Brawer
e39c2957de [GX] Fix some minor lint warnings by landscape.io 2015-06-09 14:04:33 +02:00
Sascha Brawer
624b2b7529 [GX] In ‘gvar’ tuples, treat (0,0) different from unspecified entries
After this change, MacOS Yosemite 10.3.3 renders the Oslash glyph
of Skia.ttf with the exact same outline before and after round-tripping
the font through TTX.  Before this change, the outlines were slightly
different after round-tripping through TTX.

In my initial reading of the “gvar” specification, I had assumed
that (0,0) entries had no significance. However, that is not
how the current MacOS implementation interprets it.
2015-06-09 12:41:40 +02:00
Sascha Brawer
64d8411c1c Remove work-around for https://github.com/behdad/fonttools/issues/286 2015-06-08 23:03:17 +02:00
Sascha Brawer
cd8af14991 [GX] Leave 'gvar' coordinates unchanged when round-tripping through TTX
Before this change, a rounding issue in fixedToFloat() would sometimes
change 'gvar' coordinate values when round-tripping Skia.ttf through TTX.
This change works around https://github.com/behdad/fonttools/issues/286.
2015-06-08 23:00:03 +02:00
Sascha Brawer
9dd0a7e4cd [GX] Replace range(len(...)) by enumerate(...)
This addresses 7271b779f3 (commitcomment-11374941)
2015-06-08 23:00:03 +02:00
Sascha Brawer
5ba59b3f4b [gvar] Take glyphs from gvar.variations
When compiling the set of shared coordinates, walk over glyphs in
self.variations instead of retrieving them in glyph order.

This addresses a code review comment:
0f86c1c0d3 (commitcomment-11375190)
2015-06-08 23:00:03 +02:00
Sascha Brawer
1447730438 Fix most pylint warnings for 'gvar' table 2015-06-08 23:00:03 +02:00
Sascha Brawer
513458f558 [GX] Test round-trip decompile/compile for glyph variations
Also, implement an __eq__ method on GlyphVariation so we can verify
whether the result of round-tripping actually equals the original input.
2015-06-08 23:00:02 +02:00
Sascha Brawer
54866e9294 Minor changes for Python 3 2015-06-08 23:00:02 +02:00
Sascha Brawer
6d5049cb57 Minor changes towards supporting python3. 2015-06-08 23:00:02 +02:00