440 Commits

Author SHA1 Message Date
Behdad Esfahbod
b342a27430 Add glyf.Glyph.trim() that removes padding and if asked hinting 2014-08-15 14:34:03 -04:00
Cosimo Lupo
e386a1a408 update table's list through MetaTools/buildTableList.py 2014-08-13 19:51:47 +01:00
Cosimo Lupo
d9c0d38115 a VDMX table converter 2014-08-13 19:51:13 +01:00
Behdad Esfahbod
5ba7d98a41 [glyf] Only pad glyphs that are odd-lengthed
Ouch!  Thinko.
2014-07-23 16:36:31 -04:00
Behdad Esfahbod
5ed7d154a9 Turn assert into warning 2014-07-23 16:28:34 -04:00
Behdad Esfahbod
3a10a6546c [glyf] Don't pad when removing hinting instructions
Finishes recent changes.
2014-07-22 21:48:19 -04:00
Behdad Esfahbod
9ab98b2d65 Adjust previous commit 2014-07-22 17:39:17 -04:00
Behdad Esfahbod
eef4daeeaa Add padding to glyphs only if it makes it possible to use short loca
Otherwise don't add padding.  This is against the spec, but "should"
work everywhere.  The spec only says offsets "should" be padded:

"""Note that the local offsets should be long-aligned, i.e., multiples
of 4. Offsets which are not long-aligned may seriously degrade
performance of some processors."""

We don't add any padded that we absolutely don't have to.  Should save
an average of one byte per glyph on large fonts.
2014-07-22 16:00:24 -04:00
Behdad Esfahbod
c6b031d661 Only use two-byte offsets in loca table if all offsets are even
Otherwise it will mess up.
2014-07-22 15:49:04 -04:00
Behdad Esfahbod
30ff4ab869 Minor debug output improvement 2014-07-22 15:37:17 -04:00
Behdad Esfahbod
e6adebdc4a Make glyf-table glyph loading lazy by default
When I added the font.lazy setting, I made glyf table non-lazy
by default.  This is helpful to users who typically access glyphs
like:

	glyf_table.glyphs[glyfname]

instead of the correct way:

	glyf_table[glyfname]

and also forget to call expand() on the glyph.  However, this
significantly slows down most scripts that load the font without
lazy=True...  As such, add a third mode to laziness.  By default
lazy=None and does NOT expand glyphs.  If lazy=False is passed
in, all glyphs are loaded.

I hope this is an acceptable middle ground and not too confusing.
2014-07-14 20:02:37 -04:00
Behdad Esfahbod
9bd685a3ec [cmap] Remove bogus use of font.lazy
Ouch!
2014-07-14 20:01:04 -04:00
Behdad Esfahbod
671bca785d [glyf] Align glyphs at word boundaries, not long
Saves two bytes per glyph on average.  Or as Roozbeh reports,
70kb in DroidSansFallbackFull.ttf.
2014-07-14 19:53:42 -04:00
Behdad Esfahbod
83a89c123f Fix isComposite with empty glyphs
Was broken in 626107c8.
2014-06-25 19:02:04 -06:00
Behdad Esfahbod
e0a45cdb84 Fixup for f1d5c85c3f8a3500048c8a3ef59a25f836e2bcb4
Really fix https://github.com/behdad/fonttools/issues/124
this time.
2014-06-16 18:39:22 -04:00
Behdad Esfahbod
f1d5c85c3f Ignore "reserved" post table format 2.0 indices
Fixes https://github.com/behdad/fonttools/issues/124
2014-06-13 13:18:22 -04:00
Behdad Esfahbod
3c89b298c3 Disallow empty glyph name decoded from post table
But preserve it...

For example, with this font:

https://code.google.com/p/googlefontdirectory/source/browse/ofl/phetsarath/Phetsarath-Regular.ttf

we now get:

    ...
    <GlyphID id="136" name="uni0EDD.am"/>
    <GlyphID id="137" name="uni0EB3.right"/>
    <GlyphID id="138" name="glyph00138"/>
    <GlyphID id="139" name="glyph00139"/>
    <GlyphID id="140" name="glyph00140"/>
    ...
    <GlyphID id="161" name="glyph00161"/>
  </GlyphOrder>

...

  <post>
    <formatType value="2.0"/>
    <italicAngle value="0.0"/>
    <underlinePosition value="-217"/>
    <underlineThickness value="150"/>
    <isFixedPitch value="0"/>
    <minMemType42 value="0"/>
    <maxMemType42 value="0"/>
    <minMemType1 value="0"/>
    <maxMemType1 value="0"/>
    <psNames>
      <!-- This file uses unique glyph names based on the information
           found in the 'post' table. Since these names might not be unique,
           we have to invent artificial names in case of clashes. In order to
           be able to retain the original information, we need a name to
           ps name mapping for those cases where they differ. That's what
           you see below.
            -->
      <psName name="glyph00107" psName=""/>
      <psName name="glyph00138" psName=""/>
      <psName name="glyph00139" psName=""/>
      ...
      <psName name="glyph00161" psName=""/>
    </psNames>

Part of https://github.com/behdad/fonttools/issues/124
2014-06-13 13:10:16 -04:00
Behdad Esfahbod
4d6be6b7d2 Don't use has_key in post table; that's gone in python3
Raised here: https://github.com/behdad/fonttools/issues/124
2014-06-13 12:47:58 -04:00
Behdad Esfahbod
69ef79b5da Err if post table format 2 indices get to the reserved range 2014-06-13 12:47:50 -04:00
Behdad Esfahbod
d65b587708 Minor 2014-06-05 17:58:15 -04:00
Behdad Esfahbod
ced737e249 Allow ligatures with one component only 2014-06-05 17:03:31 -04:00
Behdad Esfahbod
a47d226662 Apply fixes from 'hhea' to 'vhea'
Maybe they should be merged...
2014-06-02 18:31:52 -04:00
Behdad Esfahbod
4ff0d4b192 Fix post table glyph name dedup logic for edge case
This is a followup fix to 85be2e0a9773acec3c6d14c345b1fd94ab3aa5c3
Before this change, if some glyph names had a "#-number" suffix in
the post table, we could generate duplicate glyph names.  Fix that,
even though "#" is NOT a valid character in PS glyph names.
2014-06-02 18:03:35 -04:00
Behdad Esfahbod
62dd7b2a0e Refactor getSearchRange() 2014-05-27 16:01:47 -04:00
Behdad Esfahbod
9fed95216a Fix rangeShift calculations for count=0 in sfnt, cmap, and kern 2014-05-27 15:54:04 -04:00
Behdad Esfahbod
ec5f5150e2 Simplify cmap subtable format 4 idDelta code 2014-05-21 19:14:22 -04:00
Behdad Esfahbod
e7fb216ad8 Fix cmap subtable format 4 compiling
Was failing all these years, if a idDelta value happened to be
exactly -0x8000...

Test case: roundtripping MTLmr3m.ttf.
2014-05-21 19:14:03 -04:00
Behdad Esfahbod
4c777d3465 Typo 2014-05-21 17:57:14 -04:00
Behdad Esfahbod
ebde5454e5 Merge pull request #103 from olivierberten/post4
'post' format 4.0 support
2014-05-15 15:36:03 -06:00
Behdad Esfahbod
487b15fd94 Add a few __delitem__ implementations 2014-05-14 13:51:10 -06:00
Behdad Esfahbod
37b7bad5b1 Micro-optimize hmtx/vmtx loading 2014-05-14 00:30:02 -04:00
Behdad Esfahbod
d56eebfa96 Use .extend() syntax instead of += for sets 2014-05-14 00:22:14 -04:00
Behdad Esfahbod
470d610eb2 Further micro-optimize cmap subtable format 4 loading 2014-05-14 00:12:03 -04:00
Behdad Esfahbod
2db5eca0df Micro-optimize cmap subtable format 4 loading 2014-05-14 00:08:15 -04:00
Behdad Esfahbod
0d182bfb80 Speed up cmap format 4 loading
From quadratic to linear.  Sigh.
2014-05-14 00:00:47 -04:00
Behdad Esfahbod
da223b8fa8 Minor optimization 2014-05-09 17:05:32 -04:00
Behdad Esfahbod
497863a190 Allow disabling 'head' table modified-timestamp recalculation
Part of:
https://github.com/behdad/fonttools/issues/115
https://github.com/behdad/fonttools/issues/46
2014-05-01 15:13:22 -07:00
Behdad Esfahbod
d0a31f5a43 Make tag parameter to table constructor optional
If not provided, extract from class name.
2014-03-28 14:04:01 -07:00
Behdad Esfahbod
77ccf45eb0 Add NameRecord.isUnicode() 2014-03-12 12:32:27 -07:00
Behdad Esfahbod
0f74e80d59 Add isUnicode() and isSymbol() to cmap subtables 2014-03-12 12:17:33 -07:00
Behdad Esfahbod
319643ade2 Fix up regression in promoting lookups to extensions
Was broken by 6ed2eb409231a7fe3e0c2a135f9a89796206f639

Fixes https://github.com/behdad/fonttools/issues/110
2014-02-20 16:31:15 -05:00
Olivier Berten
ec8dccb731 More array instead of pack 2014-01-28 23:45:39 +01:00
Olivier Berten
149b9f97e3 use array instead of unpack 2014-01-28 20:59:10 +01:00
Olivier Berten
4a73f8b4e9 'post' format 4.0 support 2014-01-28 14:37:15 +01:00
Behdad Esfahbod
a36c74e8b8 Add logic for keeping PUSHB/PUSHW distinction
And avoid merging consequent pushes.  No option to control this
externally right now, but the logic is there.

Part of https://github.com/behdad/fonttools/issues/92
2014-01-19 17:30:19 +08: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
95f795f40a Move offset overflow fixing logic where it belongs 2013-12-20 21:52:28 -05:00
Behdad Esfahbod
b76d6ff14a [merge] Remove BaseTable.__hash__ need 2013-12-20 20:24:27 -05:00
Behdad Esfahbod
398770d51c [merge] Map GSUB/GPOS feature / lookup indices properly 2013-12-19 15:30:24 -05:00
Behdad Esfahbod
ee6340f475 Only track one parent per Writer
We were not using the extra parents anyway.
2013-12-17 06:31:37 -05:00