updates to support tr51 emoji sequences

This commit is contained in:
Doug Felt 2015-11-05 11:15:15 -08:00
parent 7206289643
commit d9e320acb5
3 changed files with 48 additions and 12 deletions

View file

@ -92,6 +92,8 @@ endif
%.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(UNI) $(PNG128_FLAGS) %.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(UNI) $(PNG128_FLAGS)
python $(ADD_GLYPHS) "$<" "$@" "$(EMOJI_PNG128)" python $(ADD_GLYPHS) "$<" "$@" "$(EMOJI_PNG128)"
%.ttf: %.ttx %.ttf: %.ttx
@rm -f "$@" @rm -f "$@"
ttx "$<" ttx "$<"

View file

@ -10,11 +10,11 @@ from os import path
import re import re
import shutil import shutil
DST = "/tmp/placeholder_emoji_plus" DST = '/tmp/placeholder_emoji_plus'
SRC_PLACEHOLDER = "/tmp/placeholder_emoji" SRC_PLACEHOLDER = '/usr/local/google/users/dougfelt/emoji_images/placeholder'
SRC_NOTO = "/usr/local/google/users/dougfelt/newnoto/noto-emoji/png/128" SRC_NOTO = '/usr/local/google/users/dougfelt/newnoto/noto-emoji/png/128'
SRC_DRAFT = "/usr/local/google/home/dougfelt/Downloads/PNG_latest_working_draft" SRC_DRAFT = '/usr/local/google/users/dougfelt/emoji_images/png_thurs'
# First, scan the draft images and select which ones to use. This does # First, scan the draft images and select which ones to use. This does
# two things: # two things:
@ -29,6 +29,10 @@ FIXED_NAMES = {}
VAR_PAT = re.compile(r'(.*?)\((\d+)\)\.png') VAR_PAT = re.compile(r'(.*?)\((\d+)\)\.png')
for fname in glob.glob(path.join(SRC_DRAFT, '*.png')): for fname in glob.glob(path.join(SRC_DRAFT, '*.png')):
name = path.basename(fname) name = path.basename(fname)
if 'alt' in name:
print 'skip %s' % name
continue
m = VAR_PAT.match(name) m = VAR_PAT.match(name)
if m: if m:
name = '%s.png' % m.group(1).lower() name = '%s.png' % m.group(1).lower()
@ -47,22 +51,49 @@ for name in UPDATED_NAMES:
print 'using updated image %s for %s' % (fname, name) print 'using updated image %s for %s' % (fname, name)
FIXED_NAMES[name] = fname FIXED_NAMES[name] = fname
EXCLUDE_PAT = re.compile(r'emoji_u1f3f[bcdef].png')
remove = [name for name in FIXED_NAMES if EXCLUDE_PAT.match(name)]
for name in remove:
print 'removing %s' % name
del FIXED_NAMES[name]
# Now, recreate the destination directory and copy the data into it. # Now, recreate the destination directory and copy the data into it.
if path.isdir(DST): if path.isdir(DST):
shutil.rmtree(DST) shutil.rmtree(DST)
os.makedirs(DST) os.makedirs(DST)
SKIP_PLACEHOLDERS = frozenset([ def flag_emoji_name(flag_ascii):
return 'emoji_u%s.png' % '_'.join(
'%04x' % (ord(cp) - ord('A') + 0x1f1e6) for cp in flag_ascii)
SKIP_FLAGS = [flag_emoji_name(name) for name in [
'AC', 'AQ', 'BL', 'BQ', 'BV', 'CP', 'DG', 'EA', 'EH', 'FK',
'GF', 'GP', 'GS', 'HM', 'IC', 'MF', 'MQ', 'NC', 'PM', 'RE',
'SH', 'SJ', 'TA', 'TF', 'UM', 'WF', 'XK', 'YT',
]]
def emoji_name(val):
return 'emoji_u%04x.png' % val
SKIP_SWATCHES = [emoji_name(val) for val in range(0x1f3fb, 0x1f3ff + 1)]
# these are placeholders for emoji that have a single codepoint yet
# also have a decomposition.
# we want to use the image for the single codepoint.
SKIP_SINGLE_CP_EMOJI = [
'emoji_u1f468_200d_1f469_200d_1f466.png', 'emoji_u1f468_200d_1f469_200d_1f466.png',
'emoji_u1f469_200d_2764_fe0f_200d_1f468.png', 'emoji_u1f469_200d_2764_fe0f_200d_1f468.png',
'emoji_u1f469_200d_2764_fe0f_200d_1f48b_200d_1f468.png', 'emoji_u1f469_200d_2764_fe0f_200d_1f48b_200d_1f468.png',
]) ]
for fname in glob.glob(path.join(SRC_PLACEHOLDER, '*.png')): SKIP_PLACEHOLDERS = frozenset(SKIP_FLAGS + SKIP_SWATCHES + SKIP_SINGLE_CP_EMOJI)
for fname in sorted(glob.glob(path.join(SRC_PLACEHOLDER, '*.png'))):
basename = path.basename(fname) basename = path.basename(fname)
if basename in SKIP_PLACEHOLDERS: if basename in SKIP_PLACEHOLDERS:
print 'skip %s' % basename print 'skip placeholder %s' % basename
continue continue
shutil.copy(fname, DST) shutil.copy(fname, DST)

View file

@ -109,8 +109,11 @@ class CBDT:
line_height = (ascent + descent) * y_ppem / float (upem) line_height = (ascent + descent) * y_ppem / float (upem)
line_ascent = ascent * y_ppem / float (upem) line_ascent = ascent * y_ppem / float (upem)
y_bearing = int (round (line_ascent - .5 * (line_height - height))) y_bearing = int (round (line_ascent - .5 * (line_height - height)))
# fudge y_bearing if calculations are a bit off
if y_bearing == 128:
y_bearing = 127
advance = width advance = width
print "small glyph metrics h: %d w: %d a: %d" % (height, width, advance) print "small glyph metrics h: %d w: %d" % (height, width)
# smallGlyphMetrics # smallGlyphMetrics
# Type Name # Type Name
# BYTE height # BYTE height
@ -123,9 +126,9 @@ class CBDT:
height, width, height, width,
x_bearing, y_bearing, x_bearing, y_bearing,
advance)) advance))
except: except Exception as e:
raise ValueError("h: %d w: %d a: %d x: %d y: 5d" % ( raise ValueError("%s, h: %d w: %d x: %d y: %d %d a:" % (
height, width, advance, x_braring, y_bearing)) e, height, width, x_bearing, y_bearing, advance))
def write_format1 (self, png): def write_format1 (self, png):