Remove script to build otData.py
The was was originally generated, but is static now and this allows cleaning it up and modifying it.
This commit is contained in:
parent
3879cf9439
commit
0de65295f6
@ -1,7 +1,7 @@
|
||||
otData = [
|
||||
|
||||
#
|
||||
# common (generated from chapter2.htm)
|
||||
# common
|
||||
#
|
||||
|
||||
('ScriptList', [
|
||||
@ -106,7 +106,7 @@ otData = [
|
||||
|
||||
|
||||
#
|
||||
# gpos (generated from gpos.htm)
|
||||
# gpos
|
||||
#
|
||||
|
||||
('GPOS', [
|
||||
@ -406,7 +406,7 @@ otData = [
|
||||
|
||||
|
||||
#
|
||||
# gsub (generated from gsub.htm)
|
||||
# gsub
|
||||
#
|
||||
|
||||
('GSUB', [
|
||||
@ -602,7 +602,7 @@ otData = [
|
||||
]),
|
||||
|
||||
#
|
||||
# gdef (generated from gdef.htm)
|
||||
# gdef
|
||||
#
|
||||
|
||||
('GDEF', [
|
||||
@ -653,7 +653,7 @@ otData = [
|
||||
|
||||
|
||||
#
|
||||
# base (generated from base.htm)
|
||||
# base
|
||||
#
|
||||
|
||||
('BASE', [
|
||||
@ -733,7 +733,7 @@ otData = [
|
||||
|
||||
|
||||
#
|
||||
# jstf (generated from jstf.htm)
|
||||
# jstf
|
||||
#
|
||||
|
||||
('JSTF', [
|
||||
|
@ -1,158 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
|
||||
"""This script builds the Lib/fontTools/ttLib/tables/otData.py file
|
||||
from the OpenType HTML documentation. However, it depends on a slightly
|
||||
patched version the the HTML, as there are some inconsistencies in the
|
||||
markup and the naming of certain fields. See doco.diff for differences,
|
||||
but this is probably against a slightly older version of the documentation
|
||||
than what is currently online. The documentation was taken from this URL:
|
||||
http://www.microsoft.com/typography/otspec/default.htm
|
||||
"""
|
||||
|
||||
|
||||
from sgmllib import SGMLParser
|
||||
|
||||
|
||||
class HTMLParser(SGMLParser):
|
||||
|
||||
def __init__(self):
|
||||
SGMLParser.__init__(self)
|
||||
self.data = None
|
||||
self.currenttable = None
|
||||
self.lastcaption = None
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.data is not None:
|
||||
self.data.append(data)
|
||||
|
||||
def start_i(self, attrs):
|
||||
if self.currenttable is None:
|
||||
self.data = []
|
||||
def end_i(self):
|
||||
if self.currenttable is None:
|
||||
self.lastcaption = " ".join(self.data)
|
||||
self.data = None
|
||||
|
||||
def start_b(self, attrs):
|
||||
if self.currenttable is None:
|
||||
self.data = []
|
||||
def end_b(self):
|
||||
if self.currenttable is None:
|
||||
self.lastcaption = " ".join(self.data)
|
||||
self.data = None
|
||||
|
||||
def start_table(self, attrs):
|
||||
attrs = dict(attrs)
|
||||
if attrs.get('width') in ('455', '460'):
|
||||
#print "---", attrs
|
||||
self.currenttable = []
|
||||
else:
|
||||
self.currenttable = None
|
||||
def end_table(self):
|
||||
if self.currenttable is not None and self.lastcaption is not None:
|
||||
if self.currenttable[0] == ['Type', 'Name', 'Description'] or \
|
||||
self.currenttable[0] == ['Value', 'Type', 'Description']:
|
||||
caption = self.lastcaption.split()
|
||||
name = caption[0]
|
||||
if name == "LookupType" or name == "LookupFlag":
|
||||
self.currenttable = None
|
||||
return
|
||||
elif name == "Device":
|
||||
if "Tables" in caption:
|
||||
# XXX skip this one
|
||||
self.currenttable = None
|
||||
return
|
||||
buildTable(name, self.currenttable[1:], self.lastcaption)
|
||||
self.currenttable = None
|
||||
|
||||
def start_tr(self, attrs):
|
||||
if self.currenttable is not None:
|
||||
self.currenttable.append([])
|
||||
def end_tr(self):
|
||||
pass
|
||||
|
||||
def start_td(self, attrs):
|
||||
self.data = []
|
||||
def end_td(self):
|
||||
if self.currenttable is not None and self.data is not None:
|
||||
self.currenttable[-1].append(" ".join(self.data))
|
||||
self.data = None
|
||||
|
||||
|
||||
globalDups = {}
|
||||
localDups = {}
|
||||
not3 = []
|
||||
|
||||
def buildTable(name, table, caption):
|
||||
if globalDups.has_key(name):
|
||||
globalDups[name].append(caption)
|
||||
else:
|
||||
globalDups[name] = [caption]
|
||||
print "\t(%s, [" % repr(name)
|
||||
allFields = {}
|
||||
for row in table:
|
||||
row = [" ".join(x.split()) for x in row]
|
||||
if len(row) <> 3:
|
||||
not3.append(row)
|
||||
row = makeRow(row)
|
||||
fieldName = row[1]
|
||||
if allFields.has_key(fieldName):
|
||||
key = (name, fieldName)
|
||||
localDups[key] = 1
|
||||
allFields[fieldName] = 1
|
||||
print "\t\t%s," % (tuple(row),)
|
||||
print "\t]),"
|
||||
print
|
||||
|
||||
|
||||
def makeRow(rawRow):
|
||||
tp, name = rawRow[:2]
|
||||
name = name.strip()
|
||||
rest = tuple(rawRow[2:])
|
||||
if '[' in name:
|
||||
name, repeat = name.split("[")
|
||||
name = name.strip()
|
||||
assert repeat[-1] == "]"
|
||||
repeat = repeat[:-1].split()
|
||||
if repeat[1:]:
|
||||
repeatOffset = int("".join(repeat[1:]))
|
||||
else:
|
||||
repeatOffset = 0
|
||||
if not repeat:
|
||||
repeat = ""
|
||||
else:
|
||||
repeat = repeat[0]
|
||||
else:
|
||||
repeat = None
|
||||
repeatOffset = None
|
||||
row = (tp, name, repeat, repeatOffset) + rest
|
||||
return row
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys, os
|
||||
if "-" not in sys.argv:
|
||||
sys.stdout = open("otData.py", "w")
|
||||
print "otData = ["
|
||||
for file in ["chapter2.htm", "gpos.htm", "gsub.htm", "gdef.htm", "base.htm", "jstf.htm"]:
|
||||
name = os.path.splitext(file)[0]
|
||||
if name == "chapter2":
|
||||
name = "common"
|
||||
print
|
||||
print "\t#"
|
||||
print "\t# %s (generated from %s)" % (name, file)
|
||||
print "\t#"
|
||||
print
|
||||
p = HTMLParser()
|
||||
p.feed(open(file).read())
|
||||
p.close()
|
||||
print "]"
|
||||
print
|
||||
for k, v in globalDups.items():
|
||||
if len(v) > 1:
|
||||
print "# XXX duplicate table name:", k, v
|
||||
for (name, fieldName), v in localDups.items():
|
||||
print "# XXX duplicate field name '%s' in table '%s'" % (fieldName, name)
|
||||
for n in not3:
|
||||
print "#XXX", not3
|
@ -1,108 +0,0 @@
|
||||
--- htmlorig/gpos.htm Fri Apr 5 23:55:58 2002
|
||||
+++ htmlbak/gpos.htm Tue May 7 09:53:30 2002
|
||||
@@ -270,7 +270,7 @@
|
||||
|
||||
<P>Example 2 at the end of this chapter shows a SinglePosFormat1 subtable used to adjust the placement of subscript glyphs.
|
||||
|
||||
-<P>SinglePosFormat1 subtable: Single positioning value
|
||||
+<P><I>SinglePosFormat1 subtable: Single positioning value</I>
|
||||
<P>
|
||||
|
||||
<TABLE BGCOLOR="#F0F0F0" WIDTH=460 BORDER=0 CELLPADDING=3>
|
||||
@@ -312,7 +312,7 @@
|
||||
|
||||
<P>Example 3 at the end of this chapter shows how to adjust the spacing of three dash glyphs with a SinglePosFormat2 subtable.
|
||||
|
||||
-<P>SinglePosFormat2 subtable: Array of positioning values
|
||||
+<P><I>SinglePosFormat2 subtable: Array of positioning values</I>
|
||||
<P>
|
||||
|
||||
<TABLE BGCOLOR="#F0F0F0" WIDTH=460 BORDER=0 CELLPADDING=3>
|
||||
@@ -392,8 +392,8 @@
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>PairSetCount</TD>
|
||||
<TD CLASS=tab>Number of PairSet tables</TD></TR>
|
||||
-<TR><TD CLASS=tab VALIGN=TOP>ValueRecord</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>PairSet<BR>[Offset]</TD>
|
||||
+<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>PairSet<BR>[PairSetCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to PairSet tables-from beginning of PairPos subtable-ordered by Coverage Index</TD></TR>
|
||||
</TABLE>
|
||||
|
||||
@@ -855,7 +855,8 @@
|
||||
<TD CLASS=tab>Offset to Base Mark Coverage table-from beginning of MarkMarkPos subtable</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>ClassCount</TD>
|
||||
-<TD CLASS=tab>Number of Combining Mark classes defined<TR>
|
||||
+<TD CLASS=tab>Number of Combining Mark classes defined</TD>
|
||||
+<TR>
|
||||
<TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>Mark1Array</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>Offset to MarkArray table for Mark1-from beginning of MarkMarkPos subtable</TD></TR>
|
||||
@@ -1386,19 +1387,19 @@
|
||||
<TD CLASS=tab VALIGN=TOP>BacktrackGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in the backtracking sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[BacktrackGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>BacktrackCoverage[BacktrackGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in backtracking sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>InputGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in input sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[InputGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>InputCoverage[InputGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in input sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>LookaheadGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in lookahead sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[LookaheadGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>LookaheadCoverage[LookaheadGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in lookahead sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>PosCount</TD>
|
||||
diff -u htmlorig/gsub.htm htmlbak/gsub.htm
|
||||
--- htmlorig/gsub.htm Fri Apr 5 23:55:58 2002
|
||||
+++ htmlbak/gsub.htm Tue May 7 09:53:17 2002
|
||||
@@ -758,7 +758,7 @@
|
||||
|
||||
<A HREF="#EX9"><P>Example 9</A> at the end of this chapter substitutes swash glyphs for two out of three glyphs in a sequence.
|
||||
|
||||
-<P><BR><I>ChainContextSubstFormat3 subtable: Coverage-based context glyph substitution</I><P>
|
||||
+<P><BR><I>ContextSubstFormat3 subtable: Coverage-based context glyph substitution</I><P>
|
||||
|
||||
<TABLE BGCOLOR="#F0F0F0" WIDTH=460 BORDER=0 CELLPADDING=3>
|
||||
<TR>
|
||||
@@ -880,7 +880,7 @@
|
||||
<TD CLASS=tab VALIGN=TOP>LookaheadGlyphCount</TD>
|
||||
<TD CLASS=tab>Total number of glyphs in the look ahead sequence (number of glyphs to be matched after the input sequence)</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>GlyphID</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>LookAhead<BR>[LookAheadGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>Lookahead<BR>[LookAheadGlyphCount]</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>Array of lookahead GlyphID's (to be matched after the input sequence)</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>SubstCount</TD>
|
||||
@@ -1023,19 +1023,19 @@
|
||||
<TD CLASS=tab VALIGN=TOP>BacktrackGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in the backtracking sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[BacktrackGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>BacktrackCoverage[BacktrackGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in backtracking sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>InputGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in input sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[InputGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>InputCoverage[InputGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in input sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>LookaheadGlyphCount</TD>
|
||||
<TD CLASS=tab>Number of glyphs in lookahead sequence</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>Offset</TD>
|
||||
-<TD CLASS=tab VALIGN=TOP>Coverage[LookaheadGlyphCount]</TD>
|
||||
+<TD CLASS=tab VALIGN=TOP>LookaheadCoverage[LookaheadGlyphCount]</TD>
|
||||
<TD CLASS=tab>Array of offsets to coverage tables in lookahead sequence, in glyph sequence order</TD></TR>
|
||||
<TR><TD CLASS=tab VALIGN=TOP>uint16</TD>
|
||||
<TD CLASS=tab VALIGN=TOP>SubstCount</TD>
|
Loading…
x
Reference in New Issue
Block a user