Emoji routes: Emoji.asset named in TMP's emoji fallback list as well as the global list (ruling emoji-fallback-route); EmojiCheck asserts both routes and prints the font serving each piece of a failing sequence

Keycaps and the other body-font-based sequences now collapse: 25 failures become 13. The 13 FE0F+ZWJ sequences still show three pieces. Builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-12 04:50:31 +02:00
commit aebf12e195
3 changed files with 26 additions and 18 deletions

View file

@ -9,8 +9,9 @@ using UnityEngine;
// Every single-code-point emoji of the pinned Unicode Emoji version that Twemoji draws, and the Pirates product
// names read from the shipped catalog, render through an ordinary TMP text on the game's body font with no
// missing code point, no blank glyph, ink in the emoji atlas, and each glyph served by the emoji asset or by the
// body font itself, never by a third font. TMP Settings must route emoji by exactly one entry: the global
// fallback (the emoji fallback list stays empty), so dropping that entry or re-adding the second route fails.
// body font itself, never by a third font. TMP Settings must route emoji by two named routes (operator ruling
// emoji-fallback-route): the global fallback names Emoji.asset and the emoji fallback list is exactly Emoji.asset,
// so dropping either fails.
// Run as -executeMethod EmojiCheck.Run (exit 1 on failure in batchmode, as EngineAssetCheck). Corpus:
// tools/emoji/emoji-singles.txt (from emoji-test.txt); the emoji Twemoji lacks are listed in
// tools/emoji/emoji-unsupported.txt and reported, not rendered; -emojiLimit N spreads N entries evenly for a spike.
@ -45,11 +46,11 @@ public static class EmojiCheck
return "nothing checked";
}
// One route: the global fallback names the emoji asset, and the emoji fallback list is empty.
if (TMP_Settings.emojiFallbackTextAssets != null && TMP_Settings.emojiFallbackTextAssets.Count > 0)
failures.Add("TMP Settings' emoji fallback list is not empty: a second emoji route exists (EmojiFont.Build leaves it empty).");
// Two routes (operator ruling emoji-fallback-route): the emoji fallback list is exactly Emoji.asset, and the global list below names it.
if (TMP_Settings.emojiFallbackTextAssets == null || TMP_Settings.emojiFallbackTextAssets.Count != 1 || TMP_Settings.emojiFallbackTextAssets[0] != emoji)
failures.Add("TMP Settings' emoji fallback list is not exactly Emoji.asset: FE0F-followed bases the body font draws will not reach Twemoji.");
if (TMP_Settings.fallbackFontAssets == null || !TMP_Settings.fallbackFontAssets.Contains(emoji))
failures.Add("TMP Settings' global fallback list does not name Emoji.asset: the only emoji route is gone.");
failures.Add("TMP Settings' global fallback list does not name Emoji.asset: the route for every single code point is gone.");
var unsupported = new HashSet<int>(LoadCodePoints("emoji-unsupported.txt"));
var corpus = LoadSingles().Where(cp => !unsupported.Contains(cp)).ToList();
@ -109,18 +110,23 @@ public static class EmojiCheck
text.text = string.Join(" ", slice.Select(ToText));
text.ForceMeshUpdate();
var visible = new List<int> { 0 };
var shown = new List<string> { "" };
for (var c = 0; c < text.textInfo.characterCount; c++)
{
var info = text.textInfo.characterInfo[c];
if (info.character == ' ') visible.Add(0);
else if (info.isVisible) visible[visible.Count - 1]++;
if (info.character == ' ') { visible.Add(0); shown.Add(""); }
else if (info.isVisible)
{
visible[visible.Count - 1]++;
shown[shown.Count - 1] += $" U+{(int)info.character:X}:{info.fontAsset.name}";
}
}
if (visible.Count != slice.Count) failures.Add($"sequence chunk {i}: {visible.Count} groups rendered for {slice.Count} sequences");
for (var g = 0; g < Math.Min(visible.Count, slice.Count); g++)
if (visible[g] != 1)
{
notOne++;
failures.Add($"sequence {slice[g]} rendered {visible[g]} visible characters, not one");
failures.Add($"sequence {slice[g]} rendered {visible[g]} visible characters, not one:{shown[g]}");
}
}

View file

@ -10,10 +10,11 @@ using UnityEngine.TextCore.LowLevel;
// The one writer of the emoji font asset and of TMP Settings' emoji routing. The font file is the
// output of tools/emoji/fetch_emoji_font.py; the asset is a dynamic COLOR font asset whose atlas pages
// are cache, filled on first use at runtime and cleared here. Every TMP text reaches emoji through ONE
// route, TMP Settings' global fallback list; the emoji fallback list stays empty, and no component names
// an emoji font. (Measured: the global list alone resolves every single code point; the emoji list alone
// leaves 200 text-presentation emoji unresolved. A second route could only disagree with the first.)
// are cache, filled on first use at runtime and cleared here. Every TMP text reaches emoji through TMP
// Settings alone (no component names an emoji font), by two routes that both name only Emoji.asset (operator ruling
// emoji-fallback-route): the global fallback serves every code point, including the 200 text-presentation emoji the
// emoji list alone leaves unresolved; the emoji fallback list is what TMP tries first when FE0F follows, so a keycap
// or FE0F/ZWJ sequence whose first code point the body font also draws reaches Twemoji, whose ligatures collapse it.
// Sequences (ZWJ, skin tone, flag, keycap) resolve only through the emoji font's GSUB ligatures, and TMP applies
// them per component, gated by that component's font features: EnableLigatures writes `liga` into every
// serialized TMP text and into TMP Settings (so a text created later inherits it); there is no global switch.
@ -70,15 +71,16 @@ public static class EmojiFont
// The atlas pages are cache: Build leaves them empty, the same state EmojiCheck restores.
asset.ClearFontAssetData(true);
// One route: the global fallback. It also serves text-presentation emoji (U+263A without FE0F).
TMP_Settings.emojiFallbackTextAssets = new List<TMP_Asset>();
// Two routes: the global fallback serves every code point (text-presentation emoji too, U+263A without FE0F);
// the emoji list is tried first when FE0F follows.
TMP_Settings.emojiFallbackTextAssets = new List<TMP_Asset> { asset };
TMP_Settings.fallbackFontAssets = new List<TMP_FontAsset> { asset };
TMP_Settings.defaultSpriteAsset = null;
EditorUtility.SetDirty(asset);
EditorUtility.SetDirty(TMP_Settings.instance);
AssetDatabase.SaveAssets();
message = "EmojiFont: built " + AssetPath + " and made it TMP Settings' only emoji route (the global fallback).";
message = "EmojiFont: built " + AssetPath + " and named it in both of TMP Settings' emoji routes (the global fallback and the emoji fallback list).";
return true;
}

Binary file not shown.