[mtiLib] Allow empty lookup
This commit is contained in:
parent
edd46bb14a
commit
2f800c9384
@ -186,7 +186,7 @@ def parseLookupFlags(lines):
|
|||||||
'markattachmenttype',
|
'markattachmenttype',
|
||||||
'markfiltertype',
|
'markfiltertype',
|
||||||
]
|
]
|
||||||
while lines.peek()[0].lower() in allFlags:
|
while lines.peeks()[0].lower() in allFlags:
|
||||||
line = next(lines)
|
line = next(lines)
|
||||||
flag = {
|
flag = {
|
||||||
'righttoleft': 0x0001,
|
'righttoleft': 0x0001,
|
||||||
@ -253,7 +253,7 @@ def parseSinglePos(lines, font, _lookupMap=None):
|
|||||||
|
|
||||||
def parsePair(self, lines, font, _lookupMap=None):
|
def parsePair(self, lines, font, _lookupMap=None):
|
||||||
self.ValueFormat1 = self.ValueFormat2 = 0
|
self.ValueFormat1 = self.ValueFormat2 = 0
|
||||||
typ = lines.peek()[0].split()[0].lower()
|
typ = lines.peeks()[0].split()[0].lower()
|
||||||
if typ in ('left', 'right'):
|
if typ in ('left', 'right'):
|
||||||
self.Format = 1
|
self.Format = 1
|
||||||
values = {}
|
values = {}
|
||||||
@ -295,7 +295,7 @@ def parsePair(self, lines, font, _lookupMap=None):
|
|||||||
elif typ.endswith('class'):
|
elif typ.endswith('class'):
|
||||||
self.Format = 2
|
self.Format = 2
|
||||||
classDefs = [None, None]
|
classDefs = [None, None]
|
||||||
while lines.peek()[0].endswith("class definition begin"):
|
while lines.peeks()[0].endswith("class definition begin"):
|
||||||
typ = lines.peek()[0][:-len("class definition begin")].lower()
|
typ = lines.peek()[0][:-len("class definition begin")].lower()
|
||||||
idx,klass = {
|
idx,klass = {
|
||||||
'first': (0,ot.ClassDef1),
|
'first': (0,ot.ClassDef1),
|
||||||
@ -338,7 +338,7 @@ def parsePair(self, lines, font, _lookupMap=None):
|
|||||||
assert 0, typ
|
assert 0, typ
|
||||||
|
|
||||||
def parseKernset(self, lines, font, _lookupMap=None):
|
def parseKernset(self, lines, font, _lookupMap=None):
|
||||||
typ = lines.peek()[0].split()[0].lower()
|
typ = lines.peeks()[0].split()[0].lower()
|
||||||
if typ in ('left', 'right'):
|
if typ in ('left', 'right'):
|
||||||
with lines.until(("firstclass definition begin", "secondclass definition begin")):
|
with lines.until(("firstclass definition begin", "secondclass definition begin")):
|
||||||
return parsePair(self, lines, font)
|
return parsePair(self, lines, font)
|
||||||
@ -689,7 +689,7 @@ def bucketizeRules(self, c, rules, bucketKeys):
|
|||||||
setattr(self, c.RuleSetCount, len(rulesets))
|
setattr(self, c.RuleSetCount, len(rulesets))
|
||||||
|
|
||||||
def parseContext(self, lines, font, Type, lookupMap=None):
|
def parseContext(self, lines, font, Type, lookupMap=None):
|
||||||
typ = lines.peek()[0].split()[0].lower()
|
typ = lines.peeks()[0].split()[0].lower()
|
||||||
if typ == 'glyph':
|
if typ == 'glyph':
|
||||||
self.Format = 1
|
self.Format = 1
|
||||||
log.debug("Parsing %s format %s", Type, self.Format)
|
log.debug("Parsing %s format %s", Type, self.Format)
|
||||||
@ -710,7 +710,7 @@ def parseContext(self, lines, font, Type, lookupMap=None):
|
|||||||
log.debug("Parsing %s format %s", Type, self.Format)
|
log.debug("Parsing %s format %s", Type, self.Format)
|
||||||
c = ContextHelper(Type, self.Format)
|
c = ContextHelper(Type, self.Format)
|
||||||
classDefs = [None] * c.DataLen
|
classDefs = [None] * c.DataLen
|
||||||
while lines.peek()[0].endswith("class definition begin"):
|
while lines.peeks()[0].endswith("class definition begin"):
|
||||||
typ = lines.peek()[0][:-len("class definition begin")].lower()
|
typ = lines.peek()[0][:-len("class definition begin")].lower()
|
||||||
idx,klass = {
|
idx,klass = {
|
||||||
1: {
|
1: {
|
||||||
@ -741,7 +741,7 @@ def parseContext(self, lines, font, Type, lookupMap=None):
|
|||||||
log.debug("Parsing %s format %s", Type, self.Format)
|
log.debug("Parsing %s format %s", Type, self.Format)
|
||||||
c = ContextHelper(Type, self.Format)
|
c = ContextHelper(Type, self.Format)
|
||||||
coverages = tuple([] for i in range(c.DataLen))
|
coverages = tuple([] for i in range(c.DataLen))
|
||||||
while lines.peek()[0].endswith("coverage definition begin"):
|
while lines.peeks()[0].endswith("coverage definition begin"):
|
||||||
typ = lines.peek()[0][:-len("coverage definition begin")].lower()
|
typ = lines.peek()[0][:-len("coverage definition begin")].lower()
|
||||||
idx,klass = {
|
idx,klass = {
|
||||||
1: {
|
1: {
|
||||||
@ -777,7 +777,7 @@ def parseChainedPos(self, lines, font, lookupMap=None):
|
|||||||
def parseReverseChainedSubst(self, lines, font, _lookupMap=None):
|
def parseReverseChainedSubst(self, lines, font, _lookupMap=None):
|
||||||
self.Format = 1
|
self.Format = 1
|
||||||
coverages = ([], [])
|
coverages = ([], [])
|
||||||
while lines.peek()[0].endswith("coverage definition begin"):
|
while lines.peeks()[0].endswith("coverage definition begin"):
|
||||||
typ = lines.peek()[0][:-len("coverage definition begin")].lower()
|
typ = lines.peek()[0][:-len("coverage definition begin")].lower()
|
||||||
idx,klass = {
|
idx,klass = {
|
||||||
'backtrack': (0,ot.BacktrackCoverage),
|
'backtrack': (0,ot.BacktrackCoverage),
|
||||||
@ -842,7 +842,7 @@ def parseLookup(lines, tableTag, font, lookupMap=None):
|
|||||||
subtable = ot.lookupTypes[tableTag][lookup.LookupType]()
|
subtable = ot.lookupTypes[tableTag][lookup.LookupType]()
|
||||||
parseLookupSubTable(subtable, lines, font, lookupMap)
|
parseLookupSubTable(subtable, lines, font, lookupMap)
|
||||||
subtables.append(subtable)
|
subtables.append(subtable)
|
||||||
if lines.peek() and lines.peek()[0] in ('% subtable', 'subtable end'):
|
if lines.peeks()[0] in ('% subtable', 'subtable end'):
|
||||||
next(lines)
|
next(lines)
|
||||||
lines.expect('lookup end')
|
lines.expect('lookup end')
|
||||||
|
|
||||||
@ -1015,7 +1015,7 @@ def parseCmapId(lines, field):
|
|||||||
|
|
||||||
def parseTable(lines, font, tableTag=None):
|
def parseTable(lines, font, tableTag=None):
|
||||||
log.debug("Parsing table")
|
log.debug("Parsing table")
|
||||||
line = lines.peek()
|
line = lines.peeks()
|
||||||
tag = None
|
tag = None
|
||||||
if line[0].split()[0] == 'FontDame':
|
if line[0].split()[0] == 'FontDame':
|
||||||
tag = line[0].split()[1]
|
tag = line[0].split()[1]
|
||||||
@ -1103,6 +1103,10 @@ class Tokenizer(object):
|
|||||||
return None
|
return None
|
||||||
return self.buffer
|
return self.buffer
|
||||||
|
|
||||||
|
def peeks(self):
|
||||||
|
ret = self.peek()
|
||||||
|
return ret if ret is not None else ('',)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def between(self, tag):
|
def between(self, tag):
|
||||||
start = tag + ' begin'
|
start = tag + ' begin'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user