445 Commits

Author SHA1 Message Date
Cosimo Lupo
141cc7b6c2 [loggingTools] typo 2016-01-29 17:28:53 +00:00
Cosimo Lupo
3664462a63 [loggingTools] use ellipsis for elapsed time in doctestes to fix AppVeyor build
https://ci.appveyor.com/project/anthrotype/fonttools/build/1.0.53/job/2p08d9sbcfelvwx6
2016-01-27 19:05:05 +00:00
Cosimo Lupo
e8edfad59a [loggingTools] on Windows, warnings.warn doesn't like category=None, set it to UserWarning (which is the default) 2016-01-27 19:05:05 +00:00
Cosimo Lupo
b6145de7cb [psLib] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
e4f0f3ec30 [psCharStrings] replace print with logger 2016-01-27 19:02:48 +00:00
Cosimo Lupo
de5dca010b [xmlReader] replace print with logger; deprecate 'quiet' argument 2016-01-27 19:01:12 +00:00
Cosimo Lupo
317d653125 [loggingTools] module containing tools for adapting the Python logging package to fontTools (and viceversa) 2016-01-27 19:01:12 +00:00
Cosimo Lupo
b63935c6f8 [py23_test] test py23.open for piping binary data through stdin/stdout 2016-01-25 18:25:07 +00:00
Cosimo Lupo
47bde21b86 [py23] add wrapper around io.open bridging py23 differences 2016-01-25 17:52:45 +00:00
Sascha Brawer
0f8882bcc3 [otlLib] Move creation of ValueRecords from feaLib to otlLib 2016-01-14 16:27:04 +01:00
Cosimo Lupo
a54a794f81 timeTools: define platform-independent 'asctime' function
Fixes https://github.com/behdad/fonttools/issues/455
2016-01-12 12:33:22 +00:00
Cosimo Lupo
e4ab85e90a macRes: fix OverflowError while reading resource on 32-bit Python
Fixes https://github.com/behdad/fonttools/issues/436
2015-12-15 11:01:26 +00:00
Cosimo Lupo
8933062db0 xmlReader: make xmlReader accept file objects
Fixes https://github.com/behdad/fonttools/issues/404

Also, fixed typo for ProgressPrinter method call: 'setlabel' -> 'setLabel'
2015-12-07 19:31:33 +00:00
Cosimo Lupo
5cf297ca44 xmlReader_test: test ProgressPrinter and reading from path vs file object 2015-12-07 19:26:04 +00:00
Cosimo Lupo
2eda1785f6 [py23] fix ImportError when trying to import unichr, basestring or unicode when already defined
When one does `from fontTools.misc.py23 import *`, everything seems to work fine.

However, linters will complain when one uses the asterisk to import all names from a module, since they can't detect when names are left undefined -- asterisks are greedy and will eat all names.

If one avoids the asterik and attempts to import explicitly, like in `from fontTools.misc.py23 import basestring`, the problem then is that, if `py23` does not re-define the name -- e.g. under python2 `basestring` or `unicode` are built-ins -- then the import statement raises `ImportError`.

The same happens for the `unichr` function on a "wide" Python 2 build (in which `sys.maxunicode == 0x10FFFF`).

Now, to work around this, we need to re-assign those built-ins to their very same names. This may look silly, but at least it works.
2015-11-23 12:02:12 +00:00
Cosimo Lupo
f10cb1f17d [macCreatorType] fix KeyError raised by old version of xattr module
in version 0.6.4 (installed on OS X 10.10 python lib/extras) it raises
KeyError, whereas in the latest version available fom PyPI (v0.7.8) it
raises IOError.

Fixes issue in https://github.com/googlei18n/nototools/issues/113
2015-11-11 00:01:50 +00:00
Cosimo Lupo
f8e8ea6e7f [macRes] use tostr(s, encoding='mac-roman') for resource types and names 2015-10-26 14:38:20 +00:00
Cosimo Lupo
2f212ac59a [macRes] add default value [] to self.get(resType)
ops!
2015-10-26 05:16:22 +00:00
Cosimo Lupo
17e757300c [macRes_test] add tests for ResourceReader 2015-10-26 04:40:00 +00:00
Cosimo Lupo
db70dee031 [macRes] new module and ResourceReader to read Mac resource/data forks
inspired by Sascha Brawer's GNU Classpath Java implementation

https://gcc.gnu.org/viewvc/gcc/trunk/libjava/classpath/gnu/java/awt/font/opentype/MacResourceFork.java?view=co&content-type=text%2Fplain
2015-10-26 04:40:00 +00:00
Cosimo Lupo
363893d1fc [macCreatorType] try to use xattr module if installed
xattr is a Python wrapper for extended filesystem attributes, which works
with both Python 2 and 3: https://pypi.python.org/pypi/xattr
2015-10-26 03:49:31 +00:00
Cosimo Lupo
8891e98920 remove MacOS-only misc/homeResFile.py module (no longer used) 2015-10-26 03:34:03 +00:00
Cosimo Lupo
d0b6bdafa0 [psLib] make PSTokenizer indipendent StringIO-like object; fix issues with python3 (bytes vs unicode)
PSTokenizer is now an indipendent object behaving like a StringIO.StringIO: it has `read` and `close` methods, as well as `buf`, `pos` and `len` attributes.

The input data is a string of bytes, and the output tokens are ascii-decoded unicode strings.

(I removed "__main__" as it was using a non-py23 EasyDialogs module)

See https://github.com/behdad/fonttools/issues/393.

Related to https://github.com/behdad/fonttools/issues/391.
2015-10-22 19:55:33 +01:00
Cosimo Lupo
1c2fe9c37c [eexec] use bytes instead of str; add doctests to encrypt and decrypt functions 2015-10-22 19:54:53 +01:00
Cosimo Lupo
565d36c511 [psLib] revert to StringIO.StringIO; temporarily drop support for py3
Reverts commit bf0e336d316518115a7b47da4f721bb8a009b3e1
Fixes https://github.com/behdad/fonttools/issues/391

...though only temporarily.
2015-10-21 13:14:48 +01:00
Sascha Brawer
582852119c Implement OTTableReader.readUShortArray()
There is currently only one single call site in the codebase,
but this function will be needed a lot for parsing `morx` and
other AAT tables.
2015-10-17 06:47:52 +02:00
Cosimo Lupo
cb36478d4b [testTools] add getXML function to get the XMLWriter content as string 2015-09-30 20:19:35 +01:00
Sascha Brawer
d63885e337 [otTables] Use XML snippets for testing fromXML() methods
This should make the unit tests more readable, and it also prevents
failures where a changed fromXML() implementation fails to ignore
interspersed whitespace. This has recently caused some developer
nuisance; see https://github.com/behdad/fonttools/pull/367.

Instead of having a custom parser implementation, it would be nicer
to call the actual XMLReader. However, XMLReader has a deeply built-in
assumption that it is processing an entire TTX file. Changing this
assumption would certainly be possible, but it would need a re-write
of the XMLReader code; having a custom parser just for unit tests
seems less involved.
2015-09-11 15:44:29 +02:00
Cosimo Lupo
895c54cf92 [textTools] reduce usage of str concat in pad function 2015-09-09 09:52:31 +01:00
Behdad Esfahbod
9aed8e1e9d Merge pull request #270 from anthrotype/woff2_14
implement WOFF2 encoder/decoder as standalone module
2015-08-19 15:33:44 +01: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
98e47a8746 [textTools] add 'pad' function to pad strings with null bytes 2015-08-07 18:23:41 +01:00
Cosimo Lupo
bf0e336d31 replace all 'StringIO' with 'BytesIO' 2015-08-07 17:25:22 +01:00
Cosimo Lupo
2e058808fe [py23] define BytesIO, StringIO and 'UnicodeIO' to disambiguate bytes vs unicode in-memory streams 2015-08-07 17:24:42 +01:00
Cosimo Lupo
9f846d3687 [xmlReader_test] test newlines gets normalised by expat parser, unless escaped 2015-07-27 19:24:02 +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
Cosimo Lupo
fcd31fdf19 [xmlWriter_test] test carriage returns '\r' are escaped with '
' 2015-07-27 12:58:02 +01:00
Cosimo Lupo
13d7d38259 [xmlReader_test] test that xmlReader correctly decodes UTF-8 bytes 2015-07-26 15:34:58 +01:00
Cosimo Lupo
edeb2c6c98 [xmlReader] open file for reading bytes 2015-07-24 16:59:07 +01:00
Cosimo Lupo
76c05ae052 Revert "[xmlReader] always open files using UTF-8 encoding"
This reverts commit 6b4567fcde138b069b1323d3127c103d007592cd.
2015-07-24 16:59:06 +01:00
Cosimo Lupo
fbdab03a1d Revert "[xmlReader] make expat parser use UTF-8"
This reverts commit fe76598a80b16ed078606090470f491e4aadb660.
2015-07-24 16:59:06 +01:00
Cosimo Lupo
d7d59c527d [fixedTools] make sure fixedToFloat function returns float on both python 2 and 3 2015-07-24 16:48:07 +01:00
Cosimo Lupo
fe76598a80 [xmlReader] make expat parser use UTF-8 2015-07-23 17:03:31 +01:00
Cosimo Lupo
6b4567fcde [xmlReader] always open files using UTF-8 encoding
If no "encoding" argument is provided to Python3 `open`, the default plaftorm's encoding (cp1252 on Windows) is used when decoding bytes to unicode strings.
So, we use the `io.open` function (i.e. a backport of Python3 default file interface) with `encoding="utf_8"` argument.

Fixes https://github.com/behdad/fonttools/issues/323
2015-07-23 16:36:48 +01:00
Cosimo Lupo
a54b98f445 add test for stringifyattrs method 2015-07-03 18:20:41 +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
Cosimo Lupo
679fe8965f [encodingTools] fix typo 2015-06-16 22:44:57 +01:00
Cosimo Lupo
262f0e9017 [timeTools] add timestampSinceEpoch function 2015-06-16 22:44:57 +01:00
Behdad Esfahbod
37e6e6a380 Use dict comprehension now that we don't support Python 2.6 2015-06-11 17:05:15 -07:00
Cosimo Lupo
b1bd77f9f6 fix xmlWriter and _l_t_a_g tests failing on Windows because of \r\n 2015-06-10 10:17:05 +01:00