834 Commits

Author SHA1 Message Date
Behdad Esfahbod
5a18fc83e6 Add getEncoding() to cmap subtables 2015-04-19 03:50:55 -07:00
Behdad Esfahbod
e561b758c1 Move getEncoding into fontTools.misc.encodingTools
Logic developed as part of:
https://github.com/behdad/fonttools/pull/208
2015-04-19 03:36:20 -07:00
Behdad Esfahbod
6e01a6e350 Add Roman Croatian and Romanian encodings
Concludes https://github.com/behdad/fonttools/issues/236
2015-04-16 18:24:07 -07:00
Behdad Esfahbod
ba0a3b9abb Revamp name table Unicode handling some more
Part of https://github.com/behdad/fonttools/issues/236

Now we fallback to ASCII for unknown encodings.  Not sure if this might be a bad idea.
The main user-visible difference is that if there's an ASCII-only text in an unknown
encoding, we still "decode" it and use unicode="True" instead of unicode="False".

Or is assuming that any unsupported encoding is ASCII-compatible too intrusive?
2015-04-16 17:09:49 -07:00
Sascha Brawer
b82b50cbfb Raise UnicodeDecodeError for structurally invalid names
This will make it impossible to process fonts with super-broken
name tables. But we do not handle arbitrary broken fonts anyway,
so this is arguably better than silently ignoring junk content.
Resolves a review comment in #235.

In the unit test, replace calls of deprecated unittest.assertEquals()
by calls of unittest.assertEqual().
2015-04-16 16:32:30 -07:00
Behdad Esfahbod
4ba27843a9 Fix drawing of glyf's after numpy removal!
Should really start adding tests for these...

Fixes https://github.com/behdad/fonttools/issues/238
2015-04-16 03:26:06 -07:00
Behdad Esfahbod
eed0439c8b Adjust name table to understand extended Mac East Asian encodings
Part of https://github.com/behdad/fonttools/issues/236
2015-04-16 03:18:20 -07:00
Behdad Esfahbod
a2d063c840 Implement mac-platform roman-encoding language-specific name table encodings
Part of https://github.com/behdad/fonttools/issues/236
2015-04-16 01:17:06 -07:00
Behdad Esfahbod
a310df0848 Implement more legacy Mac name table encodings
Based on https://github.com/behdad/fonttools/issues/236
2015-04-15 23:44:07 -07:00
Sascha Brawer
af944354d2 Emit XML even for names whose platform encoding is unsupported
When dumping the Macintosh Skia font to XML, the TTX tool crashed
with a Python exception. After this change, the font can be dumped
fine. This was caused by a name record with platformID=1 (Macintosh)
and platEncID=2 (Traditional Chinese).
2015-04-15 23:01:00 -07:00
Sascha Brawer
012049d7fb Add unit tests for ltag table
Resolves #226 and #227.
2015-04-15 10:56:28 -07:00
Sascha Brawer
dc8a66956a Support 'ltag' table for IETF BCP-47 language tags
Resolves #226
2015-04-14 17:50:42 -07:00
Behdad Esfahbod
7c9ab300c2 Add standard imports to all python sources
Previously, the trivial files didn't have them.
2015-04-14 17:26:59 -07:00
Behdad Esfahbod
9db2ace931 Fix ttProgram test for Python3 2015-04-14 13:25:19 -07:00
Behdad Esfahbod
2702a5b879 Hook up ttProgram tests to doctest 2015-04-14 11:51:03 -07:00
Behdad Esfahbod
5cd4e51450 Update MetaTools/buildTableList.py for recent changes 2015-04-14 00:17:52 -07:00
sansplomb
a18416076c sorted vTables 2015-04-10 16:31:41 +02:00
Behdad Esfahbod
64a5103a77 Merge pull request #212 from vitalyvolkov/master
Handle the exception of IndexError when list item access is out of range
2015-04-08 14:33:23 -07:00
Behdad Esfahbod
c0e7bb859f Add test to make sure supported table entries are added to git
Catches the vase where support for a table is added, but the .py
file is not added to git (like happened for feat and fvar tables).
2015-04-07 18:27:23 -07:00
Behdad Esfahbod
2aac2f0eeb Actually add the fvar table. Ouch! 2015-04-07 18:02:04 -07:00
Behdad Esfahbod
81750849fc Allow setting name entries to Unicode strings
Just convert to bytes if needed when compiling table.
2015-04-07 17:58:11 -07:00
Behdad Esfahbod
e3f531783a Don't modify name table object when compiling 2015-04-07 17:56:51 -07:00
Behdad Esfahbod
4458f363e3 [ttx] Write out name table entries as Unicode when possible
https://github.com/behdad/fonttools/issues/54

There's a new attribute named unicode that can choose whether the
text in the XML entry is to be interpretted as Unicode, or as the
target encoding.
2015-04-07 17:52:51 -07:00
Behdad Esfahbod
98aee5f11a Add getEncoding() to name table entries 2015-04-03 10:07:57 -07:00
Cosimo Lupo
4c4c65fac0 [sfnt] fix WOFF checksum adjustment calculation
Use 'origLength' and 'origChecksum', instead of 'length' and
'checksum', to calculate the checksum adjustment of WOFF.
2015-04-01 10:25:06 +01:00
Behdad Esfahbod
0bf67b50bd [glyf] Implement optimal glyph outline packing; disabled by default
Dynamic-Programming-based algorithm.  Previously we had a greedy
algorithm only.

Unfortunately the savings are truly negligible.  In the order of ~20
bytes for each of the Roboto faces, less so for Noto fonts.  Even on
a 20MB font, it produced less than 100 bytes saving compared to our
greedy packing.  Either I made a huge mistake, or this is so not worth
it.  Anyway, the code is there, but disabled.
2015-03-30 16:47:49 -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
cd1bc34f89 Simplify glyf packing a bit more 2015-03-30 16:47:48 -07:00
Behdad Esfahbod
c72058623b Minor 2015-03-30 16:47:48 -07:00
Behdad Esfahbod
630284e31a Minor 2015-03-30 16:47:48 -07:00
Behdad Esfahbod
0679a7691d Move glyf coordinate delta packing into new function 2015-03-30 16:47:47 -07:00
Behdad Esfahbod
a40b20d0e0 Minor shuffling of glyf compression code 2015-03-30 16:47:47 -07:00
Behdad Esfahbod
a9632a376b Merge pull request #219 from anthrotype/bytesjoin
[_n_a_m_e] fix "can't concat bytes to str" error in python 3
2015-03-20 12:42:53 -07:00
Cosimo Lupo
743e990b5c [_n_a_m_e] fix "can't concat bytes to str" error in py3 2015-03-19 18:11:19 +00:00
Behdad Esfahbod
c511745b2e Work around a Jython bug:
>>> import array; array.array("f", array.array("b", [1,2,3]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only extend with array of same kind

>>> import array; array.array("f", list(array.array("b", [1,2,3])))
array('f', [1.0, 2.0, 3.0])
2015-03-17 15:32:57 -07:00
Behdad Esfahbod
b9ac90a8f9 [GX] Add 'fvar' table support
I might change the table format in the future, but it's functional now.
2015-03-11 15:29:35 -07:00
Behdad Esfahbod
61cda14c1b Actually add _f_e_a_t.py
Ouch!
2015-03-11 12:31:44 -07:00
Behdad Esfahbod
e02b9ea05b Fix tests to return failures 2015-03-03 10:47:40 -08:00
Behdad Esfahbod
f192400039 Fix checks; add run-tests.sh 2015-03-03 09:57:41 -08:00
Behdad Esfahbod
612c70dada [SVG] Support gzip-compressed SVG tables
Set font['SVG '].compressed=True to enable.  Here's a snippet to convert a
WOFF-compressed SVG+OpenType font to a compressed SVG+OpenType non-WOFF font:

from fontTools.ttLib import TTFont
font = TTFont("NotoColorEmojiSvg.woff")
font['SVG '].compressed=True
font.flavor=None
font.save("NotoColorEmojiSvgCompressed.ttf")
2015-03-02 15:41:57 -08:00
Behdad Esfahbod
b1f46be65c Minor 2015-03-02 15:22:39 -08:00
Behdad Esfahbod
9fc8ac0559 Whitespace 2015-03-02 13:05:29 -08:00
Behdad Esfahbod
5a7ec608c8 Fix SVG doc length calculations
Patch from Doug Felt.
2015-02-23 14:03:06 -08:00
vitalyvolkov
3042fcf989 Handle exception IndexError when accessing out of range glyphs 2015-02-02 13:47:55 +02:00
Behdad Esfahbod
8af5c69ea0 Unbreak backward compatibility re _h_e_a_d.mac_epoch_diff
Fixes https://github.com/behdad/fonttools/issues/210
2015-01-22 11:21:43 -08: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
0d5d12e02a Adjust 'feat' table format
As discussed here:
730bedd3d1
2015-01-21 15:46:30 -08:00
Behdad Esfahbod
4362cb49f3 In getGlyphSet(), pull glyph advance from hmtx even for CFF fonts
That's the right thing to do.

Also fixes this:
https://github.com/robofab-developers/robofab/issues/28
2015-01-08 12:53:58 -08:00
Behdad Esfahbod
8ef5adc4af Move draw() implementation to a better place 2015-01-08 12:28:42 -08:00
schriftgestalt
adfe7f293a add some missing return values 2015-01-08 09:46:13 -08:00