280 lines
10 KiB
Diff
280 lines
10 KiB
Diff
diff -urN fonttools-20050315/Lib/fontTools/fondLib.py fonttools-20050624/Lib/fontTools/fondLib.py
|
|
--- fonttools-20050315/Lib/fontTools/fondLib.py 2002-10-29 19:19:25.000000000 +0330
|
|
+++ fonttools-20050624/Lib/fontTools/fondLib.py 2005-06-24 14:05:16.000000000 +0430
|
|
@@ -12,6 +12,7 @@
|
|
DEBUG = 0
|
|
|
|
headerformat = """
|
|
+ >
|
|
ffFlags: h
|
|
ffFamID: h
|
|
ffFirstChar: h
|
|
@@ -127,9 +128,9 @@
|
|
def _getheader(self):
|
|
data = self.FOND.data
|
|
sstruct.unpack(headerformat, data[:28], self)
|
|
- self.ffProperty = struct.unpack("9h", data[28:46])
|
|
- self.ffIntl = struct.unpack("hh", data[46:50])
|
|
- self.ffVersion, = struct.unpack("h", data[50:FONDheadersize])
|
|
+ self.ffProperty = struct.unpack(">9h", data[28:46])
|
|
+ self.ffIntl = struct.unpack(">hh", data[46:50])
|
|
+ self.ffVersion, = struct.unpack(">h", data[50:FONDheadersize])
|
|
|
|
if DEBUG:
|
|
self._rawheader = data[:FONDheadersize]
|
|
@@ -137,9 +138,9 @@
|
|
|
|
def _buildheader(self):
|
|
header = sstruct.pack(headerformat, self)
|
|
- header = header + apply(struct.pack, ("9h",) + self.ffProperty)
|
|
- header = header + apply(struct.pack, ("hh",) + self.ffIntl)
|
|
- header = header + struct.pack("h", self.ffVersion)
|
|
+ header = header + apply(struct.pack, (">9h",) + self.ffProperty)
|
|
+ header = header + apply(struct.pack, (">hh",) + self.ffIntl)
|
|
+ header = header + struct.pack(">h", self.ffVersion)
|
|
if DEBUG:
|
|
print "header is the same?", self._rawheader == header and 'yes.' or 'no.'
|
|
if self._rawheader <> header:
|
|
@@ -149,12 +150,12 @@
|
|
def _getfontassociationtable(self):
|
|
data = self.FOND.data
|
|
offset = FONDheadersize
|
|
- numberofentries, = struct.unpack("h", data[offset:offset+2])
|
|
+ numberofentries, = struct.unpack(">h", data[offset:offset+2])
|
|
numberofentries = numberofentries + 1
|
|
size = numberofentries * 6
|
|
self.fontAssoc = []
|
|
for i in range(offset + 2, offset + size, 6):
|
|
- self.fontAssoc.append(struct.unpack("3h", data[i:i+6]))
|
|
+ self.fontAssoc.append(struct.unpack(">3h", data[i:i+6]))
|
|
|
|
self._endoffontassociationtable = offset + size + 2
|
|
if DEBUG:
|
|
@@ -162,9 +163,9 @@
|
|
self.parsedthings.append((offset, self._endoffontassociationtable, 'fontassociationtable'))
|
|
|
|
def _buildfontassociationtable(self):
|
|
- data = struct.pack("h", len(self.fontAssoc) - 1)
|
|
+ data = struct.pack(">h", len(self.fontAssoc) - 1)
|
|
for size, stype, ID in self.fontAssoc:
|
|
- data = data + struct.pack("3h", size, stype, ID)
|
|
+ data = data + struct.pack(">3h", size, stype, ID)
|
|
|
|
if DEBUG:
|
|
print "font association table is the same?", self._rawfontassociationtable == data and 'yes.' or 'no.'
|
|
@@ -194,10 +195,10 @@
|
|
return
|
|
boxes = {}
|
|
data = self._rawoffsettable[6:]
|
|
- numstyles = struct.unpack("h", data[:2])[0] + 1
|
|
+ numstyles = struct.unpack(">h", data[:2])[0] + 1
|
|
data = data[2:]
|
|
for i in range(numstyles):
|
|
- style, l, b, r, t = struct.unpack("hhhhh", data[:10])
|
|
+ style, l, b, r, t = struct.unpack(">hhhhh", data[:10])
|
|
boxes[style] = (l, b, r, t)
|
|
data = data[10:]
|
|
self.boundingBoxes = boxes
|
|
@@ -206,9 +207,9 @@
|
|
if self.boundingBoxes and self._rawoffsettable[:6] == '\0\0\0\0\0\6':
|
|
boxes = self.boundingBoxes.items()
|
|
boxes.sort()
|
|
- data = '\0\0\0\0\0\6' + struct.pack("h", len(boxes) - 1)
|
|
+ data = '\0\0\0\0\0\6' + struct.pack(">h", len(boxes) - 1)
|
|
for style, (l, b, r, t) in boxes:
|
|
- data = data + struct.pack("hhhhh", style, l, b, r, t)
|
|
+ data = data + struct.pack(">hhhhh", style, l, b, r, t)
|
|
self._rawoffsettable = data
|
|
|
|
def _getglyphwidthtable(self):
|
|
@@ -217,15 +218,15 @@
|
|
return
|
|
data = self.FOND.data
|
|
offset = self.ffWTabOff
|
|
- numberofentries, = struct.unpack("h", data[offset:offset+2])
|
|
+ numberofentries, = struct.unpack(">h", data[offset:offset+2])
|
|
numberofentries = numberofentries + 1
|
|
count = offset + 2
|
|
for i in range(numberofentries):
|
|
- stylecode, = struct.unpack("h", data[count:count+2])
|
|
+ stylecode, = struct.unpack(">h", data[count:count+2])
|
|
widthtable = self.widthTables[stylecode] = []
|
|
count = count + 2
|
|
for j in range(3 + self.ffLastChar - self.ffFirstChar):
|
|
- width, = struct.unpack("h", data[count:count+2])
|
|
+ width, = struct.unpack(">h", data[count:count+2])
|
|
widthtable.append(width)
|
|
count = count + 2
|
|
|
|
@@ -238,15 +239,15 @@
|
|
self._rawglyphwidthtable = ""
|
|
return
|
|
numberofentries = len(self.widthTables)
|
|
- data = struct.pack('h', numberofentries - 1)
|
|
+ data = struct.pack('>h', numberofentries - 1)
|
|
tables = self.widthTables.items()
|
|
tables.sort()
|
|
for stylecode, table in tables:
|
|
- data = data + struct.pack('h', stylecode)
|
|
+ data = data + struct.pack('>h', stylecode)
|
|
if len(table) <> (3 + self.ffLastChar - self.ffFirstChar):
|
|
raise error, "width table has wrong length"
|
|
for width in table:
|
|
- data = data + struct.pack('h', width)
|
|
+ data = data + struct.pack('>h', width)
|
|
if DEBUG:
|
|
print "glyph width table is the same?", self._rawglyphwidthtable == data and 'yes.' or 'no.'
|
|
self._rawglyphwidthtable = data
|
|
@@ -257,17 +258,17 @@
|
|
return
|
|
data = self.FOND.data
|
|
offset = self.ffKernOff
|
|
- numberofentries, = struct.unpack("h", data[offset:offset+2])
|
|
+ numberofentries, = struct.unpack(">h", data[offset:offset+2])
|
|
numberofentries = numberofentries + 1
|
|
count = offset + 2
|
|
for i in range(numberofentries):
|
|
- stylecode, = struct.unpack("h", data[count:count+2])
|
|
+ stylecode, = struct.unpack(">h", data[count:count+2])
|
|
count = count + 2
|
|
- numberofpairs, = struct.unpack("h", data[count:count+2])
|
|
+ numberofpairs, = struct.unpack(">h", data[count:count+2])
|
|
count = count + 2
|
|
kerntable = self.kernTables[stylecode] = []
|
|
for j in range(numberofpairs):
|
|
- firstchar, secondchar, kerndistance = struct.unpack("cch", data[count:count+4])
|
|
+ firstchar, secondchar, kerndistance = struct.unpack(">cch", data[count:count+4])
|
|
kerntable.append((ord(firstchar), ord(secondchar), kerndistance))
|
|
count = count + 4
|
|
|
|
@@ -281,14 +282,14 @@
|
|
self.ffKernOff = 0
|
|
return
|
|
numberofentries = len(self.kernTables)
|
|
- data = [struct.pack('h', numberofentries - 1)]
|
|
+ data = [struct.pack('>h', numberofentries - 1)]
|
|
tables = self.kernTables.items()
|
|
tables.sort()
|
|
for stylecode, table in tables:
|
|
- data.append(struct.pack('h', stylecode))
|
|
- data.append(struct.pack('h', len(table))) # numberofpairs
|
|
+ data.append(struct.pack('>h', stylecode))
|
|
+ data.append(struct.pack('>h', len(table))) # numberofpairs
|
|
for firstchar, secondchar, kerndistance in table:
|
|
- data.append(struct.pack("cch", chr(firstchar), chr(secondchar), kerndistance))
|
|
+ data.append(struct.pack(">cch", chr(firstchar), chr(secondchar), kerndistance))
|
|
|
|
data = string.join(data, '')
|
|
|
|
@@ -308,9 +309,9 @@
|
|
return
|
|
data = self.FOND.data
|
|
self.fondClass, self.glyphTableOffset, self.styleMappingReserved, = \
|
|
- struct.unpack("hll", data[offset:offset+10])
|
|
- self.styleIndices = struct.unpack('48b', data[offset + 10:offset + 58])
|
|
- stringcount, = struct.unpack('h', data[offset+58:offset+60])
|
|
+ struct.unpack(">hll", data[offset:offset+10])
|
|
+ self.styleIndices = struct.unpack('>48b', data[offset + 10:offset + 58])
|
|
+ stringcount, = struct.unpack('>h', data[offset+58:offset+60])
|
|
|
|
count = offset + 60
|
|
for i in range(stringcount):
|
|
@@ -331,14 +332,14 @@
|
|
if not self.styleIndices:
|
|
self._rawstylemappingtable = ""
|
|
return
|
|
- data = struct.pack("hll", self.fondClass, self.glyphTableOffset,
|
|
+ data = struct.pack(">hll", self.fondClass, self.glyphTableOffset,
|
|
self.styleMappingReserved)
|
|
|
|
self._packstylestrings()
|
|
- data = data + apply(struct.pack, ("48b",) + self.styleIndices)
|
|
+ data = data + apply(struct.pack, (">48b",) + self.styleIndices)
|
|
|
|
stringcount = len(self.styleStrings)
|
|
- data = data + struct.pack("h", stringcount)
|
|
+ data = data + struct.pack(">h", stringcount)
|
|
for string in self.styleStrings:
|
|
data = data + chr(len(string)) + string
|
|
|
|
@@ -401,7 +402,7 @@
|
|
data = self._rawstylemappingtable
|
|
if not data:
|
|
return
|
|
- data = data[:2] + struct.pack("l", self.glyphTableOffset) + data[6:]
|
|
+ data = data[:2] + struct.pack(">l", self.glyphTableOffset) + data[6:]
|
|
self._rawstylemappingtable = data
|
|
|
|
def _getglyphencodingsubtable(self):
|
|
@@ -410,7 +411,7 @@
|
|
return
|
|
offset = self.ffStylOff + self.glyphTableOffset
|
|
data = self.FOND.data
|
|
- numberofentries, = struct.unpack("h", data[offset:offset+2])
|
|
+ numberofentries, = struct.unpack(">h", data[offset:offset+2])
|
|
count = offset + 2
|
|
for i in range(numberofentries):
|
|
glyphcode = ord(data[count])
|
|
@@ -430,7 +431,7 @@
|
|
self._rawglyphencodingsubtable = ""
|
|
return
|
|
numberofentries = len(self.glyphEncoding)
|
|
- data = struct.pack("h", numberofentries)
|
|
+ data = struct.pack(">h", numberofentries)
|
|
items = self.glyphEncoding.items()
|
|
items.sort()
|
|
for glyphcode, glyphname in items:
|
|
diff -urN fonttools-20050315/Lib/fontTools/misc/psCharStrings.py fonttools-20050624/Lib/fontTools/misc/psCharStrings.py
|
|
--- fonttools-20050315/Lib/fontTools/misc/psCharStrings.py 2005-02-24 00:52:27.000000000 +0330
|
|
+++ fonttools-20050624/Lib/fontTools/misc/psCharStrings.py 2005-05-07 13:11:12.000000000 +0430
|
|
@@ -780,7 +780,8 @@
|
|
#
|
|
def op_hflex(self, index):
|
|
dx1, dx2, dy2, dx3, dx4, dx5, dx6 = self.popall()
|
|
- dy1 = dy3 = dy4 = dy5 = dy6 = 0
|
|
+ dy1 = dy3 = dy4 = dy6 = 0
|
|
+ dy5 = -dy2
|
|
self.rCurveTo((dx1, dy1), (dx2, dy2), (dx3, dy3))
|
|
self.rCurveTo((dx4, dy4), (dx5, dy5), (dx6, dy6))
|
|
def op_flex(self, index):
|
|
@@ -789,7 +790,9 @@
|
|
self.rCurveTo((dx4, dy4), (dx5, dy5), (dx6, dy6))
|
|
def op_hflex1(self, index):
|
|
dx1, dy1, dx2, dy2, dx3, dx4, dx5, dy5, dx6 = self.popall()
|
|
- dy3 = dy4 = dy6 = 0
|
|
+ dy3 = dy4 = 0
|
|
+ dy6 = -(dy1 + dy2 + dy3 + dy4 + dy5)
|
|
+
|
|
self.rCurveTo((dx1, dy1), (dx2, dy2), (dx3, dy3))
|
|
self.rCurveTo((dx4, dy4), (dx5, dy5), (dx6, dy6))
|
|
def op_flex1(self, index):
|
|
@@ -798,9 +801,9 @@
|
|
dy = dy1 + dy2 + dy3 + dy4 + dy5
|
|
if abs(dx) > abs(dy):
|
|
dx6 = d6
|
|
- dy6 = 0
|
|
+ dy6 = -dy
|
|
else:
|
|
- dx6 = 0
|
|
+ dx6 = -dx
|
|
dy6 = d6
|
|
self.rCurveTo((dx1, dy1), (dx2, dy2), (dx3, dy3))
|
|
self.rCurveTo((dx4, dy4), (dx5, dy5), (dx6, dy6))
|
|
diff -urN fonttools-20050315/Lib/fontTools/pens/basePen.py fonttools-20050624/Lib/fontTools/pens/basePen.py
|
|
--- fonttools-20050315/Lib/fontTools/pens/basePen.py 2005-03-08 13:20:55.000000000 +0330
|
|
+++ fonttools-20050624/Lib/fontTools/pens/basePen.py 2005-04-10 17:48:42.000000000 +0430
|
|
@@ -162,8 +162,11 @@
|
|
of the base glyph and draws it onto self.
|
|
"""
|
|
from fontTools.pens.transformPen import TransformPen
|
|
- glyph = self.glyphSet.get(glyphName)
|
|
- if glyph is not None:
|
|
+ try:
|
|
+ glyph = self.glyphSet[glyphName]
|
|
+ except KeyError:
|
|
+ pass
|
|
+ else:
|
|
tPen = TransformPen(self, transformation)
|
|
glyph.draw(tPen)
|
|
|