74 Commits

Author SHA1 Message Date
Masaya Nakamura
a68bfc2458 [psCharStrings] Add recalcBounds() to T2CharString 2017-08-01 10:51:47 +09:00
Cosimo Lupo
72baa5a7d5 [cffLib/psCharStrings] remove cffCtx, pass down isCFF2
* Removed `CFFContext`
* Added `isCFF2` argument to CFFFontSet.decompile/compile, used from
  respective ttLib classes
* Index classes get a `isCFF2` argument in constructor (used for
  decompiling); must be True/False if `file` argument is not None;
  it is stored as self._isCFF2 to support lazy loading
* Removed `TopDictData` class; reuse same `TopDictIndexCompiler` for
  both CFF and CFF2
* `CFFWriter` and all `*Compiler` classes get an `isCFF2` argument;
  defaults to the parent compiler's `isCFF2` attribute
* Removed `size` argument from `produceItem` method as unused and
  useless (`len(data)` is the same)
* psCharStrings: removed useless ByteCodeBase class
* A reference to the TopDict's VarStoreData is passed down to all
  the FontDicts' PrivateDict, so it can be used to get the number of
  regions while decompiling blend and vsindex operators

See dicussion:
https://github.com/fonttools/fonttools/pull/968#issuecomment-309920007
2017-07-19 18:18:58 +01:00
Miguel Sousa
dbf78fe930 [psCharStrings] Fix assert 2017-07-12 22:50:06 -07:00
ReadRoberts
386f16a233 Fix formatting for init function. 2017-06-20 16:23:52 -07:00
ReadRoberts
38cde93a1c psCharStrings.py. Fix bug: allow T1 charstrings to not have private attribute. 2017-06-20 16:23:52 -07:00
ReadRoberts
7acfe1f6a8 Fix bug in changing class API’s while doing work to remove global state. Needed to make ‘private’ argument to SimpleT2Decompiler __init__() be optional. It is not needed by CFF decompilation. 2017-06-20 16:23:52 -07:00
ReadRoberts
af23a781e4 Removed global state from cffLib.py; introduced instance-specific context class instead. Also deprecated maxstack operator, per OpenType spec update 1.8.1, as this simplified some of the context passing logic. Still not thoroughly tested; convertCFFToCFF2() function has not yet been updated to work with new logic. 2017-06-20 16:23:52 -07:00
ReadRoberts
1c53437e39 Folded CFF2 classes into CFF classes. Removed:
TopDict2Decompiler
PrivateDict2Decompiler
PrivateDict2Compiler
Working towards using one set of classes for both CFF2 and CFF data.
2017-06-20 16:23:52 -07:00
ReadRoberts
c33ae5c96a Folded CFF2 classes into CFF classes. Removed:
SimpleCFF2DEcompiler
CFF2CharString
GlobalSubrsIndex2
SubrsIndex2
CharstringIndex2
Working towards using one set of classes for both CFF2 and CFF data.
2017-06-20 16:23:52 -07:00
ReadRoberts
5fb2688567 psCharstring.py. Added CFF2 specific operators to t2Operators list, removed cff2Operators list. Working towards using one set of classes for both CFF2 and CFF data. 2017-06-20 16:23:52 -07:00
ReadRoberts
88e72e2c56 psCharstrings.py. Fold CFF2CharString() logic into T2Charstring(). Working towards using one set of classes for both CFF2 and CFF data. 2017-06-20 16:23:52 -07:00
Miguel Sousa
5e115c1d2a [CFF2] Report the correct number of regions in the font
This change also makes the processing of the blend operator to be as described at https://www.microsoft.com/typography/otspec/cff2charstr.htm#section4.5
2017-03-23 17:12:31 -07:00
Miguel Sousa
bba1d9f225 [CFF2] Support ‘maxstack’ 2017-03-13 00:02:13 -07:00
Miguel Sousa
64d5119642 whitespace 2017-03-09 21:30:28 -08:00
Cosimo Lupo
33b42f47b6
[cffLib/psCharStrings] fix IndexError with empty deltas
After 2b2aca1, DictCompiler/Decompiler's `arg_delta` method unconditionally attempts to get the first item to check if it's a list, but this fails with `IndexError` when the value is empty.

```
Traceback (most recent call last):
  [...]
  File "/Users/cosimolupo/Documents/Github/ufo2ft/Lib/ufo2ft/otfPostProcessor.py", line 15, in __init__
    otf.save(stream)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/ttLib/__init__.py", line 219, in save
    self._writeTable(tag, writer, done)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/ttLib/__init__.py", line 658, in _writeTable
    tabledata = self.getTableData(tag)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/ttLib/__init__.py", line 669, in getTableData
    return self.tables[tag].compile(self)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/ttLib/tables/C_F_F_.py", line 20, in compile
    self.cff.compile(f, otFont)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/cffLib.py", line 124, in compile
    writer.toFile(file)
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/cffLib.py", line 300, in toFile
    endPos = pos + item.getDataLength()
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/cffLib.py", line 1858, in getDataLength
    return len(self.compile("getDataLength"))
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/cffLib.py", line 1879, in compile
    data.append(arghandler(value))
  File "/Users/cosimolupo/Documents/Github/fonttools/Lib/fontTools/cffLib.py", line 1910, in arg_delta
    val0 = value[0]
IndexError: list index out of range
``
2017-03-09 14:21:38 +00:00
ReadRoberts
2b2aca1290
Add CFF2 support. 2017-03-05 22:53:04 +00:00
Cosimo Lupo
f1673e46dd
[psCharStings] remove unused T2OutlineExtractor.hints attribute 2017-02-15 11:10:34 -08:00
Cosimo Lupo
3bb50b9b7f
[psCharStrings] split width-extracting part of T2OutlineExtractor into T2WidthExtractor
We shall reuse it as base class for the _DehintingT2Decompiler in subset module,
as we need to save the width in order to re-insert it after dropping the hints.
2017-01-26 11:55:13 +00:00
Cosimo Lupo
bfe330e0a6 [psCharStrings] use fixedToFloat to use the shortest decimal reprentation
Fixes https://github.com/behdad/fonttools/issues/492
2016-02-01 10:52:33 +00:00
Cosimo Lupo
e4f0f3ec30 [psCharStrings] replace print with logger 2016-01-27 19:02:48 +00:00
Miguel Sousa
a7aef47695 fix "indentation contains mixed spaces and tabs" errors reported by Landscape 2015-08-09 00:33:50 -07:00
Behdad Esfahbod
37e6e6a380 Use dict comprehension now that we don't support Python 2.6 2015-06-11 17:05:15 -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
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
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
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
153ec40209 Fix a few pychecker warnings
Fixes https://github.com/behdad/fonttools/issues/58
2013-12-04 01:15:46 -05:00
Behdad Esfahbod
f918ab4cf6 Fix typos
From
4d2d8c9642
2013-11-29 17:12:43 -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
278c88c0af py23 Fix psCharStrings bytes issues 2013-11-28 17:32:44 -05:00
Behdad Esfahbod
18316aa769 ps23 More bytes fixes. All ''join()'s fixed 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
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
002c32fd0d 2to3 --fix=types with manual fixups 2013-11-27 04:48:20 -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
3a9fd30180 2to3 equivalent to --fix=tuple_params
I hope I got this all right...
2013-11-27 03:30:21 -05:00
Behdad Esfahbod
cd5aad92f2 2to3 --fix=raise 2013-11-27 02:42:28 -05:00
Behdad Esfahbod
846d09e380 Allow None for globalSubrs in T2CharString 2013-11-18 14:11:30 -05:00
Behdad Esfahbod
f09f1d4064 Raise exceptions on unimplemented T2CharString operators 2013-08-19 14:16:07 -04:00