From 3922000b6cfa65bd79a8cd6a3f38252c02390e07 Mon Sep 17 00:00:00 2001 From: Parag Nemade Date: Mar 07 2016 06:32:22 +0000 Subject: Resolves:rh#1240265- fonttools 2.5 takes too much memory --- diff --git a/0001-EBLC-Decompile-and-release-copies-of-data-early.patch b/0001-EBLC-Decompile-and-release-copies-of-data-early.patch new file mode 100644 index 0000000..dc06a95 --- /dev/null +++ b/0001-EBLC-Decompile-and-release-copies-of-data-early.patch @@ -0,0 +1,103 @@ +diff -urN fonttools-3.0/Lib/fontTools/ttLib/tables/E_B_L_C_.py fonttools-3.0.new/Lib/fontTools/ttLib/tables/E_B_L_C_.py +--- fonttools-3.0/Lib/fontTools/ttLib/tables/E_B_L_C_.py 2015-08-31 23:27:15.000000000 +0530 ++++ fonttools-3.0.new/Lib/fontTools/ttLib/tables/E_B_L_C_.py 2016-03-06 14:03:58.406847533 +0530 +@@ -71,44 +71,46 @@ + + # Save the original data because offsets are from the start of the table. + origData = data ++ i=0 + +- dummy, data = sstruct.unpack2(eblcHeaderFormat, data, self) +- ++ dummy = sstruct.unpack(eblcHeaderFormat, data[:8], self) ++ i += 8 + self.strikes = [] + for curStrikeIndex in range(self.numSizes): + curStrike = Strike() + self.strikes.append(curStrike) + curTable = curStrike.bitmapSizeTable +- dummy, data = sstruct.unpack2(bitmapSizeTableFormatPart1, data, curTable) ++ dummy = sstruct.unpack2(bitmapSizeTableFormatPart1, data[i:i+16], curTable) ++ i += 16 + for metric in ('hori', 'vert'): + metricObj = SbitLineMetrics() + vars(curTable)[metric] = metricObj +- dummy, data = sstruct.unpack2(sbitLineMetricsFormat, data, metricObj) +- dummy, data = sstruct.unpack2(bitmapSizeTableFormatPart2, data, curTable) ++ dummy = sstruct.unpack2(sbitLineMetricsFormat, data[i:i+12], metricObj) ++ i += 12 ++ dummy = sstruct.unpack(bitmapSizeTableFormatPart2, data[i:i+8], curTable) ++ i += 8 + + for curStrike in self.strikes: + curTable = curStrike.bitmapSizeTable + for subtableIndex in range(curTable.numberOfIndexSubTables): +- lowerBound = curTable.indexSubTableArrayOffset + subtableIndex * indexSubTableArraySize +- upperBound = lowerBound + indexSubTableArraySize +- data = origData[lowerBound:upperBound] ++ i = curTable.indexSubTableArrayOffset + subtableIndex * indexSubTableArraySize + +- tup = struct.unpack(indexSubTableArrayFormat, data) ++ tup = struct.unpack(indexSubTableArrayFormat, data[i:i+indexSubTableArraySize]) + (firstGlyphIndex, lastGlyphIndex, additionalOffsetToIndexSubtable) = tup +- offsetToIndexSubTable = curTable.indexSubTableArrayOffset + additionalOffsetToIndexSubtable +- data = origData[offsetToIndexSubTable:] ++ i = curTable.indexSubTableArrayOffset + additionalOffsetToIndexSubtable + +- tup = struct.unpack(indexSubHeaderFormat, data[:indexSubHeaderSize]) ++ tup = struct.unpack(indexSubHeaderFormat, data[i:i+indexSubHeaderSize]) + (indexFormat, imageFormat, imageDataOffset) = tup + + indexFormatClass = self.getIndexFormatClass(indexFormat) +- indexSubTable = indexFormatClass(data[indexSubHeaderSize:], ttFont) ++ indexSubTable = indexFormatClass(data[i+indexSubHeaderSize:], ttFont) + indexSubTable.firstGlyphIndex = firstGlyphIndex + indexSubTable.lastGlyphIndex = lastGlyphIndex + indexSubTable.additionalOffsetToIndexSubtable = additionalOffsetToIndexSubtable + indexSubTable.indexFormat = indexFormat + indexSubTable.imageFormat = imageFormat + indexSubTable.imageDataOffset = imageDataOffset ++ indexSubTable.decompile() # https://github.com/behdad/fonttools/issues/317 + curStrike.indexSubTables.append(indexSubTable) + + def compile(self, ttFont): +@@ -336,7 +338,6 @@ + if not hasattr(self, "data"): + raise AttributeError(attr) + self.decompile() +- del self.data, self.ttFont + return getattr(self, attr) + + # This method just takes care of the indexSubHeader. Implementing subclasses +@@ -439,6 +440,7 @@ + + self.names = list(map(self.ttFont.getGlyphName, glyphIds)) + self.removeSkipGlyphs() ++ del self.data, self.ttFont + + def compile(self, ttFont): + # First make sure that all the data lines up properly. Formats 1 and 3 +@@ -525,6 +527,7 @@ + offsets = [self.imageSize * i + self.imageDataOffset for i in range(len(glyphIds)+1)] + self.locations = list(zip(offsets, offsets[1:])) + self.names = list(map(self.ttFont.getGlyphName, glyphIds)) ++ del self.data, self.ttFont + + def compile(self, ttFont): + glyphIds = list(map(ttFont.getGlyphID, self.names)) +@@ -556,6 +559,7 @@ + offsets = [offset + self.imageDataOffset for offset in offsets] + self.locations = list(zip(offsets, offsets[1:])) + self.names = list(map(self.ttFont.getGlyphName, glyphIds)) ++ del self.data, self.ttFont + + def compile(self, ttFont): + # First make sure that all the data lines up properly. Format 4 +@@ -594,6 +598,7 @@ + offsets = [self.imageSize * i + self.imageDataOffset for i in range(len(glyphIds)+1)] + self.locations = list(zip(offsets, offsets[1:])) + self.names = list(map(self.ttFont.getGlyphName, glyphIds)) ++ del self.data, self.ttFont + + def compile(self, ttFont): + self.imageDataOffset = min(zip(*self.locations)[0]) diff --git a/fonttools.spec b/fonttools.spec index 9b6c0b5..d33b9ba 100644 --- a/fonttools.spec +++ b/fonttools.spec @@ -2,11 +2,12 @@ Name: fonttools Version: 3.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A tool to convert True/OpenType fonts to XML and back License: BSD URL: https://github.com/behdad/%{name}/ Source0: https://github.com/behdad/%{name}/archive/%{gittag0}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: 0001-EBLC-Decompile-and-release-copies-of-data-early.patch Requires: python3-fonttools BuildArch: noarch @@ -46,6 +47,7 @@ TrueType and OpenType fonts to an XML-based text format and vice versa. %prep %setup -qc +%patch0 -p0 pushd %{name}-%{version} mv LICENSE.txt Doc/documentation.html Doc/changes.txt ../ popd @@ -97,6 +99,9 @@ popd %{python3_sitelib}/FontTools %changelog +* Sun Mar 06 2016 Parag Nemade - 3.0-4 +- Resolves:rh#1240265- fonttools 2.5 takes too much memory + * Wed Feb 03 2016 Fedora Release Engineering - 3.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild