Cosimo Lupo
a0a400d9c1
[name] add setName method to table__n_a_m_e
...
If the referenced name record already exists, the string is modified in place.
If it doesn't exist, a new record is created with the given IDs and string.
2015-10-01 10:11:48 +01:00
Behdad Esfahbod
ee3b5c0b6f
Speed up name.getDebugName()
...
Avoid decoding all strings, and break early if found English.
2015-06-24 15:30:06 -07:00
Sascha Brawer
29328f20e5
Helper function to find a debug string for a name
...
Useful for generating XML comments when tables refer to name IDs.
For example, XML for a named instance in an ‘fvar’ table is easier
to read when it says <!-- Bold --> in addition to nameID="258".
2015-06-24 09:08:19 +02:00
Behdad Esfahbod
c8579bb7a7
Revert "Handle broken Python codecs system"
...
This reverts commit a430174b0a21068f64739642ce2dae136ff22478.
Err. CodecRegistryError is not defined on CPython, etc.
Finding another fix...
2015-05-06 12:06:24 -07:00
Behdad Esfahbod
a430174b0a
Handle broken Python codecs system
...
As seen on some Jython situations where this was raised:
encodings.CodecRegistryError: incompatible codecs in module "encodings.utf_16_be" (__pyclasspath__/encodings/utf_16_be.py)
2015-05-06 11:49:41 -07: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
cc072eca9f
Use utf_16_be instead of utf_16be
...
That's the canonical name.
https://github.com/behdad/fonttools/issues/236
2015-04-24 12:48:37 -07:00
Behdad Esfahbod
2df891f25c
Handle double-encoded UTF-16BE
...
Merge the logic with the marked-Mac-but-UTF-16BE logic.
Fixes https://github.com/behdad/fonttools/issues/249
2015-04-22 02:22:11 -07:00
Behdad Esfahbod
c4fb6459b0
Handle Mac-marked actual-UTF-16BE ASCII-only name
...
This seems to take care of quite a few of misencoded files I've found.
2015-04-22 02:15:51 -07:00
Behdad Esfahbod
2d443eeac2
Tighten check for ASCII in previous commit
2015-04-22 01:59:50 -07:00
Behdad Esfahbod
7e4092aba8
Implement heuristics for decoding odd-length UTF-16BE data in name table
...
Part of https://github.com/behdad/fonttools/issues/249
2015-04-22 01:55:43 -07:00
Behdad Esfahbod
abf7dc6568
If Unicode-compatible name failed to decode, write unicode="False"
2015-04-22 01:16:34 -07:00
Behdad Esfahbod
702b94f00a
Use canonical Python encoding names
2015-04-19 04:24: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
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
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
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
77ccf45eb0
Add NameRecord.isUnicode()
2014-03-12 12:32:27 -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
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
1edfe57656
Strip name table records before writing to XML
...
They will be stripped reading back anyone, so any surrounding
whitespace will be lost. At least this way diffs of ttx files
are cleaner.
2013-11-28 18:53:30 -05:00
Behdad Esfahbod
ca80208a15
Revert XML name table format changes
...
For the sake of separating py23 effort from feature changes,
I'm reverting the name table XML dump format back to what it
was. I will clean it up after py23 is merged.
2013-11-28 17:33:23 -05:00
Behdad Esfahbod
6962f0cfb2
py23 XML encoding fixes
...
Name table entries that are Unicode are written out as native Unicode
now text in the XML now.
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
9005774c10
2to3 --fix=unicode equivalents
...
Remove usage of unicode module. The rest are mostly false
positives.
Remains u'' in macUtils.py and u"" and unichr in M_E_T_A_.py.
2013-11-27 14:01:45 -05:00
Behdad Esfahbod
14fb031125
Remove most uses of module string
2013-11-27 14:01:44 -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
ac1b435946
2to3 --fix=idioms
2013-11-27 04:15:34 -05:00
Behdad Esfahbod
3a9fd30180
2to3 equivalent to --fix=tuple_params
...
I hope I got this all right...
2013-11-27 03:30:21 -05:00
Behdad Esfahbod
180ace6a5f
2to3 --fix=ne
2013-11-27 02:40:30 -05:00