518 Commits

Author SHA1 Message Date
Behdad Esfahbod
3619126d26 Use os.linesep for line separator in xmlWriter 2015-04-15 17:41:30 -07:00
Behdad Esfahbod
034ed355de Fix bytes/unicode detection
https://github.com/behdad/fonttools/pull/233
2015-04-15 10:44:39 -07:00
Behdad Esfahbod
8b0152f0a1 Fix XMLWriter to take sinks that accept both bytes() and unicodes()
Fix xmlWriter_test with python3 as well.
2015-04-14 19:07:34 -07:00
Sascha Brawer
2ac42ad3ec Support unittests in addition to doctests
The Python libraries come with two ways of writing unittests:
module unittest, and module doctest. In some cases, unittest
is more natural (less cumbersome) than doctest.

Wrote tests on xmlWriter for illustration.
2015-04-14 17:52:17 -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
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
467a0369e4 Fix test on Python 2.6 2015-03-03 16:05:25 -08:00
Behdad Esfahbod
1296c7457e Make tests pass with Python3
In python3, str(float) is noisy.  Always format floats using "%g".
2015-03-03 15:54:37 -08: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
b056318ca9 Ignore top four bytes of head table timestamps
Warn instead.
2015-01-02 13:08:57 -08:00
Behdad Esfahbod
15f2bb1e2f Fixup previous commit 2015-01-02 13:02:36 -08:00
Behdad Esfahbod
ee425b4350 Adjust for Python 3.3 change in gmtime() exception type
https://github.com/behdad/fonttools/issues/99#issuecomment-66776810

Fixes https://github.com/behdad/fonttools/issues/99
2015-01-02 12:54:19 -08:00
Behdad Esfahbod
f0200def0c Refactor timestamp code into misc.timeTools 2015-01-02 12:53:16 -08:00
Behdad Esfahbod
d86755bd45 Really fix fixedToFloat() this time
And simplify.  Fixes regression introduced two commits ago.

Fixes https://github.com/behdad/fonttools/issues/205
2014-12-29 11:56:39 -08:00
Behdad Esfahbod
db3b2817bf Add more tests to fixedToFloat(), showing previous commit is broken
Fix coming.
2014-12-29 11:30:48 -08:00
Behdad Esfahbod
97a07ce536 Improve fixedtoFloat()
Fixes https://github.com/behdad/fonttools/issues/205
2014-12-28 23:52:46 -08:00
Behdad Esfahbod
a767e0298b Fix XML reading of True/False after safeEval() revert 2014-09-30 18:54:47 -04:00
Behdad Esfahbod
8388a2e37c Revert "Use ast.literal_eval to implement safeEval"
This reverts commit f5d123be5e342d91c2fa964ddae2844bc633d08e.

Fixes https://github.com/behdad/fonttools/issues/164
See issue for details.
2014-09-24 18:15:51 +03:00
Behdad Esfahbod
03f8ad9dd8 Allow passing encoding to XMLWriter()
We don't support non-UTF-8 encodings, but reinstate the argument
such that existing code, like robofab, continues to work.
2014-08-13 19:06:51 -04:00
Behdad Esfahbod
4af65b0f3d [py23] Minor refactoring 2014-07-21 13:19:53 -04:00
Roozbeh Pournader
365b0bfce1 Add support for dumping XMLs to the standard output. 2014-06-27 15:03:32 -04:00
Behdad Esfahbod
d897eb0486 Micro optimization 2014-06-16 20:35:12 -04:00
Behdad Esfahbod
d06ecc6b25 Use basestring instead of str 2014-06-16 20:30:17 -04:00
Behdad Esfahbod
5598d1de5a [cff] Speed up operand handling
I get ~7% speedup just avoiding a redirection.
2014-06-16 20:23:12 -04:00
Behdad Esfahbod
8d44d79ee2 Minor simplification 2014-06-16 20:23:12 -04:00
Behdad Esfahbod
e3d7d71b7a Allow setting 'raw' attrs on XML for tables to be loaded from hex
Previously one had to set the 'ERROR' attribute.  Accept raw also.
So, for example one can say:

  <cmap raw="1">
    <!-- Hand-coded format13 table mapping all Unicode
         characters to .notdef glyph. -->
    <hexdata>
      0000 0001 <!-- version numTables -->
        0000 0006 <!-- platformID encodingID -->
        0000000C  <!-- offset -->
          000D 0000 <!-- format reserved -->
          0000001C  <!-- length -->
          00000000  <!-- language -->
          00000001  <!-- nGroups -->
            00000001  <!-- startCharCode -->
            0010FFFE  <!-- endCharCode -->
            00000001  <!-- glyphID -->
    </hexdata>
  </cmap>
2014-01-31 18:06:24 -05: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
f5d123be5e Use ast.literal_eval to implement safeEval
Fixes https://github.com/behdad/fonttools/issues/75
2014-01-14 14:59:12 +08:00
Behdad Esfahbod
494d9d139e Remove eexecOp C extension
It hasn't been working:

  6102ba7500

And it's only used to load Type1 fonts, so who cares if the Python
implementation is slow...
2013-12-07 17:36:12 -05:00
Behdad Esfahbod
dc0ce0b498 py23 fixes for psLib and t1Lib
Still not working with Python 3 as psLib's PSTokenizer subclasses
StringIO and expects it to have buf and pos.  Need to rewrite
this to implement StringIO internally.
2013-12-07 12:04:23 -05:00
Behdad Esfahbod
56da965344 Add @total_ordering to classes with __lt__ 2013-12-07 03:35:16 -05:00
Behdad Esfahbod
8ea6439d3b Implement __ne__ when __eq__ is defined 2013-12-06 22:25:48 -05:00
Behdad Esfahbod
b8e1afa809 Use struct format 'Q' to read/write 64bit integers 2013-12-06 17:26:09 -05:00
Behdad Esfahbod
dc87372c88 Use True/False instead of 1/0 2013-12-04 21:28:50 -05:00
Behdad Esfahbod
78c02b6af3 Fix T1CharString decompile()
self.program is never None; it's set to [] if using bytecode.
So fixup the check.
2013-12-04 13:16:49 -05:00
Behdad Esfahbod
cc13b7889d Simplify 2013-12-04 04:12:57 -05:00
Behdad Esfahbod
94968f3151 Use pure-Python StringIO, not cStringIO
misc.psLib tries to subclass StringIO.  It doesn't work with
the cStringIO version.

Change doesn't seem to affect performance of CFF, which is the
biggest StringIO user.

7279302238 (commitcomment-4767054)
2013-12-04 04:11:06 -05:00
Khaled Hosny
8851bcfd32 Add missing dot
Since 153ec402094adbea673e914385b87f1d99191d0b.
2013-12-04 08:54:12 +02:00
Behdad Esfahbod
cc43f3a15c Fixup 2013-12-04 01:17:21 -05:00
Behdad Esfahbod
153ec40209 Fix a few pychecker warnings
Fixes https://github.com/behdad/fonttools/issues/58
2013-12-04 01:15:46 -05:00
Behdad Esfahbod
c40e26ec4c Fix stupid mishap 2013-12-04 00:20:19 -05:00
Behdad Esfahbod
f2c2b4d38b Improve composite glyph bounds calculation
Extend GlyphCoordinates to transparently support float coordinates.
As a result, transformed glyph components now don't have their
coordinates rounded anymore.  This slightly changes bounding box
calculations.

There's also code added, but disabled, to calculate exact glyph
bounding box, but we don't seem to actually want that.
2013-12-01 13:36:09 -05:00
Behdad Esfahbod
21bae0e3db py23 fixes for psOperators 2013-11-29 20:27:21 -05:00
Behdad Esfahbod
70c46de635 Revert "Remove unused fontTools.misc.psOperators"
psOperators is still used by t1Lib.  I'm not sure whether I want
to drop t1Lib just yet.

This reverts commit f3a8aeada3ba54e16b0f7e6aa90ca59358668b85.
2013-11-29 20:24:58 -05:00
Behdad Esfahbod
f918ab4cf6 Fix typos
From
4d2d8c9642
2013-11-29 17:12:43 -05:00
Behdad Esfahbod
7279302238 py23 fixes for psLib 2013-11-29 16:31:21 -05:00
Behdad Esfahbod
b49aa66e61 Revert "Remove unused fontTools.misc.psLib"
psLib is still used by t1Lib.  I'm not sure whether I want to
drop t1Lib just yet.

This reverts commit e0f84aabfaea36a5a4e1dc161b6c47c3a0bc4e1b.
2013-11-29 16:31:00 -05:00
Denis Jacquerye
af1c9968b2 from __future__ imports must be first for python 3.3.2
adding \ to break lines in fontTools/misc/transorm.py
unneeded closing parenthesis in T_S_I__1.py
2013-11-29 16:03:42 -05:00
Denis Jacquerye
db08ee2c19 missing from __future__ import print_function in setup.py
python3: sum() can't sum bytes, using b''.join(seq) instead
2013-11-29 14:15:48 -05:00