Merge pull request #2544 from fonttools/set-glyf-glyph-order
Also update glyf's glyphOrder when calling TTFont.setGlyphOrder()
This commit is contained in:
commit
71a5bf1b51
@ -451,6 +451,8 @@ class TTFont(object):
|
|||||||
self.glyphOrder = glyphOrder
|
self.glyphOrder = glyphOrder
|
||||||
if hasattr(self, '_reverseGlyphOrderDict'):
|
if hasattr(self, '_reverseGlyphOrderDict'):
|
||||||
del self._reverseGlyphOrderDict
|
del self._reverseGlyphOrderDict
|
||||||
|
if self.isLoaded("glyf"):
|
||||||
|
self["glyf"].setGlyphOrder(glyphOrder)
|
||||||
|
|
||||||
def getGlyphOrder(self):
|
def getGlyphOrder(self):
|
||||||
"""Returns a list of glyph names ordered by their position in the font."""
|
"""Returns a list of glyph names ordered by their position in the font."""
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import random
|
||||||
from fontTools.ttLib import TTFont, newTable, registerCustomTableClass, unregisterCustomTableClass
|
from fontTools.ttLib import TTFont, newTable, registerCustomTableClass, unregisterCustomTableClass
|
||||||
from fontTools.ttLib.tables.DefaultTable import DefaultTable
|
from fontTools.ttLib.tables.DefaultTable import DefaultTable
|
||||||
|
|
||||||
@ -118,3 +119,21 @@ def test_virtualGlyphId():
|
|||||||
font.saveXML(out)
|
font.saveXML(out)
|
||||||
outxml = normalize_TTX(out.getvalue()).splitlines()
|
outxml = normalize_TTX(out.getvalue()).splitlines()
|
||||||
assert xml == outxml
|
assert xml == outxml
|
||||||
|
|
||||||
|
|
||||||
|
def test_setGlyphOrder_also_updates_glyf_glyphOrder():
|
||||||
|
# https://github.com/fonttools/fonttools/issues/2060#issuecomment-1063932428
|
||||||
|
font = TTFont()
|
||||||
|
font.importXML(os.path.join(DATA_DIR, "TestTTF-Regular.ttx"))
|
||||||
|
current_order = font.getGlyphOrder()
|
||||||
|
|
||||||
|
assert current_order == font["glyf"].glyphOrder
|
||||||
|
|
||||||
|
new_order = list(current_order)
|
||||||
|
while new_order == current_order:
|
||||||
|
random.shuffle(new_order)
|
||||||
|
|
||||||
|
font.setGlyphOrder(new_order)
|
||||||
|
|
||||||
|
assert font.getGlyphOrder() == new_order
|
||||||
|
assert font["glyf"].glyphOrder == new_order
|
||||||
|
Loading…
x
Reference in New Issue
Block a user