aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-11-29 14:00:46 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-11-29 16:03:10 +0300
commitf8dcc21a2e403d3eb6875294d36a64f3f52dbc31 (patch)
tree106e239bf2ef4413ab9bed722ebedfb499107aaf /contrib
parent10fd58d05678db9a22303a46178f5ed6c7150601 (diff)
downloadydb-f8dcc21a2e403d3eb6875294d36a64f3f52dbc31.tar.gz
Update contrib/python/fonttools to 4.44.1
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/fonttools/.dist-info/METADATA10
-rw-r--r--contrib/python/fonttools/fontTools/__init__.py2
-rw-r--r--contrib/python/fonttools/fontTools/feaLib/builder.py3
-rw-r--r--contrib/python/fonttools/fontTools/subset/__init__.py14
-rw-r--r--contrib/python/fonttools/fontTools/ttLib/tables/O_S_2f_2.py125
-rw-r--r--contrib/python/fonttools/ya.make2
6 files changed, 152 insertions, 4 deletions
diff --git a/contrib/python/fonttools/.dist-info/METADATA b/contrib/python/fonttools/.dist-info/METADATA
index 996d69838a..dfdbe2c0d9 100644
--- a/contrib/python/fonttools/.dist-info/METADATA
+++ b/contrib/python/fonttools/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: fonttools
-Version: 4.44.0
+Version: 4.44.1
Summary: Tools to manipulate font files
Home-page: http://github.com/fonttools/fonttools
Author: Just van Rossum
@@ -366,6 +366,14 @@ Have fun!
Changelog
~~~~~~~~~
+4.44.1 (released 2023-11-14)
+----------------------------
+
+- [feaLib] Ensure variable mark anchors are deep-copied while building since they
+ get modified in-place and later reused (#3330).
+- [OS/2|subset] Added method to ``recalcCodePageRanges`` to OS/2 table class; added
+ ``--prune-codepage-ranges`` to `fonttools subset` command (#3328, #2607).
+
4.44.0 (released 2023-11-03)
----------------------------
diff --git a/contrib/python/fonttools/fontTools/__init__.py b/contrib/python/fonttools/fontTools/__init__.py
index 9a59504e44..cf93bad01f 100644
--- a/contrib/python/fonttools/fontTools/__init__.py
+++ b/contrib/python/fonttools/fontTools/__init__.py
@@ -3,6 +3,6 @@ from fontTools.misc.loggingTools import configLogger
log = logging.getLogger(__name__)
-version = __version__ = "4.44.0"
+version = __version__ = "4.44.1"
__all__ = ["version", "log", "configLogger"]
diff --git a/contrib/python/fonttools/fontTools/feaLib/builder.py b/contrib/python/fonttools/fontTools/feaLib/builder.py
index cfaf54d4d1..36eed95148 100644
--- a/contrib/python/fonttools/fontTools/feaLib/builder.py
+++ b/contrib/python/fonttools/fontTools/feaLib/builder.py
@@ -36,6 +36,7 @@ from fontTools.varLib.builder import buildVarDevTable
from fontTools.varLib.featureVars import addFeatureVariationsRaw
from fontTools.varLib.models import normalizeValue, piecewiseLinearMap
from collections import defaultdict
+import copy
import itertools
from io import StringIO
import logging
@@ -1516,7 +1517,7 @@ class Builder(object):
for mark in markClassDef.glyphs.glyphSet():
if mark not in lookupBuilder.marks:
otMarkAnchor = self.makeOpenTypeAnchor(
- location, markClassDef.anchor
+ location, copy.deepcopy(markClassDef.anchor)
)
lookupBuilder.marks[mark] = (markClass.name, otMarkAnchor)
else:
diff --git a/contrib/python/fonttools/fontTools/subset/__init__.py b/contrib/python/fonttools/fontTools/subset/__init__.py
index bd826ed224..d9da900fe1 100644
--- a/contrib/python/fonttools/fontTools/subset/__init__.py
+++ b/contrib/python/fonttools/fontTools/subset/__init__.py
@@ -407,6 +407,10 @@ Other font-specific options
*not* be switched on if an intersection is found. [default]
--no-prune-unicode-ranges
Don't change the 'OS/2 ulUnicodeRange*' bits.
+--prune-codepage-ranges
+ Update the 'OS/2 ulCodePageRange*' bits after subsetting. [default]
+--no-prune-codepage-ranges
+ Don't change the 'OS/2 ulCodePageRange*' bits.
--recalc-average-width
Update the 'OS/2 xAvgCharWidth' field after subsetting.
--no-recalc-average-width
@@ -3086,6 +3090,7 @@ class Options(object):
self.recalc_bounds = False # Recalculate font bounding boxes
self.recalc_timestamp = False # Recalculate font modified timestamp
self.prune_unicode_ranges = True # Clear unused 'ulUnicodeRange' bits
+ self.prune_codepage_ranges = True # Clear unused 'ulCodePageRange' bits
self.recalc_average_width = False # update 'xAvgCharWidth'
self.recalc_max_context = False # update 'usMaxContext'
self.canonical_order = None # Order tables as recommended
@@ -3450,6 +3455,15 @@ class Subsetter(object):
log.info(
"%s Unicode ranges pruned: %s", tag, sorted(new_uniranges)
)
+ if self.options.prune_codepage_ranges:
+ old_codepages = font[tag].getCodePageRanges()
+ new_codepages = font[tag].recalcCodePageRanges(font, pruneOnly=True)
+ if old_codepages != new_codepages:
+ log.info(
+ "%s CodePage ranges pruned: %s",
+ tag,
+ sorted(new_codepages),
+ )
if self.options.recalc_average_width:
old_avg_width = font[tag].xAvgCharWidth
new_avg_width = font[tag].recalcAvgCharWidth(font)
diff --git a/contrib/python/fonttools/fontTools/ttLib/tables/O_S_2f_2.py b/contrib/python/fonttools/fontTools/ttLib/tables/O_S_2f_2.py
index 7b403026aa..b4126b835b 100644
--- a/contrib/python/fonttools/fontTools/ttLib/tables/O_S_2f_2.py
+++ b/contrib/python/fonttools/fontTools/ttLib/tables/O_S_2f_2.py
@@ -340,6 +340,45 @@ class table_O_S_2f_2(DefaultTable.DefaultTable):
self.setUnicodeRanges(bits)
return bits
+ def getCodePageRanges(self):
+ """Return the set of 'ulCodePageRange*' bits currently enabled."""
+ bits = set()
+ ul1, ul2 = self.ulCodePageRange1, self.ulCodePageRange2
+ for i in range(32):
+ if ul1 & (1 << i):
+ bits.add(i)
+ if ul2 & (1 << i):
+ bits.add(i + 32)
+ return bits
+
+ def setCodePageRanges(self, bits):
+ """Set the 'ulCodePageRange*' fields to the specified 'bits'."""
+ ul1, ul2 = 0, 0
+ for bit in bits:
+ if 0 <= bit < 32:
+ ul1 |= 1 << bit
+ elif 32 <= bit < 64:
+ ul2 |= 1 << (bit - 32)
+ else:
+ raise ValueError(f"expected 0 <= int <= 63, found: {bit:r}")
+ self.ulCodePageRange1, self.ulCodePageRange2 = ul1, ul2
+
+ def recalcCodePageRanges(self, ttFont, pruneOnly=False):
+ unicodes = set()
+ for table in ttFont["cmap"].tables:
+ if table.isUnicode():
+ unicodes.update(table.cmap.keys())
+ bits = calcCodePageRanges(unicodes)
+ if pruneOnly:
+ bits &= self.getCodePageRanges()
+ # when no codepage ranges can be enabled, fall back to enabling bit 0
+ # (Latin 1) so that the font works in MS Word:
+ # https://github.com/googlei18n/fontmake/issues/468
+ if not bits:
+ bits = {0}
+ self.setCodePageRanges(bits)
+ return bits
+
def recalcAvgCharWidth(self, ttFont):
"""Recalculate xAvgCharWidth using metrics from ttFont's 'hmtx' table.
@@ -611,6 +650,92 @@ def intersectUnicodeRanges(unicodes, inverse=False):
return set(range(len(OS2_UNICODE_RANGES))) - bits if inverse else bits
+def calcCodePageRanges(unicodes):
+ """Given a set of Unicode codepoints (integers), calculate the
+ corresponding OS/2 CodePage range bits.
+ This is a direct translation of FontForge implementation:
+ https://github.com/fontforge/fontforge/blob/7b2c074/fontforge/tottf.c#L3158
+ """
+ bits = set()
+ hasAscii = set(range(0x20, 0x7E)).issubset(unicodes)
+ hasLineart = ord("┤") in unicodes
+
+ for uni in unicodes:
+ if uni == ord("Þ") and hasAscii:
+ bits.add(0) # Latin 1
+ elif uni == ord("Ľ") and hasAscii:
+ bits.add(1) # Latin 2: Eastern Europe
+ if hasLineart:
+ bits.add(58) # Latin 2
+ elif uni == ord("Б"):
+ bits.add(2) # Cyrillic
+ if ord("Ѕ") in unicodes and hasLineart:
+ bits.add(57) # IBM Cyrillic
+ if ord("╜") in unicodes and hasLineart:
+ bits.add(49) # MS-DOS Russian
+ elif uni == ord("Ά"):
+ bits.add(3) # Greek
+ if hasLineart and ord("½") in unicodes:
+ bits.add(48) # IBM Greek
+ if hasLineart and ord("√") in unicodes:
+ bits.add(60) # Greek, former 437 G
+ elif uni == ord("İ") and hasAscii:
+ bits.add(4) # Turkish
+ if hasLineart:
+ bits.add(56) # IBM turkish
+ elif uni == ord("א"):
+ bits.add(5) # Hebrew
+ if hasLineart and ord("√") in unicodes:
+ bits.add(53) # Hebrew
+ elif uni == ord("ر"):
+ bits.add(6) # Arabic
+ if ord("√") in unicodes:
+ bits.add(51) # Arabic
+ if hasLineart:
+ bits.add(61) # Arabic; ASMO 708
+ elif uni == ord("ŗ") and hasAscii:
+ bits.add(7) # Windows Baltic
+ if hasLineart:
+ bits.add(59) # MS-DOS Baltic
+ elif uni == ord("₫") and hasAscii:
+ bits.add(8) # Vietnamese
+ elif uni == ord("ๅ"):
+ bits.add(16) # Thai
+ elif uni == ord("エ"):
+ bits.add(17) # JIS/Japan
+ elif uni == ord("ㄅ"):
+ bits.add(18) # Chinese: Simplified
+ elif uni == ord("ㄱ"):
+ bits.add(19) # Korean wansung
+ elif uni == ord("央"):
+ bits.add(20) # Chinese: Traditional
+ elif uni == ord("곴"):
+ bits.add(21) # Korean Johab
+ elif uni == ord("♥") and hasAscii:
+ bits.add(30) # OEM Character Set
+ # TODO: Symbol bit has a special meaning (check the spec), we need
+ # to confirm if this is wanted by default.
+ # elif chr(0xF000) <= char <= chr(0xF0FF):
+ # codepageRanges.add(31) # Symbol Character Set
+ elif uni == ord("þ") and hasAscii and hasLineart:
+ bits.add(54) # MS-DOS Icelandic
+ elif uni == ord("╚") and hasAscii:
+ bits.add(62) # WE/Latin 1
+ bits.add(63) # US
+ elif hasAscii and hasLineart and ord("√") in unicodes:
+ if uni == ord("Å"):
+ bits.add(50) # MS-DOS Nordic
+ elif uni == ord("é"):
+ bits.add(52) # MS-DOS Canadian French
+ elif uni == ord("õ"):
+ bits.add(55) # MS-DOS Portuguese
+
+ if hasAscii and ord("‰") in unicodes and ord("∑") in unicodes:
+ bits.add(29) # Macintosh Character Set (US Roman)
+
+ return bits
+
+
if __name__ == "__main__":
import doctest, sys
diff --git a/contrib/python/fonttools/ya.make b/contrib/python/fonttools/ya.make
index adcfec1693..1a702d48c6 100644
--- a/contrib/python/fonttools/ya.make
+++ b/contrib/python/fonttools/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(4.44.0)
+VERSION(4.44.1)
LICENSE(MIT)