45 Commits

Author SHA1 Message Date
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Cosimo Lupo
094a40ca2e Revert "Deprecate and ignore newlinestr"
This reverts commit 5af178ac8eb2da79b965be5c6cee693dad602c65.
2021-08-03 10:00:13 +02:00
Khaled Hosny
5af178ac8e Deprecate and ignore newlinestr 2021-07-30 04:31:19 +02:00
Khaled Hosny
000bf81700 Default to "\n" for newlinestr instead of None
If newlinestr is None, os.linesep is used, bu it is the third millennium
and we don’t need or want different line endings per-platform.
2021-07-30 04:12:33 +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
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
justvanrossum
d897a08fc8 more updated issue URLs 2019-03-06 16:52:35 +01:00
Miguel Sousa
523c31dd0b Add context manager to XMLWriter
93103c08ca (r29633076)
2018-07-08 22:12:44 -07:00
Behdad Esfahbod
c99a731adb [ttc] Implement saveXML() 2018-01-25 17:50:03 -08:00
Cosimo Lupo
d874782ee4 [xmlWriter] add 'newlinestr' argument for overriding os-specific line endings
By default (newlinestr=None), the XMLWriter will still use the `os.linesep` as the
newline string.
Otherwise, it will use the specified `newlinestr`.

This is useful when TTX files under version control are being written from
multiple platforms; in which case, one usually wants to always use one
specific line ending (most likely LF, which is what the XML spec itself
normalizes it to).
2016-10-20 16:53:07 +01:00
Cosimo Lupo
5102353afb [xmlWriter] escape carriage returns '\r' using XML character entity '&13#;'
Fixes https://github.com/behdad/fonttools/issues/318
2015-07-27 12:58:02 +01:00
mashabow
57e7a6b7a7 [cffLib] Fix encoding of Notice and Copyright values in XML on Python 2 2015-07-03 22:33:17 +09:00
Behdad Esfahbod
b30e12ae00 More whitespace 2015-04-26 02:01:01 -04:00
Behdad Esfahbod
d73e707317 Always write encoding as "UTF-8" in XML output
Fixes https://github.com/behdad/fonttools/issues/246
2015-04-21 11:07:48 -07:00
Behdad Esfahbod
aa74114f1d Use cannonical encoding ids 2015-04-20 18:21:46 -07:00
Behdad Esfahbod
5580c60b64 Fix build 2015-04-20 18:20:04 -07:00
Behdad Esfahbod
00c89aa9cf Preserve case and other detail of XML encoding passed in
Part of fixing https://github.com/behdad/fonttools/issues/246

Or, should I alsways write "UTF-8" for the sake of consistency?
I think I actually like doing that.
2015-04-20 18:04:47 -07:00
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
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
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
Roozbeh Pournader
365b0bfce1 Add support for dumping XMLs to the standard output. 2014-06-27 15:03:32 -04: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
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
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
c076261598 s/latin-1/latin1/g 2013-11-28 17:32:44 -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
18316aa769 ps23 More bytes fixes. All ''join()'s fixed 2013-11-28 17:32:43 -05:00
Behdad Esfahbod
5cf4008336 py23 tostr()/tobytes() and using them
ttf->xml seems to be mostly working now.
2013-11-28 17:32:43 -05:00
Behdad Esfahbod
319c5fd10e py23 introduce byteord() and use it 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
b7a2d797a4 py23 Use bytechr() instead of chr() 2013-11-27 15:25:00 -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
14fb031125 Remove most uses of module string 2013-11-27 14:01:44 -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
dc7e6f3e55 2to3 --fix=repr 2013-11-27 02:44:56 -05:00
Behdad Esfahbod
66214cbe8c 2to3 --fix=apply 2013-11-27 02:18:18 -05:00
Behdad Esfahbod
f65033e277 Move xmlWriter into fontTools.misc
Trying to cleanup our footprint in the Python namespace.
2013-09-17 16:41:32 -04:00