Skip to content

Commit db7ae18

Browse files
committed
Consolidate watch face fonts to 2 hours per font file with pure BMP East Asian fullwidth ideographs
1 parent 2ad0b5c commit db7ae18

5 files changed

Lines changed: 477 additions & 179 deletions

File tree

wear-watchface-wff-resources/build.gradle.kts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,23 @@ private data class ConsolidatedHourGroup(
108108
)
109109

110110
private val consolidatedHourGroups = listOf(
111-
ConsolidatedHourGroup("hours_00_02", listOf("00", "01", "02")),
112-
ConsolidatedHourGroup("hours_03_05", listOf("03", "04", "05")),
113-
ConsolidatedHourGroup("hours_06_08", listOf("06", "07", "08")),
114-
ConsolidatedHourGroup("hours_09_11", listOf("09", "10", "11")),
115-
ConsolidatedHourGroup("hours_12_14", listOf("12", "13", "14")),
116-
ConsolidatedHourGroup("hours_15_17", listOf("15", "16", "17")),
117-
ConsolidatedHourGroup("hours_18_20", listOf("18", "19", "20")),
118-
ConsolidatedHourGroup("hours_21_23", listOf("21", "22", "23")),
119-
ConsolidatedHourGroup("hours_1_3", listOf("_1", "_2", "_3")),
120-
ConsolidatedHourGroup("hours_4_6", listOf("_4", "_5", "_6")),
121-
ConsolidatedHourGroup("hours_7_9", listOf("_7", "_8", "_9")),
111+
ConsolidatedHourGroup("hours_00_01", listOf("00", "01")),
112+
ConsolidatedHourGroup("hours_02_03", listOf("02", "03")),
113+
ConsolidatedHourGroup("hours_04_05", listOf("04", "05")),
114+
ConsolidatedHourGroup("hours_06_07", listOf("06", "07")),
115+
ConsolidatedHourGroup("hours_08_09", listOf("08", "09")),
116+
ConsolidatedHourGroup("hours_10_11", listOf("10", "11")),
117+
ConsolidatedHourGroup("hours_12_13", listOf("12", "13")),
118+
ConsolidatedHourGroup("hours_14_15", listOf("14", "15")),
119+
ConsolidatedHourGroup("hours_16_17", listOf("16", "17")),
120+
ConsolidatedHourGroup("hours_18_19", listOf("18", "19")),
121+
ConsolidatedHourGroup("hours_20_21", listOf("20", "21")),
122+
ConsolidatedHourGroup("hours_22_23", listOf("22", "23")),
123+
ConsolidatedHourGroup("hours_1_2", listOf("_1", "_2")),
124+
ConsolidatedHourGroup("hours_3_4", listOf("_3", "_4")),
125+
ConsolidatedHourGroup("hours_5_6", listOf("_5", "_6")),
126+
ConsolidatedHourGroup("hours_7_8", listOf("_7", "_8")),
127+
ConsolidatedHourGroup("hours_9", listOf("_9")),
122128
)
123129

124130
androidComponents {

wear-watchface-wff-resources/scripts/build_consolidated_hour_otf.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,20 @@
4343
MAX_SUBROUTINES_PER_FONT = 1239
4444

4545

46-
def get_safe_bmp_codepoints():
46+
def get_safe_codepoints():
4747
"""
48-
Generates 54,000 safe East Asian Fullwidth/ideographic BMP codepoints:
48+
Generates 36,000 pure East Asian Fullwidth (W) ideographs in the BMP (Plane 0):
4949
- Hour 0: CJK Unified Ideographs (0x4E00..0x944F, 18,000 characters)
5050
- Hour 1: Hangul Syllables + CJK Ext A + Yi (0xAC00.., 18,000 characters)
51-
- Hour 2: PUA + Remaining CJK + Non-combining LTR BMP (18,000 characters)
51+
Every character is 100% fullwidth square cell, strictly LTR, non-combining,
52+
and natively supported by Android's Format 4 BMP cmap.
5253
"""
5354
h0 = list(range(0x4E00, 0x4E00 + 18000))
5455
h1 = (list(range(0xAC00, 0xD7A4)) + list(range(0x3400, 0x4DC0)) + list(range(0xA000, 0xA490)))[:18000]
56+
return h0 + h1
5557

56-
h2_filtered = []
57-
for cp in list(range(0x0100, 0x0590)) + list(range(0x0900, 0xD800)) + list(range(0xE000, 0xFFFD)):
58-
c = chr(cp)
59-
cat = unicodedata.category(c)
60-
bidi = unicodedata.bidirectional(c)
61-
if cat in ("Mn", "Mc", "Me", "Cf", "Cc", "Cs", "Zl", "Zp", "Zs"):
62-
continue
63-
if bidi not in ("L", "ON", "EN"):
64-
continue
65-
if c in ("<", ">", "&", '"', "'"):
66-
continue
67-
if cp not in h0 and cp not in h1 and cp not in h2_filtered:
68-
h2_filtered.append(cp)
69-
h2 = h2_filtered[:18000]
70-
return h0 + h1 + h2
7158

72-
73-
SAFE_BMP_CODEPOINTS = get_safe_bmp_codepoints()
59+
SAFE_CODEPOINTS = get_safe_codepoints()
7460

7561

7662
def parse_minute_data(file_path: str):
@@ -197,7 +183,7 @@ def build_consolidated_font(
197183
for gen in range(GENERATIONS_PER_MINUTE):
198184
canonical_idx = gen_map[gen]
199185
glyph_name = f"c_{hour_prefix}_{minute:02d}_{canonical_idx}"
200-
cmap[SAFE_BMP_CODEPOINTS[base_frame_idx + gen]] = glyph_name
186+
cmap[SAFE_CODEPOINTS[base_frame_idx + gen]] = glyph_name
201187

202188
for canonical_idx, instances in glyph_instances.items():
203189
glyph_name = f"c_{hour_prefix}_{minute:02d}_{canonical_idx}"

wear-watchface-wff-version-1/src/main/res/raw/watchface.xml

Lines changed: 203 additions & 53 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)