1768 Commits

Author SHA1 Message Date
Behdad Esfahbod
645a3eb104 [GlyphCoordinates] Use float.is_integer() 2021-04-08 10:43:20 -06:00
Behdad Esfahbod
c5e3fca636 [GlyphCoordinates] Format 2021-04-08 09:48:35 -06:00
Behdad Esfahbod
5c815a6def [TupleVariation] Do away with another bytesjoin() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
a715f57130 [TupleVariation] Optimize compilePoints() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
6abf8680b4 [TupleVariation] More bytes optimization 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
250e59886f [TupleVariation] Micro-optimize away a lambda 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
62a89bc3d5 [TupleVariations] Optimize serialization loops 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
b1b672e17e [TupleVariation] Remove a few hot asserts
We verify the code instead.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
4cbf6ae1c4 [TupleVariation] Minor 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
d5d771b2bf [TupleVariation] Use array.array to serialize multiple deltas 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
1e6b20cc2c [TupleVariation] Don't round deltas (again!)
Remove tests that passed float in.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
9405244617 [TupleVariation] Use bytearray() instead of io.Bytes() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
869f00507b [glyf] Use bytearray() instead of array.array('B') for flags 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
db918e3355 [glyf] Use bytearray() in trim() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
bbbc877af9 [glyf] Remove several bytes slicings 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
8284af6b61 [TupleVariation] Use list(coordinates) instead of coordinates[:]
The latter is more expensive in GlyphCoordinates().
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
c23a540d07 [GlyphCoordinates] Micro-optimize _i() access 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
b5af979fbd [glyf] Minor 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
1f3c23e62b [glyf] Remove most use of py23 byteord etc 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
693bf0457a [glyf] Remove reprflag()
If compatibility is an issue, we should rewrite it in terms of "bin(flag)".
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
9be029c0cc [glyf] Remove unnecessary use of byteord() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
fb196fdf7d [glyf] Avoid a copy during decompile of flags 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
e328ee0254 [glyf] Use memoryview() in decompile for larger glyphs 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
4ff6b3390e [glyf] Use bytearray() when compiling 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
3252ed10ee [GlyphCoordinates] Remove unused .isFloat() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
b63b8ceb8b [GlyphCoordinates] Remove internal dual representation
Always store coordinates as float. Convert to int in __getitem__() if is whole.

This changes observed values. But we never made any guarantees so that's fine.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
acc56bdf72 [GlyphCoordinates] Faster .zeros()
Using .frombytes() since bytes() constructor can make zeros fast.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
7ef101ccb1 [GlyphCoordinates] Speed up .zeros()
Such a pain that this is a speedup...
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
f6e8577476 [GlyphCoordinates] Revert back from double to float
We do proper rounding these days, so revert this back.

https://github.com/fonttools/fonttools/pull/964#issuecomment-814511128
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
e9acd9634f [GlyphCoordinates] Store int data as 4byte, not 2byte
The memory increase is negligible, but means that we don't have to
worry about integer overflows anymore.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
8be2f49b84 [GlyphCoordinates] Speed up __imul__()
Like the recent change to __isub__/__iadd__().

This, as well as the other, change do not handle overflows.
Going to fix that now.
2021-04-08 09:41:45 -06:00
Behdad Esfahbod
77abdad0f7 [GlyphCoordinates] Move identity check to scale() / translate() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
45e94ff2bd [GlyphCoordinates] Speed up __isub__() and __iadd__() 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
3892ece50c [GlyphCoordinates] Remove Jython workaround 2021-04-08 09:41:45 -06:00
Just van Rossum
bf1b480064
Merge pull request #2251 from justvanrossum/improve-ttfont-getitem
[ttLib] Refactored TTFont.__getitem__ somewhat
2021-04-01 12:04:44 +02:00
justvanrossum
c7e736790f TTFont.save: create file on disk only after compilation to tmp stream succeeded. This fixes #536 2021-03-31 15:38:39 +02:00
justvanrossum
6ff4444c41 refactored TTFont.__getitem__ somewhat: don't do major work in an exception handler; factor reading table from file into separate function 2021-03-30 21:26:54 +02: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
Chris Simpkins
7abf2e4c75
transition basestring to str
https://github.com/fonttools/fonttools/issues/2232
2021-03-27 10:23:29 -04:00
Behdad Esfahbod
6243a24a09 [otBase] Delete .Format if was introduced by .preWrite()
https://github.com/fonttools/fonttools/pull/2238#issuecomment-805192631
2021-03-23 18:13:07 -07:00
Behdad Esfahbod
03d0a62078 Remove .Format from MultipleSubst as well 2021-03-23 18:01:06 -07:00
Behdad Esfahbod
8f79235d00 [Tests] Remove hack after Coverage .Format removal 2021-03-23 11:44:13 -07:00
Behdad Esfahbod
10fe1c2636 Don't write Format for Coverage, ClassDef, Single/Alternate/LigatureSubst
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.

https://github.com/fonttools/fonttools/pull/2236#issuecomment-804523961
2021-03-23 11:01:53 -07:00
Behdad Esfahbod
0faf01d5f1 [otlLib] Generate Value1 / Value2 if respective formats are non-zero
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 https://github.com/googlefonts/ufo2ft/pull/486
2021-03-19 13:59:27 -06:00
Behdad Esfahbod
606b072f40 [glyf] Add round=otRound parameter to GlyphCoordinates.toInt() & __round__() 2021-03-04 09:43:08 -07:00
Behdad Esfahbod
77acdbced3 [glyf] Remove stale comment about Python 2 2021-03-04 09:20:43 -07:00
Behdad Esfahbod
abc1ba07a4 [misc.roundTools] New module; move otRound() here
Code relying on old place (fixedTools.otRound) still works.
2021-03-04 09:20:43 -07:00
Zachary Scheuren
0434b1a917
Add feaLib support for STAT table 2021-02-25 17:16:01 +00:00
Cosimo Lupo
4dcc7f83d2
otTables: add Paint.traverse method
paint graph traversal mostly adapted from rsheeter's https://github.com/googlefonts/nanoemoji/pull/233
2021-02-15 11:12:16 +00:00
Cosimo Lupo
4036512a27
C_O_L_R_: factor out method to convert v0 layer records to dict of list
we'll need that when we subset the COLRv0 portion of a COLRv1 table
2021-02-15 11:12:16 +00:00