From 22dcb9e6f9a9d087e87cece6caca6aa5d92f4d91 Mon Sep 17 00:00:00 2001 From: jvr Date: Fri, 10 May 2002 19:03:34 +0000 Subject: [PATCH] a few cosmetic/style changes git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@206 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/__init__.py | 6 ++---- Lib/fontTools/ttLib/tables/O_S_2f_2.py | 4 +++- Lib/fontTools/ttLib/tables/_c_m_a_p.py | 7 ++++--- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 13 +++++++------ Lib/fontTools/ttLib/tables/_k_e_r_n.py | 3 ++- Lib/fontTools/ttLib/tables/_p_o_s_t.py | 5 +++-- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py index 514622c3d..174411cfb 100644 --- a/Lib/fontTools/ttLib/__init__.py +++ b/Lib/fontTools/ttLib/__init__.py @@ -42,7 +42,7 @@ Dumping 'prep' table... """ # -# $Id: __init__.py,v 1.22 2002-05-05 11:29:33 jvr Exp $ +# $Id: __init__.py,v 1.23 2002-05-10 19:03:34 jvr Exp $ # import os @@ -221,9 +221,7 @@ class TTFont: else: writer.begintag(xmltag) writer.newline() - if tag == "glyf": - table.toXML(writer, self, progress) - elif tag == "CFF ": + if tag in ("glyf", "CFF "): table.toXML(writer, self, progress) else: table.toXML(writer, self) diff --git a/Lib/fontTools/ttLib/tables/O_S_2f_2.py b/Lib/fontTools/ttLib/tables/O_S_2f_2.py index ea7112cb7..eb09d2873 100644 --- a/Lib/fontTools/ttLib/tables/O_S_2f_2.py +++ b/Lib/fontTools/ttLib/tables/O_S_2f_2.py @@ -1,6 +1,8 @@ import DefaultTable import sstruct from fontTools.misc.textTools import safeEval, num2binary, binary2num +from types import TupleType + # panose classification @@ -152,7 +154,7 @@ class table_O_S_2f_2(DefaultTable.DefaultTable): if name == "panose": self.panose = panose = Panose() for element in content: - if type(element) == type(()): + if type(element) == TupleType: panose.fromXML(element, ttFont) elif name in ("ulUnicodeRange1", "ulUnicodeRange2", "ulUnicodeRange3", "ulUnicodeRange4", diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index c6d237e15..285d36fea 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -4,6 +4,7 @@ import string import array from fontTools import ttLib from fontTools.misc.textTools import safeEval, readHex +from types import TupleType class table__c_m_a_p(DefaultTable.DefaultTable): @@ -153,7 +154,7 @@ class cmap_format_0(CmapSubtable): self.version = safeEval(attrs["version"]) self.cmap = {} for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element if name <> "map": @@ -307,7 +308,7 @@ class cmap_format_4(CmapSubtable): self.version = safeEval(attrs["version"]) self.cmap = {} for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element if name <> "map": @@ -372,7 +373,7 @@ class cmap_format_6(CmapSubtable): self.version = safeEval(attrs["version"]) self.cmap = {} for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element if name <> "map": diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index daa4e2638..b34361b99 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -21,7 +21,8 @@ from fontTools.misc.textTools import safeEval, readHex import ttProgram import array import Numeric -import types +from types import StringType, TupleType + class table__g_l_y_f(DefaultTable.DefaultTable): @@ -105,7 +106,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable): if name == "GlyphOrder": glyphOrder = [] for element in content: - if type(element) == types.StringType: + if type(element) <> TupleType: continue name, attrs, content = element if name == "GlyphID": @@ -125,7 +126,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable): setattr(glyph, attr, safeEval(attrs.get(attr, '0'))) self.glyphs[glyphName] = glyph for element in content: - if type(element) == types.StringType: + if type(element) <> TupleType: continue glyph.fromXML(element, ttFont) if not ttFont.recalcBBoxes: @@ -281,7 +282,7 @@ class Glyph: coordinates = [] flags = [] for element in content: - if type(element) == types.StringType: + if type(element) <> TupleType: continue name, attrs, content = element if name <> "pt": @@ -310,7 +311,7 @@ class Glyph: elif name == "instructions": self.program = ttProgram.Program() for element in content: - if type(element) == types.StringType: + if type(element) <> TupleType: continue self.program.fromXML(element, ttFont) @@ -801,7 +802,7 @@ class GlyphComponent: def reprflag(flag): bin = "" - if type(flag) == types.StringType: + if type(flag) == StringType: flag = ord(flag) while flag: if flag & 0x01: diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py index 9b83f102c..494fec9bf 100644 --- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py +++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py @@ -2,6 +2,7 @@ import DefaultTable import struct from fontTools.ttLib import sfnt from fontTools.misc.textTools import safeEval, readHex +from types import TupleType class table__k_e_r_n(DefaultTable.DefaultTable): @@ -125,7 +126,7 @@ class KernTable_format_0: if not hasattr(self, "kernTable"): self.kernTable = {} for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element self.kernTable[(attrs["l"], attrs["r"])] = safeEval(attrs["v"]) diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py index 32fccb910..9cc75af20 100644 --- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py +++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py @@ -4,6 +4,7 @@ import struct, sstruct import array from fontTools import ttLib from fontTools.misc.textTools import safeEval, readHex +from types import TupleType postFormat = """ @@ -192,7 +193,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable): elif name == "psNames": self.mapping = {} for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element if name == "psName": @@ -200,7 +201,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable): elif name == "extraNames": self.extraNames = [] for element in content: - if type(element) <> type(()): + if type(element) <> TupleType: continue name, attrs, content = element if name == "psName":