require lxml to subset SVG
support for namespaces and xpath is insufficient in built-in ElementTree; supporting both lxml and ElementTree is too complicated, let's simply require lxml to be able to subset SVG for now
This commit is contained in:
parent
d44af9f2d7
commit
0dc2be3e78
@ -1,9 +1,16 @@
|
||||
import re
|
||||
from itertools import groupby
|
||||
|
||||
from fontTools.subset.util import _add_method
|
||||
from fontTools.misc import etree
|
||||
try:
|
||||
from lxml import etree
|
||||
except ModuleNotFoundError:
|
||||
etree = None
|
||||
|
||||
from fontTools import ttLib
|
||||
from fontTools.subset.util import _add_method
|
||||
|
||||
|
||||
__all__ = ["subset_glyphs"]
|
||||
|
||||
|
||||
GID_RE = re.compile("^glyph(\d+)$")
|
||||
@ -72,6 +79,9 @@ def ranges(ints):
|
||||
|
||||
@_add_method(ttLib.getTableClass("SVG "))
|
||||
def subset_glyphs(self, s):
|
||||
if etree is None:
|
||||
raise ModuleNotFoundError("No module named 'lxml', required to subset SVG")
|
||||
|
||||
# ordered list of glyph names (before subsetting)
|
||||
glyph_order = s.orig_glyph_order
|
||||
# map from glyph names to original glyph indices
|
||||
|
Loading…
x
Reference in New Issue
Block a user