diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index bea880064..14e19682f 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -18,7 +18,10 @@ def codes_to_string(codes): pieces = codes.split ("_") string = "".join ([unichr (int (code, 16)) for code in pieces]) else: + try: string = unichr (int (codes, 16)) + except: + raise ValueError("uh-oh, no unichr for '%s'" % codes) return string @@ -145,13 +148,13 @@ def add_lig_sequence(ligatures, seq, n): rev_seq.reverse() trseq = tuple(rev_seq) if trseq in ligatures: - print 'rev lig sequence %s, replace %s with %s' % ( - trseq, ligatures[trseq], n) + # print 'rev lig sequence %s, replace %s with %s' % ( + # trseq, ligatures[trseq], n) ligatures[trseq] = n for (u, filename) in img_pairs: - print "Adding glyph for U+%s" % ",".join (["%04X" % ord (char) for char in u]) + # print "Adding glyph for U+%s" % ",".join (["%04X" % ord (char) for char in u]) n = glyph_name (u) glyph_names.add(n) @@ -185,13 +188,14 @@ for k, v in ligatures.iteritems(): for base in sorted(keyed_ligatures): pairs = keyed_ligatures[base] - print 'base %s has %d sequences' % (base, len(pairs)) + # print 'base %s has %d sequences' % (base, len(pairs)) + # Sort longest first, this ensures longer sequences with common prefixes # are handled before shorter ones. It would be better to have multiple # lookups, most likely. pairs.sort(key = lambda pair: (len(pair[0]), pair[0]), reverse=True) for seq, name in pairs: - print seq, name + # print seq, name add_ligature(font, seq, name) font.saveXML (out_file) diff --git a/third_party/color_emoji/emoji_builder.py b/third_party/color_emoji/emoji_builder.py index 0092b0751..fa9f4115c 100644 --- a/third_party/color_emoji/emoji_builder.py +++ b/third_party/color_emoji/emoji_builder.py @@ -84,7 +84,7 @@ class CBDT: write_func = self.image_write_func (image_format) for glyph in glyphs: img_file = glyph_filenames[glyph] - print 'writing data for glyph %s' % path.basename(img_file) + # print 'writing data for glyph %s' % path.basename(img_file) offset = self.tell () write_func (PNG (img_file)) self.glyph_maps.append (GlyphMap (glyph, offset, image_format)) @@ -113,7 +113,7 @@ class CBDT: if y_bearing == 128: y_bearing = 127 advance = width - print "small glyph metrics h: %d w: %d" % (height, width) + # print "small glyph metrics h: %d w: %d" % (height, width) # smallGlyphMetrics # Type Name # BYTE height @@ -488,7 +488,8 @@ By default they are dropped. glyph_imgs[glyph_id] = img_file if "verbose" in options: uchars_name = ",".join (["%04X" % ord (char) for char in uchars]) - print "Matched U+%s: id=%d name=%s image=%s" % (uchars_name, glyph_id, glyph_name, img_file) + # print "Matched U+%s: id=%d name=%s image=%s" % ( + # uchars_name, glyph_id, glyph_name, img_file) advance += glyph_metrics[glyph_name][0] w, h = PNG (img_file).get_size ()