304 Commits

Author SHA1 Message Date
Cosimo Lupo
bcd4268442
subset/testdata: add a version of TestTTF-Regular.ttx containing an additional non-BMP character, U+1F6D2 2016-11-29 15:42:51 +00:00
Behdad Esfahbod
78d3cbea57 [subset] Fix subsetting MathVariants
Was failing on Caudex-Regular.ttf for example.
2016-11-11 10:58:02 -08:00
moyogo
4dd1e73b04 Revert "Merge pull request #606 from anthrotype/cff-dehint"
This reverts commit 25a03f5a5736ed70791a8dde31605ed4cee9bbd9, reversing
changes made to 8351600bc628278960390d747f45593a50b7c1ea.
2016-10-14 20:20:35 +01:00
Cosimo Lupo
25a03f5a57 Merge pull request #606 from anthrotype/cff-dehint
subset: must 'draw' charstrings to set 'width' attribute before calling 'drop_hints'
2016-10-14 18:43:15 +01:00
Behdad Esfahbod
72f5cb8579 Fixup 2016-10-13 15:59:25 -07:00
Behdad Esfahbod
4158b54244 Make subset module callable 2016-10-13 15:42:14 -07:00
Cosimo Lupo
718201471a {subset,builder}_test: fix order of fromfile/tofile in expect_ttx
The order of the arguments for difflib.unified_diff was inverted in feaLib.builder_test.
The same snippet was probably copy-pasted to the subset_test.

See https://docs.python.org/3/library/difflib.html#difflib.unified_diff
2016-10-09 11:54:48 +01:00
Cosimo Lupo
5d43936d85 subset_test: add basic unit tests for --no-hinting (CFF and TTF) and --desubroutinize options (CFF only) 2016-10-09 11:37:52 +01:00
Cosimo Lupo
942e656b3c subset_test: remove unused variable 2016-10-09 11:22:21 +01:00
Cosimo Lupo
ddfa48ea7c subset: 'draw' charstrings to set 'width' before calling 'drop_hints'
the horizontal advance of hinted charstrings gets lost when the CFF hinting
is stripped with '--no-hinting' option, as noted by @miguelsousa here:

https://github.com/behdad/fonttools/issues/343#issuecomment-156234918

The reason is T2CharString objects only get assigned a 'witdh' attribute
after their 'draw' method is called.

The subsetter's 'drop_hints' function attempts to insert the width back
at the beginning of the de-hinted charstring's program, but can do that
only if the charstring does have a 'width' attribute:

https://github.com/behdad/fonttools/blob/master/Lib/fontTools/subset/__init__.py#L1908
2016-10-09 10:59:10 +01:00
Cosimo Lupo
ab395ff0e2 move CapturingLogHandler class from subset to loggingTools module 2016-10-04 14:31:30 +01:00
ReadRoberts
5b479716bc Fix bugs in cffLib.py. 1) In the last commit, I added logic to use a CFF predefined charset when possible. This is not allowed In CID fonts. Added a test to NOT do this when font is CD. 2) Added exception handler when reading FontDict XML to skip unknown fields. In previous versions, all the default key/value pairs for the TopDict were (incorrectly) written to FDArray FontDicts. New logic does not do that, but also should not fail when it sees any of these key/value pairs. 3) Changed the expected txt files for some of the subset tests. For the CID example, this meant removing the unnecessary key/value pairs from the FDArray FontDicts. For all, it meant adding the major.minor CFF version fields. 2016-09-27 19:49:41 +02:00
Behdad Esfahbod
402d726692 [ot] Change Version to be an integer instead of float
API Change:
This will change XML output for GSUB/GPOS/GDEF/MATH/BASE/JSTF/...
Scripts that set the Version for those to 1.0 or other float values
also need fixing.  A warning is emitted when code or XML needs fix.
2016-09-27 19:49:41 +02:00
Behdad Esfahbod
a30b6250cb . 2016-09-27 19:49:41 +02:00
Behdad Esfahbod
ae93928275 [varLib] Rename fields in fvar, to accommodate for postscriptNameID 2016-09-27 19:49:41 +02:00
Cosimo Lupo
4ae7bba184 [subset_test] add tests for --passthrough-tables option 2016-09-26 19:13:56 +01:00
Cosimo Lupo
9de25ea628 [subset] add --passthrough-tables option to keep any tables that the subsetter does not know how to subset 2016-09-26 19:13:04 +01:00
JasonAtGithub
a41c60cb88 Fixed encoding error in subset tool in Windows
Fixed encoding error in subset tool in Windows which system default codepage isn't 65001.
For Example: 
When windows default codepage is 936, the command like 'pyftsubset myfont.ttf --text-file=mytextfile.txt' will throw an exception.
2016-08-29 20:43:33 +08:00
Cosimo Lupo
539a5010e5 subset: --recalc-average-width is disabled by default 2016-07-20 09:33:35 +01:00
Cosimo Lupo
d1a27bd671 subset: add --recalc-average-width command-line option (on by default); log message if xAvgCharWidth changed 2016-07-19 22:54:05 +01:00
Khaled Hosny
efb32d5402 [subset] Recalculate OS/2.xAvgCharWidth 2016-07-18 01:35:18 +02:00
Behdad Esfahbod
5cd1fbaff6 [subset] Clear CFF Encoding vector
Fixes https://github.com/behdad/fonttools/issues/620
2016-07-13 00:33:41 -07:00
Khaled Hosny
f88c43d105 Check for file attribute before deleting it
I don’t know why this is happening, but I’m getting attribute error when
I build https://github.com/khaledhosny/mada with compreffor
optimisations on.
2016-05-19 20:50:10 +02:00
Cosimo Lupo
ca8e49b6f5 subset: fix typo
Ouch.
2016-05-16 17:05:46 +01:00
Cosimo Lupo
920c6a8249 subset: set maxp.maxStorage to 0 when --no-hinting option is passed
'maxStorage' is the maximum number of Storage Area locations used.
If there's no hinting, it should be 0.
2016-05-16 15:57:17 +01:00
Behdad Esfahbod
26bb99e1c3 [subset] Whitespace 2016-05-12 13:40:14 +02:00
Behdad Esfahbod
cd914c9575 [subset] Protect against some more prematurely-short arrays 2016-05-12 13:40:14 +02:00
Behdad Esfahbod
85750a864a [subset] Protect against prematurely-short arrays GPOS 2016-05-12 13:40:14 +02:00
Rod Sheeter
df2c2c7128 Verify that we can see individual parts of timing messages 2016-05-11 17:39:37 -07:00
Behdad Esfahbod
a61b31a917 [subset] Mark avar and fvar tables as no-need-subsetting 2016-04-08 18:41:31 -07:00
Sascha Brawer
0fad6e66ec Support subsetting of variation fonts 2016-03-31 16:23:24 +02:00
justvanrossum
ad386ee477 Keep Format attribute for OT subtables. This value may be ignored by the compiler but is useful for debugging. Part of fixing #92. 2016-03-21 12:12:05 +01:00
Behdad Esfahbod
74e629e600 [subset] Retain GSUB ScriptRecords, even if they are empty
This slightly bloats subset fonts, but fixes:
https://bugzilla.mozilla.org/show_bug.cgi?id=1080739#c15
https://github.com/behdad/fonttools/issues/518

At some point we might want to do something smarter based
on Unicode script of retained characters.
2016-02-10 16:22:24 +07:00
Cosimo Lupo
f6b8445515 [subset] catch OptionError exception, print usage + error and throw exit code 2 2016-02-04 12:17:01 +00:00
Cosimo Lupo
c4d2ebca66 remove deprecated use of 'quiet' option in test modules 2016-02-01 13:39:39 +00:00
Cosimo Lupo
7ac65613eb [subset] add --with-zopfli option; set 'canonical_order' to None
'canonical_order' default value was set to False in the subsetter. However,
the meaning of the related 'reorderTables' argument in TTFont.save method has changed
with commit 6ba67ab699d62962690a7a523c286ebf0c8b0ae4.
When the latter is set to False, the original input font's table order is "kept": which
still means doing some sort of reordering. If one wishes to avoid any kind of reordering,
reorderTables needs to be set to None.
2016-01-31 14:50:04 +00:00
Cosimo Lupo
c5febaf1a5 [subset] remove custom Logger and use logging instead
The Subsetter class now uses a module-level 'log', and no longer uses
its own custom Logger. This has been removed, and its features replaced
by equivalents.

log.lapse() are replaced with Timer context manager/decorator (these should make clearer where the elapsed time starts/stops);

log.glyphs() is kept for convenience: it is bound dynamically to the logger instance instead of subclassing logging.Logger, as it's only
useful in here.

log.font() is replaced by `font.saveXML(sys.stdout)`.

A distinct sub-logger is configured for timing messages, to allow --timing option to be enabled independently from --verbose
2016-01-27 19:05:05 +00:00
Cosimo Lupo
ce5d230eef [subset] add --prune-unicode-ranges option (enabled by default) 2016-01-27 18:38:32 +00:00
Cosimo Lupo
ac56990aad replace all uses of codecs.open with py23.open 2016-01-26 15:45:27 +00:00
Khaled Hosny
279243202a [subset] Test MATH table 2016-01-23 23:09:22 +04:00
Khaled Hosny
0e1cc9fb73 [subset] Add support for MATH table 2016-01-23 23:00:30 +04:00
Behdad Esfahbod
0ec2911c47 [subset] Fix for f0eb7e98ca0642f17ac82433db8c957fffd6a9d3 2016-01-13 17:00:29 +00:00
Rod Sheeter
9927a91653 Remove change to _dict_subset (meant to be local/test only). Add a cmap fmt 0 to color font test file. 2015-12-09 13:32:35 -08:00
Rod Sheeter
905eb831b9 Add Google-style color font test and make _dict_subset more forgiving. 2015-12-09 13:05:16 -08:00
Cosimo Lupo
812609e90c [subset] fix logic of EBLC subsetting; avoid KeyError in EBDT subsetting 2015-12-09 09:42:15 -08:00
Rod Sheeter
9189d1a1f0 Experimental support for Google-style color bitmap fonts 2015-12-09 09:42:15 -08:00
Behdad Esfahbod
8128b509a4 [subset] Augment ContextHelper
As needed in my Monotype OpenType format parser.  I'm not using the object
directly from subset module, but pushing back my changes here, in the hope
that we move this object to ttLib proper soon.
2015-12-08 20:40:42 +01:00
Behdad Esfahbod
f129f658c9 [subset] Fix Options parsing
Fixes https://github.com/behdad/fonttools/issues/413
Test passes now.
2015-12-07 11:14:04 +01:00
Behdad Esfahbod
59b702c5ca [subset] Add test for subset.Options
Currently fails.
https://github.com/behdad/fonttools/issues/413
2015-12-07 11:13:44 +01:00
Khaled Hosny
301d2db812 [subset] Support subsetting MS color tables
Add support for subsetting COLR table.

The CPAL table does not need subsetting, but unused palettes should be
pruned, this is not implemented however as it depends on COLR table,
which in turn will not be updated after pruning CPAL.
2015-12-01 11:59:52 +04:00