Skip to content

Commit

Permalink
Update contrib/python/fonttools to 4.56.0
Browse files Browse the repository at this point in the history
commit_hash:e14b5f62205f342a10d129125b2721f1c1bcb1b9
  • Loading branch information
robot-piglet committed Feb 22, 2025
1 parent 002e228 commit aeba7bc
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 73 deletions.
11 changes: 10 additions & 1 deletion contrib/python/fonttools/.dist-info/METADATA
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.2
Name: fonttools
Version: 4.55.8
Version: 4.56.0
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
Expand Down Expand Up @@ -391,6 +391,15 @@ Have fun!
Changelog
~~~~~~~~~

4.56.0 (released 2025-02-07)
----------------------------

- [varStore] Sort the input todo list with the same sorting key used for the opimizer's output (#3767).
- [otData] Fix DeviceTable's ``DeltaValue`` repeat value which caused a crash after importing from XML and then compiling a GPOS containing Device tables (#3758).
- [feaLib] Make ``FeatureLibError`` pickleable, so client can e.g. use feaLib to can compile features in parallel with multiprocessing (#3762).
- [varLib/gvar] Removed workaround for old, long-fixed macOS bug about composite glyphs with all zero deltas (#1381, #1788).
- [Docs] Updated ttLib documentation, beefed up TTFont and TTGlyphSet explanations (#3720).

4.55.8 (released 2025-01-29)
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion contrib/python/fonttools/fontTools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

log = logging.getLogger(__name__)

version = __version__ = "4.55.8"
version = __version__ = "4.56.0"

__all__ = ["version", "log", "configLogger"]
2 changes: 1 addition & 1 deletion contrib/python/fonttools/fontTools/feaLib/error.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class FeatureLibError(Exception):
def __init__(self, message, location):
def __init__(self, message, location=None):
Exception.__init__(self, message)
self.location = location

Expand Down
3 changes: 3 additions & 0 deletions contrib/python/fonttools/fontTools/misc/testTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def __init__(self, glyphs):
self.tables = {}
self.cfg = Config()

def __contains__(self, tag):
return tag in self.tables

def __getitem__(self, tag):
return self.tables[tag]

Expand Down
2 changes: 1 addition & 1 deletion contrib/python/fonttools/fontTools/ttLib/tables/otData.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
(
"DeltaValue",
"DeltaValue",
"",
None,
"DeltaFormat in (1,2,3)",
"Array of compressed data",
),
Expand Down
38 changes: 21 additions & 17 deletions contrib/python/fonttools/fontTools/ttLib/tables/otTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2226,24 +2226,28 @@ def computeClipBox(
def fixLookupOverFlows(ttf, overflowRecord):
"""Either the offset from the LookupList to a lookup overflowed, or
an offset from a lookup to a subtable overflowed.
The table layout is:
GPSO/GUSB
Script List
Feature List
LookUpList
Lookup[0] and contents
SubTable offset list
SubTable[0] and contents
...
SubTable[n] and contents
...
Lookup[n] and contents
SubTable offset list
SubTable[0] and contents
...
SubTable[n] and contents
The table layout is::
GPSO/GUSB
Script List
Feature List
LookUpList
Lookup[0] and contents
SubTable offset list
SubTable[0] and contents
...
SubTable[n] and contents
...
Lookup[n] and contents
SubTable offset list
SubTable[0] and contents
...
SubTable[n] and contents
If the offset to a lookup overflowed (SubTableIndex is None)
we must promote the *previous* lookup to an Extension type.
we must promote the *previous* lookup to an Extension type.
If the offset from a lookup to subtable overflowed, then we must promote it
to an Extension Lookup type.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def bfs_base_table(
"""Breadth-first search tree of BaseTables.
Args:
the root of the tree.
root
the root of the tree.
root_accessor (Optional[str]): attribute name for the root table, if any (mostly
useful for debugging).
skip_root (Optional[bool]): if True, the root itself is not visited, only its
Expand Down
8 changes: 6 additions & 2 deletions contrib/python/fonttools/fontTools/ttLib/ttFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TTFont(object):
they're actually accessed. This means that simple operations can be extremely fast.
Example usage:
.. code-block:: pycon
>>>
Expand All @@ -39,8 +40,10 @@ class TTFont(object):
>> tt['head'].unitsPerEm
2048
For details of the objects returned when accessing each table, see :ref:`tables`.
For details of the objects returned when accessing each table, see the
:doc:`tables </ttLib/tables>` documentation.
To add a table to the font, use the :py:func:`newTable` function:
.. code-block:: pycon
>>>
Expand All @@ -50,7 +53,8 @@ class TTFont(object):
>> font["OS/2"] = os2
TrueType fonts can also be serialized to and from XML format (see also the
:ref:`ttx` binary):
:doc:`ttx </ttx>` binary):
.. code-block:: pycon
>>
Expand Down
13 changes: 1 addition & 12 deletions contrib/python/fonttools/fontTools/varLib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ def _add_gvar(font, masterModel, master_ttfs, tolerance=0.5, optimize=True):

for glyph in font.getGlyphOrder():
log.debug("building gvar for glyph '%s'", glyph)
isComposite = glyf[glyph].isComposite()

allData = [
m.glyf._getCoordinatesAndControls(glyph, m.hMetrics, m.vMetrics)
Expand Down Expand Up @@ -363,7 +362,7 @@ def _add_gvar(font, masterModel, master_ttfs, tolerance=0.5, optimize=True):
endPts = control.endPts

for i, (delta, support) in enumerate(zip(deltas[1:], supports[1:])):
if all(v == 0 for v in delta.array) and not isComposite:
if all(v == 0 for v in delta.array):
continue
var = TupleVariation(support, delta)
if optimize:
Expand All @@ -372,16 +371,6 @@ def _add_gvar(font, masterModel, master_ttfs, tolerance=0.5, optimize=True):
)

if None in delta_opt:
"""In composite glyphs, there should be one 0 entry
to make sure the gvar entry is written to the font.
This is to work around an issue with macOS 10.14 and can be
removed once the behaviour of macOS is changed.
https://github.com/fonttools/fonttools/issues/1381
"""
if all(d is None for d in delta_opt):
delta_opt = [(0, 0)] + [None] * (len(delta_opt) - 1)
# Use "optimized" version only if smaller...
var_opt = TupleVariation(support, delta_opt)

Expand Down
46 changes: 9 additions & 37 deletions contrib/python/fonttools/fontTools/varLib/varStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,25 +412,6 @@ def append(self, row):
def extend(self, lst):
self.items.update(lst)

def get_room(self):
"""Maximum number of bytes that can be added to characteristic
while still being beneficial to merge it into another one."""
count = len(self.items)
return max(0, (self.overhead - 1) // count - self.width)

room = property(get_room)

def get_gain(self):
"""Maximum possible byte gain from merging this into another
characteristic."""
count = len(self.items)
return max(0, self.overhead - count)

gain = property(get_gain)

def gain_sort_key(self):
return self.gain, self.chars

def width_sort_key(self):
return self.width, self.chars

Expand Down Expand Up @@ -534,13 +515,9 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1):
# of the old encoding is completely eliminated. However, each row
# now would require more bytes to encode, to the tune of one byte
# per characteristic bit that is active in the new encoding but not
# in the old one. The number of bits that can be added to an encoding
# while still beneficial to merge it into another encoding is called
# the "room" for that encoding.
# in the old one.
#
# The "gain" of an encodings is the maximum number of bytes we can
# save by merging it into another encoding. The "gain" of merging
# two encodings is how many bytes we save by doing so.
# The "gain" of merging two encodings is how many bytes we save by doing so.
#
# High-level algorithm:
#
Expand All @@ -554,7 +531,11 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1):
#
# - Put all encodings into a "todo" list.
#
# - Sort todo list by decreasing gain (for stability).
# - Sort todo list (for stability) by width_sort_key(), which is a tuple
# of the following items:
# * The "width" of the encoding.
# * The characteristic bitmap of the encoding, with higher-numbered
# columns compared first.
#
# - Make a priority-queue of the gain from combining each two
# encodings in the todo list. The priority queue is sorted by
Expand All @@ -575,16 +556,7 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1):
#
# The output is then sorted for stability, in the following way:
# - The VarRegionList of the input is kept intact.
# - All encodings are sorted before the main algorithm, by
# gain_key_sort(), which is a tuple of the following items:
# * The gain of the encoding.
# * The characteristic bitmap of the encoding, with higher-numbered
# columns compared first.
# - The VarData is sorted by width_sort_key(), which is a tuple
# of the following items:
# * The "width" of the encoding.
# * The characteristic bitmap of the encoding, with higher-numbered
# columns compared first.
# - The VarData is sorted by the same width_sort_key() used at the beginning.
# - Within each VarData, the items are sorted as vectors of numbers.
#
# Finally, each VarData is optimized to remove the empty columns and
Expand Down Expand Up @@ -626,7 +598,7 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1):
front_mapping[(major << 16) + minor] = row

# Prepare for the main algorithm.
todo = sorted(encodings.values(), key=_Encoding.gain_sort_key)
todo = sorted(encodings.values(), key=_Encoding.width_sort_key)
del encodings

# Repeatedly pick two best encodings to combine, and combine them.
Expand Down

0 comments on commit aeba7bc

Please sign in to comment.