85 Commits

Author SHA1 Message Date
Behdad Esfahbod
05950fcbab [cmap] Rewrite loop 2016-12-27 18:38:42 -05:00
Behdad Esfahbod
48f4e4ed04 [cmap] Factor out some common code 2016-12-27 18:36:59 -05:00
Cosimo Lupo
e40dffd86d [_c_m_a_p] don't set self.data = headerdata + data inside cmap_format_14.compile
self.data is usually set by decompileHeader as "the data after the header"; while here
it also included `headerdata`. This produced corrupt data if the compile method was called
again, as the header data is added again to self.data.

Moreover, in none of the subtable classes' `compile` methods, the re-compiled data is
stored in self.data, so we shall not do that for format 14 either.

Fixes #389
2016-01-31 21:00:11 +00:00
Cosimo Lupo
ff853c38b8 [_c_m_a_p] replace print with logger 2016-01-27 19:02:48 +00:00
Sascha Brawer
07458f62dd Support non-BMP characters for synthetic glyph names
When a font supplies no glyph names in its 'post' table, fontTools
builds synthetic glyph names by reversing the 'cmap' table.
After this change, the library looks at all 'cmap' subtables for
Unicode, irrespective of format or platform. For example, glyph #4
in NotoSansOldItalic-Regular.ttf gets now named "u10300" instead of
"glyph00004".

Moved the code for building a reversed 'cmap' table into the cmap class,
for easier testing.
2015-09-04 12:20:54 +02:00
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Cosimo Lupo
e05db5c75f [_c_m_a_p] fix compiling of cmap subtable format 6
Fixes https://github.com/googlefonts/fontbakery/issues/551

the `codes` variable needs to be a sorted list of cmap keys, else the following line
```python
codes = range(codes[0], codes[-1] + 1)
```
cannot work properly, since dict keys are unsorted.

Up until 13a08d0c3a59402459875155b7dbd194787fb229, there was a line with
```python
codes.sort()
```
which was deleted for some reason.
2015-06-27 17:01:51 +01:00
Behdad Esfahbod
c7b6d1943d Fix decompiling of cmap table
Previously, if a subtable's data was shared amongst two different encodings,
the second one being loaded was getting a cmap member assigned while retaining
its data item.  If we subset the cmap and then save that subtable, the original
unsubset data will be written out.  Fix, but removing data when assigning cmap.

Explains and obviates mystery hack in subsetter.
2015-06-22 19:14:09 -07:00
Behdad Esfahbod
3d6932549c Fix immediate decompiling of cmap subtables
This codepath never worked, and is never exercised during normal operations.
Found by landscape.io.
2015-04-26 03:01:25 -04:00
Behdad Esfahbod
b30e12ae00 More whitespace 2015-04-26 02:01:01 -04:00
Behdad Esfahbod
bd67253118 Some more whitespace fixes from pep8 tool 2015-04-26 01:59:01 -04:00
Behdad Esfahbod
5287b52d22 Whitespace 2015-04-26 00:49:36 -04:00
Behdad Esfahbod
5a18fc83e6 Add getEncoding() to cmap subtables 2015-04-19 03:50:55 -07:00
Behdad Esfahbod
4e616d2f7f Accept MS Symbol cmap tables as Unicode-compatible
Apparently these days these tables are used to encode symbols in
PUA, so they are still Unicode-compatible...

This follows a similar change in fontconfig.
2015-03-30 16:47:48 -07:00
Behdad Esfahbod
21af87536f [cmap] Split last segment of a format 4 efficiently
Fixes https://github.com/behdad/fonttools/issues/189
2015-01-22 00:10:01 -08:00
Behdad Esfahbod
9bd685a3ec [cmap] Remove bogus use of font.lazy
Ouch!
2014-07-14 20:01:04 -04:00
Behdad Esfahbod
62dd7b2a0e Refactor getSearchRange() 2014-05-27 16:01:47 -04:00
Behdad Esfahbod
9fed95216a Fix rangeShift calculations for count=0 in sfnt, cmap, and kern 2014-05-27 15:54:04 -04:00
Behdad Esfahbod
ec5f5150e2 Simplify cmap subtable format 4 idDelta code 2014-05-21 19:14:22 -04:00
Behdad Esfahbod
e7fb216ad8 Fix cmap subtable format 4 compiling
Was failing all these years, if a idDelta value happened to be
exactly -0x8000...

Test case: roundtripping MTLmr3m.ttf.
2014-05-21 19:14:03 -04:00
Behdad Esfahbod
4c777d3465 Typo 2014-05-21 17:57:14 -04:00
Behdad Esfahbod
d56eebfa96 Use .extend() syntax instead of += for sets 2014-05-14 00:22:14 -04:00
Behdad Esfahbod
470d610eb2 Further micro-optimize cmap subtable format 4 loading 2014-05-14 00:12:03 -04:00
Behdad Esfahbod
2db5eca0df Micro-optimize cmap subtable format 4 loading 2014-05-14 00:08:15 -04:00
Behdad Esfahbod
0d182bfb80 Speed up cmap format 4 loading
From quadratic to linear.  Sigh.
2014-05-14 00:00:47 -04:00
Behdad Esfahbod
da223b8fa8 Minor optimization 2014-05-09 17:05:32 -04:00
Behdad Esfahbod
0f74e80d59 Add isUnicode() and isSymbol() to cmap subtables 2014-03-12 12:17:33 -07:00
Behdad Esfahbod
1ae29591ef from __future__ import absolute_import
Such that our Python 2 is closer to Python 3.

Part of https://github.com/behdad/fonttools/issues/77
2014-01-14 15:07:50 +08:00
Behdad Esfahbod
1a4f96b787 Remove total_ordering
Upon studying further, we don't need it.  Since we only expect
comparing objects of the same type, just having __lt__ is enough.
2013-12-07 12:17:32 -05:00
Behdad Esfahbod
273a90074a Return NotImplemented 2013-12-07 03:40:44 -05:00
Behdad Esfahbod
56da965344 Add @total_ordering to classes with __lt__ 2013-12-07 03:35:16 -05:00
Behdad Esfahbod
dc87372c88 Use True/False instead of 1/0 2013-12-04 21:28:50 -05:00
Behdad Esfahbod
9e6ef94b55 Use "is None" instead of "== None"
The latter hits the __eq__ method and can fail because we now
do not allow comparing objects of different types.

For example, was failing subsetting Andika-R.ttf.
2013-12-04 16:35:10 -05:00
Behdad Esfahbod
e388db566b py23 Use new-style classes
Such that we get the same semantics in both Python 2 and 3.
2013-11-28 18:53:30 -05:00
Behdad Esfahbod
2242b26742 Fix cmap UVS encode/decode on big-endian systems
Previous code didn't make any sense.
2013-11-28 17:32:43 -05:00
Behdad Esfahbod
43e4b3d256 py23 cmap bytes fix 2013-11-28 17:32:43 -05:00
Behdad Esfahbod
5f6418d9e1 py23 Turn Unicode XML parsing on; more bytes fixes 2013-11-28 17:32:43 -05:00
Behdad Esfahbod
18316aa769 ps23 More bytes fixes. All ''join()'s fixed 2013-11-28 17:32:43 -05:00
Behdad Esfahbod
821572c9a9 py23 Add bytesjoin() 2013-11-28 17:32:43 -05:00
Behdad Esfahbod
b7fd2e1913 py23 Remove uses of __cmp__ and cmp() 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
32c10eecff py23 from __future__ import division and adjust divisions 2013-11-28 17:32:42 -05:00
Behdad Esfahbod
30e691edd0 py23 from __future__ import print_function 2013-11-27 17:27:45 -05:00
Behdad Esfahbod
7ed91eca1e py23 import in all nontrivial source files and unused import cleanup 2013-11-27 15:25:00 -05:00
Behdad Esfahbod
c2297cd41d 2to3 --fix=dict with manual cleanup 2013-11-27 14:01:45 -05:00
Behdad Esfahbod
b774f9f684 2to3 --fix=types manual additions
Don't know why the tool didn't catch these.
2013-11-27 14:01:44 -05:00
Behdad Esfahbod
3ec6a25823 2to3 --fix=print with manual fixup 2013-11-27 04:57:33 -05:00
Behdad Esfahbod
e5ca79699d 2to3 --fix=map with manual cleanup 2013-11-27 04:38:16 -05:00
Behdad Esfahbod
ac1b435946 2to3 --fix=idioms 2013-11-27 04:15:34 -05:00
Behdad Esfahbod
fa5f2e85ab 2to3 --fix=zip with manual cleanup 2013-11-27 04:13:15 -05:00
Behdad Esfahbod
28aeabb08b 2to3 --fix=filter 2013-11-27 04:07:28 -05:00