updates to support tr51 emoji sequences
parent
7206289643
commit
d9e320acb5
2
Makefile
2
Makefile
|
@ -92,6 +92,8 @@ endif
|
|||
%.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(UNI) $(PNG128_FLAGS)
|
||||
python $(ADD_GLYPHS) "$<" "$@" "$(EMOJI_PNG128)"
|
||||
|
||||
|
||||
|
||||
%.ttf: %.ttx
|
||||
@rm -f "$@"
|
||||
ttx "$<"
|
||||
|
|
|
@ -10,11 +10,11 @@ from os import path
|
|||
import re
|
||||
import shutil
|
||||
|
||||
DST = "/tmp/placeholder_emoji_plus"
|
||||
DST = '/tmp/placeholder_emoji_plus'
|
||||
|
||||
SRC_PLACEHOLDER = "/tmp/placeholder_emoji"
|
||||
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_PLACEHOLDER = '/usr/local/google/users/dougfelt/emoji_images/placeholder'
|
||||
SRC_NOTO = '/usr/local/google/users/dougfelt/newnoto/noto-emoji/png/128'
|
||||
SRC_DRAFT = '/usr/local/google/users/dougfelt/emoji_images/png_thurs'
|
||||
|
||||
# First, scan the draft images and select which ones to use. This does
|
||||
# two things:
|
||||
|
@ -29,6 +29,10 @@ FIXED_NAMES = {}
|
|||
VAR_PAT = re.compile(r'(.*?)\((\d+)\)\.png')
|
||||
for fname in glob.glob(path.join(SRC_DRAFT, '*.png')):
|
||||
name = path.basename(fname)
|
||||
if 'alt' in name:
|
||||
print 'skip %s' % name
|
||||
continue
|
||||
|
||||
m = VAR_PAT.match(name)
|
||||
if m:
|
||||
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)
|
||||
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.
|
||||
|
||||
if path.isdir(DST):
|
||||
shutil.rmtree(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_u1f469_200d_2764_fe0f_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)
|
||||
if basename in SKIP_PLACEHOLDERS:
|
||||
print 'skip %s' % basename
|
||||
print 'skip placeholder %s' % basename
|
||||
continue
|
||||
shutil.copy(fname, DST)
|
||||
|
||||
|
|
|
@ -109,8 +109,11 @@ class CBDT:
|
|||
line_height = (ascent + descent) * y_ppem / float (upem)
|
||||
line_ascent = ascent * y_ppem / float (upem)
|
||||
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
|
||||
print "small glyph metrics h: %d w: %d a: %d" % (height, width, advance)
|
||||
print "small glyph metrics h: %d w: %d" % (height, width)
|
||||
# smallGlyphMetrics
|
||||
# Type Name
|
||||
# BYTE height
|
||||
|
@ -123,9 +126,9 @@ class CBDT:
|
|||
height, width,
|
||||
x_bearing, y_bearing,
|
||||
advance))
|
||||
except:
|
||||
raise ValueError("h: %d w: %d a: %d x: %d y: 5d" % (
|
||||
height, width, advance, x_braring, y_bearing))
|
||||
except Exception as e:
|
||||
raise ValueError("%s, h: %d w: %d x: %d y: %d %d a:" % (
|
||||
e, height, width, x_bearing, y_bearing, advance))
|
||||
|
||||
def write_format1 (self, png):
|
||||
|
||||
|
|
Loading…
Reference in New Issue