Merge emoji-font into master

This commit is contained in:
Meta Vens 2026-10-08 23:37:09 +02:00
commit 56f7162923
26 changed files with 2314 additions and 620 deletions

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d0603b6d5186471b96c778c3949c7ce2
guid: 5e0ef88f85924e146855ca7bb57bbdb6
folderAsset: yes
DefaultImporter:
externalObjects: {}

BIN
Assets/Fonts/Emoji/Emoji.asset (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: c41005c129ba4d66911b75229fd70b45
timeCreated: 1480316912
licenseType: Pro
guid: 4cbb1005dc560d54ba85c3d091dbe30b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,410 @@
Twemoji v17.0.3: https://github.com/jdecked/twemoji/archive/refs/tags/v17.0.3.tar.gz
Copyright (c) 2022–present Jason Sofonia & Justine De Caires
Copyright (c) 2014–2021 Twitter
Graphics licensed under CC-BY 4.0: <https://creativecommons.org/licenses/by/4.0/>
Change notice (CC BY 4.0 section 3(a)(1)(B)): the SVG graphics are converted to a COLRv0 colour
font (Twemoji.ttf) by tools/emoji/fetch_emoji_font.py using nanoemoji. No artwork is edited.
Attribution Requirements (upstream README)
As an open source project, attribution is critical from a legal, practical and motivational perspective in our opinion. The graphics are licensed under the CC-BY 4.0 which has a pretty good guide on [best practices for attribution](https://wiki.creativecommons.org/Best_practices_for_attribution).
However, we consider the guide a bit onerous and as a project, will accept a mention in a project README or an 'About' section or footer on a website. In mobile applications, a common place would be in the Settings/About section (for example, see the mobile Twitter application Settings->About->Legal section). We would consider a mention in the HTML/JS source sufficient also.
LICENSE-GRAPHICS (upstream, verbatim)
=======================================================================
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public licenses.
Notwithstanding, Creative Commons may elect to apply one of its public
licenses to material it publishes and in those instances will be
considered the "Licensor." Except for the limited purpose of indicating
that material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public
licenses.
Creative Commons may be contacted at creativecommons.org.

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 381dcb09d5029d14897e55f98031fca5
guid: db23d2e6bc295794888af02d32cbae60
TextScriptImporter:
externalObjects: {}
userData:

BIN
Assets/Fonts/Emoji/Twemoji.ttf (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: bde541f3fd3b82b4aa6aa068e4a205a7
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Aetheria Emoji
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,22 @@
source_url=https://github.com/jdecked/twemoji/archive/refs/tags/v17.0.3.tar.gz
source_version=v17.0.3
source_sha256=a0855654b633045ae2337537e77f1bb4361162f7fcd910e613eaab1d6d9c5fca
emoji_test_version=17.0
emoji_test_url=https://unicode.org/Public/17.0.0/emoji/emoji-test.txt
emoji_test_sha256=1d8a944f88d7952f7ef7c5167fef3c67995bcae24543949710231b03a201acda
svg_count=4009
single_codepoint_count=1400
unsupported_count=0
tool_nanoemoji=0.16.0
tool_fonttools=4.66.1
tool_picosvg=0.23.0
tool_ninja=1.13.2
source_date_epoch=1780352497
color_format=glyf_colr_0
python_version=3.13.15
platform=linux
container_image=python:3.13-slim
font_file=Twemoji.ttf
font_sha256=de66290bfa98226e40d8999a3ab024c2242e8d2938f939d9a85c1494844f6aa0
singles_sha256=7ad887a16ef5386df040e1e8988e9bdc55ae5cab461ffc9df4613d0cb5770b4e
unsupported_sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6290b5397f6ae1d47a19c6886ebd87e2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TMPro;
using UnityEditor;
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.
// 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.
public static class EmojiCheck
{
const string BodyFontPath = "Assets/Fonts/Ubuntu/Ubuntu-L Small SDF.asset";
const string PiratesFaction = "Pirates";
const int Chunk = 64;
[MenuItem("Aetheria/Text/Check Emoji Rendering")]
public static void Run()
{
var failures = new List<string>();
var summary = RunCheck(failures);
foreach (var failure in failures.Take(20)) Debug.LogError(failure);
Debug.Log($"EmojiCheck: {summary}; {failures.Count} failure(s).");
if (Application.isBatchMode) EditorApplication.Exit(failures.Count == 0 ? 0 : 1);
}
// Public so a scratch driver can mutate TMP Settings in memory and watch this fail; adds to failures.
public static string RunCheck(List<string> failures)
{
var emoji = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(EmojiFont.AssetPath);
var body = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(BodyFontPath);
if (emoji == null || body == null)
{
failures.Add("EmojiCheck: Emoji.asset or the body font is missing; run EmojiFont.Build first.");
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).");
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.");
var unsupported = new HashSet<int>(LoadCodePoints("emoji-unsupported.txt"));
var corpus = LoadSingles().Where(cp => !unsupported.Contains(cp)).ToList();
var missing = new HashSet<int>();
TMP_Text.MissingCharacterEventCallback onMissing = (unicode, index, source, asset, component) => missing.Add(unicode);
TMP_Text.OnMissingCharacter += onMissing;
var canvas = new GameObject("EmojiCheck", typeof(Canvas));
var text = new GameObject("Text", typeof(RectTransform)).AddComponent<TextMeshProUGUI>();
text.transform.SetParent(canvas.transform, false);
text.font = body;
text.textWrappingMode = TextWrappingModes.NoWrap;
text.rectTransform.sizeDelta = new Vector2(100000, 100000);
int viaEmoji = 0, viaBody = 0, blank = 0, pirateNames = 0;
var strays = new HashSet<string>();
try
{
void Render(string content, string label)
{
text.text = content;
text.ForceMeshUpdate();
for (var i = 0; i < text.textInfo.characterCount; i++)
{
var info = text.textInfo.characterInfo[i];
if (info.character == ' ' || info.elementType != TMP_TextElementType.Character) continue;
if (info.fontAsset == emoji) viaEmoji++;
else if (info.fontAsset == body) viaBody++;
else if (strays.Add($"{info.fontAsset.name}:{(int)info.character:X}"))
failures.Add($"U+{(int)info.character:X4} in {label} was served by {info.fontAsset.name}, not Emoji.asset or the body font");
if (info.fontAsset == emoji && info.textElement.glyph.glyphRect.width <= 0)
{
blank++;
failures.Add($"blank glyph U+{(int)info.character:X4} in {label}");
}
}
}
for (var i = 0; i < corpus.Count; i += Chunk)
{
var slice = corpus.Skip(i).Take(Chunk).ToList();
Render(string.Join(" ", slice.Select(char.ConvertFromUtf32)), $"chunk {i}");
}
// The Pirates names as the shipped catalog stores them, through the game's own catalog reader.
var catalogPath = Path.Combine(Directory.GetParent(Application.dataPath).FullName, "GameData", "Aetheria.cc");
using (var catalog = AetheriaStores.Open(catalogPath))
{
var pirates = catalog.GetAll<Faction>().SingleOrDefault(faction => faction.Name == PiratesFaction);
if (pirates == null) failures.Add($"the catalog has no {PiratesFaction} faction");
else
{
var key = catalog.RefOf(pirates);
foreach (var product in catalog.GetAll<FactionProductData>().Where(product => product.Manufacturer.Equals(key)))
{
pirateNames++;
Render(product.Name, $"Pirates product name \"{product.Name}\"");
}
if (pirateNames == 0) failures.Add($"the catalog has no {PiratesFaction} products");
}
}
}
finally
{
TMP_Text.OnMissingCharacter -= onMissing;
UnityEngine.Object.DestroyImmediate(canvas);
}
foreach (var cp in missing.OrderBy(c => c)) failures.Add($"missing code point U+{cp:X4}");
// TMP over-allocates atlasTextures by doubling its capacity when a page is added, so entries past
// atlasTextureCount are null by design (3 pages in a 4-slot array). Only the used pages count.
long ink = 0, colour = 0;
for (var i = 0; i < emoji.atlasTextureCount; i++)
{
var page = emoji.atlasTextures[i];
if (page == null) { failures.Add($"emoji atlas page {i} of {emoji.atlasTextureCount} is null"); continue; }
var pixels = page.GetPixels32();
ink += pixels.LongCount(p => p.a != 0);
colour += pixels.LongCount(p => p.a != 0 && (p.r != p.g || p.g != p.b));
}
if (ink == 0) failures.Add("the emoji atlas holds no ink after rendering");
else if (colour == 0) failures.Add("the emoji atlas holds no coloured pixel: the glyphs rendered monochrome");
var pages = emoji.atlasTextureCount;
// Dynamic atlas content is cache: drop it so this check leaves the asset as Build wrote it.
emoji.ClearFontAssetData(true);
if (unsupported.Count > 0)
Debug.LogWarning($"EmojiCheck: Twemoji lacks {unsupported.Count} single-code-point emoji of the Emoji version: " +
string.Join(" ", unsupported.OrderBy(c => c).Select(c => $"U+{c:X4}")));
return $"checked {corpus.Count} single code points ({unsupported.Count} not drawn by Twemoji, listed in the warning) + {pirateNames} Pirates product names, " +
$"{missing.Count} missing, {viaEmoji} glyphs via the emoji asset, {viaBody} via the body font, {strays.Count} via other fonts, {blank} blank, " +
$"{ink} atlas ink pixels of which {colour} coloured, {pages} atlas pages";
}
static List<int> LoadSingles()
{
var all = LoadCodePoints("emoji-singles.txt");
var args = Environment.GetCommandLineArgs();
var at = Array.IndexOf(args, "-emojiLimit");
if (at < 0 || at + 1 >= args.Length) return all;
var limit = int.Parse(args[at + 1]);
return Enumerable.Range(0, limit).Select(i => all[i * all.Count / limit]).ToList();
}
static List<int> LoadCodePoints(string file)
{
var path = Path.Combine(Directory.GetParent(Application.dataPath).FullName, "tools", "emoji", file);
return File.ReadAllLines(path).Where(l => l.Length > 0).Select(l => Convert.ToInt32(l, 16)).ToList();
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c6f940add256a754daac8460fc79480d

View file

@ -0,0 +1,77 @@
using System.Collections.Generic;
using TMPro;
using UnityEditor;
using UnityEngine;
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.)
public static class EmojiFont
{
public const string FontPath = "Assets/Fonts/Emoji/Twemoji.ttf";
public const string AssetPath = "Assets/Fonts/Emoji/Emoji.asset";
// Colour outlines (COLRv0) are rasterised at one size; 109 is the strike size a CBDT set needs.
const int SamplingPointSize = 64;
const int AtlasPadding = 4;
const int AtlasSize = 2048;
// Menu entry for interactive use; -executeMethod EmojiFont.Build for batchmode, exit 1 on failure.
[MenuItem("Aetheria/Text/Build Emoji Font")]
public static void Build()
{
var ok = TryBuild(out var message);
if (ok) Debug.Log(message); else Debug.LogError(message);
if (Application.isBatchMode) EditorApplication.Exit(ok ? 0 : 1);
}
static bool TryBuild(out string message)
{
var font = AssetDatabase.LoadAssetAtPath<Font>(FontPath);
if (font == null)
{
message = $"EmojiFont: {FontPath} is missing; run tools/emoji/fetch_emoji_font.py.";
return false;
}
// An existing asset keeps its GUID, so a second Build changes nothing the settings point at.
var asset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(AssetPath);
if (asset == null)
{
asset = TMP_FontAsset.CreateFontAsset(font, SamplingPointSize, AtlasPadding, GlyphRenderMode.COLOR,
AtlasSize, AtlasSize, AtlasPopulationMode.Dynamic, enableMultiAtlasSupport: true);
if (asset == null)
{
message = $"EmojiFont: TMP could not create a font asset from {FontPath}.";
return false;
}
asset.name = "Emoji";
AssetDatabase.CreateAsset(asset, AssetPath);
foreach (var page in asset.atlasTextures)
{
page.name = "Emoji Atlas";
AssetDatabase.AddObjectToAsset(page, asset);
}
asset.material.name = "Emoji Atlas Material";
AssetDatabase.AddObjectToAsset(asset.material, asset);
}
// 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>();
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).";
return true;
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bd3a902defe23f14fbe821ca9fb26a08

View file

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 512a49d95c0c4332bdd98131869c23c9
folderAsset: yes
timeCreated: 1441876896
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +0,0 @@
This sample of beautiful emojis are provided by EmojiOne https://www.emojione.com/
Please visit their website to view the complete set of their emojis and review their licensing terms.

View file

@ -1,156 +0,0 @@
{"frames": [
{
"filename": "1f60a.png",
"frame": {"x":0,"y":0,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f60b.png",
"frame": {"x":128,"y":0,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f60d.png",
"frame": {"x":256,"y":0,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f60e.png",
"frame": {"x":384,"y":0,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f600.png",
"frame": {"x":0,"y":128,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f601.png",
"frame": {"x":128,"y":128,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f602.png",
"frame": {"x":256,"y":128,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f603.png",
"frame": {"x":384,"y":128,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f604.png",
"frame": {"x":0,"y":256,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f605.png",
"frame": {"x":128,"y":256,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f606.png",
"frame": {"x":256,"y":256,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f609.png",
"frame": {"x":384,"y":256,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f618.png",
"frame": {"x":0,"y":384,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "1f923.png",
"frame": {"x":128,"y":384,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "263a.png",
"frame": {"x":256,"y":384,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
},
{
"filename": "2639.png",
"frame": {"x":384,"y":384,"w":128,"h":128},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":128},
"sourceSize": {"w":128,"h":128},
"pivot": {"x":0.5,"y":0.5}
}],
"meta": {
"app": "http://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "EmojiOne.png",
"format": "RGBA8888",
"size": {"w":512,"h":512},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:196a26a2e149d875b91ffc8fa3581e76:fc928c7e275404b7e0649307410475cb:424723c3774975ddb2053fd5c4b85f6e$"
}
}

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8f05276190cf498a8153f6cbe761d4e6
timeCreated: 1480316860
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/TextMesh Pro/Sprites/EmojiOne.png (Stored with Git LFS)

Binary file not shown.

View file

@ -1,431 +0,0 @@
fileFormatVersion: 2
guid: dffef66376be4fa480fb02b19edbe903
TextureImporter:
fileIDToRecycleName:
21300000: EmojiOne_0
21300002: EmojiOne_1
21300004: EmojiOne_2
21300006: EmojiOne_3
21300008: EmojiOne_4
21300010: EmojiOne_6
21300012: EmojiOne_7
21300014: EmojiOne_8
21300016: EmojiOne_9
21300018: EmojiOne_10
21300020: EmojiOne_11
21300022: EmojiOne_12
21300024: EmojiOne_13
21300026: EmojiOne_5
21300028: EmojiOne_14
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: iPhone
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 512
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: EmojiOne_0
rect:
serializedVersion: 2
x: 0
y: 384
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 4bcc36da2108f2c4ba3de5c921d25c3c
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_1
rect:
serializedVersion: 2
x: 128
y: 384
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: e9eea8093eaeaee4d901c4553f572c22
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_2
rect:
serializedVersion: 2
x: 256
y: 384
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 49451da35411dcc42a3692e39b0fde70
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_3
rect:
serializedVersion: 2
x: 384
y: 384
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: f65709664b924904790c850a50ca82bc
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_4
rect:
serializedVersion: 2
x: 0
y: 256
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 5b92c568a5ec9ad4b9ed90e271f1c9a8
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_6
rect:
serializedVersion: 2
x: 256
y: 256
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: b10f2b48b7281594bb8a24a6511a35af
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_7
rect:
serializedVersion: 2
x: 384
y: 256
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 10a600f9329dc2246a897e89f4d283cd
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_8
rect:
serializedVersion: 2
x: 0
y: 128
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 66cffa363b90ab14787d8a5b90cf4502
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_9
rect:
serializedVersion: 2
x: 128
y: 128
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 55cf3d409c9b89349b1e1bdc1cc224ad
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_10
rect:
serializedVersion: 2
x: 256
y: 128
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 2a9e58eaf96feef42bcefa1cf257193f
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_11
rect:
serializedVersion: 2
x: 384
y: 128
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 2489120affc155840ae6a7be2e93ce19
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_12
rect:
serializedVersion: 2
x: 0
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 412349a150598d14da4d7140df5c0286
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_13
rect:
serializedVersion: 2
x: 128
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: a937464b42bb3634782dea34c6becb6c
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_5
rect:
serializedVersion: 2
x: 256
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: b0f933b217682124dbfc5e6b89abe3d0
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: EmojiOne_14
rect:
serializedVersion: 2
x: 128
y: 256
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: f7235c763afe4434e8bb666750a41096
vertices: []
indices:
edges: []
weights: []
outline: []
physicsShape: []
bones: []
spriteID: 3e32d8f5477abfc43b19066e8ad5032e
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -71,6 +71,8 @@ Client-Server communication is implemented using [LiteNetLib](https://github.com
Game content lives in `GameData/Aetheria.cc`, a [CultCache](https://github.com/GameCult/CultLib) store that is read-only at runtime. Run state and player state (settings and bindings) live in their own `.cc` stores in the same cache. Persistent data types carry MessagePack attributes; some also carry [JSON.Net](https://www.newtonsoft.com/json) attributes.
Emoji are drawn from [Twemoji](https://github.com/jdecked/twemoji) v17.0.3, converted to a colour font (`Assets/Fonts/Emoji/Twemoji.ttf`, built by `tools/emoji/fetch_emoji_font.py`; the artwork itself is not edited). Copyright (c) 2022–present Jason Sofonia & Justine De Caires; copyright (c) 2014–2021 Twitter. The graphics are licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); the full notice is `Assets/Fonts/Emoji/LICENSE.txt`.
### Programming Paradigms
The codebase makes heavy use of C#'s [Language Integrated Queries (LINQ)](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/), allowing for the concise representation of operations that modify or filter collections (though they do generate some garbage so must be avoided within the update loop). Asynchronous stream processing is often performed using the [functional reactive programming](http://reactivex.io/) paradigm, which is achieved using [Microsoft's Reactive Extensions](https://github.com/dotnet/reactive) on the server and [Reactive Extensions for Unity](https://github.com/neuecc/UniRx). Combining Observables with LINQ allows for extremely powerful expressions of the programmer's intent.

File diff suppressed because it is too large Load diff

View file

View file

@ -0,0 +1,176 @@
"""Build Assets/Fonts/Emoji/Twemoji.ttf from the pinned Twemoji release.
The font reproduces ONLY inside the pinned Linux container (PINNED_IMAGE, Python PINNED_PYTHON); on any
other platform the script refuses to run and writes nothing. It does not run under `py -3` on Windows.
Run it on Yggdrasil (or any docker host) from the repository root:
docker run --rm -e EMOJI_FONT_IMAGE=python:3.13-slim -v "$PWD":/src -w /src python:3.13-slim sh -c \\
"pip install -r tools/emoji/requirements.txt && python tools/emoji/fetch_emoji_font.py [--jobs N]"
Downloads the jdecked/twemoji release source archive and Unicode's emoji-test.txt (both sha256 pinned
below), runs nanoemoji (glyf_colr_0) over the SVGs, and writes the font, the licence text, the smoke's
corpus (emoji-singles.txt, from emoji-test.txt), the list of emoji Twemoji lacks (emoji-unsupported.txt)
and emoji-font.lock. The font is the only artifact Unity consumes; nothing here is hand-made art.
A run whose font-determining pins match the lock must reproduce the font's sha256, or the script exits 1
and leaves the committed font and lock untouched; the lock never follows the machine.
"""
import argparse, hashlib, os, platform, re, shutil, subprocess, sys, tarfile, tempfile, urllib.request
from importlib import metadata
from pathlib import Path
TWEMOJI_VERSION = "v17.0.3"
TWEMOJI_URL = "https://github.com/jdecked/twemoji/archive/refs/tags/v17.0.3.tar.gz"
TWEMOJI_SHA256 = "a0855654b633045ae2337537e77f1bb4361162f7fcd910e613eaab1d6d9c5fca"
# 2026-06-01T22:21:37Z, the release's publication time: fixes head.created/modified for reproducibility.
SOURCE_DATE_EPOCH = "1780352497"
FAMILY = "Twemoji"
# Unicode's emoji-test.txt for the Emoji version Twemoji v17.0.3 targets: the smoke's corpus.
EMOJI_TEST_VERSION = "17.0"
EMOJI_TEST_URL = "https://unicode.org/Public/17.0.0/emoji/emoji-test.txt"
EMOJI_TEST_SHA256 = "1d8a944f88d7952f7ef7c5167fef3c67995bcae24543949710231b03a201acda"
# The one environment the font reproduces in. The docker command passes the image tag in; a container
# cannot read its own image name.
PINNED_PLATFORM = "linux"
PINNED_PYTHON = "3.13"
PINNED_IMAGE = "python:3.13-slim"
ROOT = Path(__file__).resolve().parents[2]
FONT_DIR = ROOT / "Assets" / "Fonts" / "Emoji"
SINGLES = ROOT / "tools" / "emoji" / "emoji-singles.txt"
UNSUPPORTED = ROOT / "tools" / "emoji" / "emoji-unsupported.txt"
def sha256(path):
h = hashlib.sha256()
with open(path, "rb") as f:
for block in iter(lambda: f.read(1 << 20), b""):
h.update(block)
return h.hexdigest()
def download(cache, url, name, pinned):
path = cache / name
if not path.exists():
cache.mkdir(parents=True, exist_ok=True)
urllib.request.urlretrieve(url, path)
got = sha256(path)
if got != pinned:
path.unlink()
sys.exit(f"{name} sha256 {got} != pinned {pinned}")
return path
def single_code_points(emoji_test):
"""Every emoji of the Emoji version that is one code point, bare or with its FE0F presentation
selector (so (c) and (r) are in), of any qualification status including components."""
found = set()
for line in emoji_test.read_text(encoding="utf-8").splitlines():
if not line or line.startswith("#"):
continue
points = [int(p, 16) for p in line.split(";", 1)[0].split() if int(p, 16) != 0xFE0F]
if len(points) == 1:
found.add(points[0])
return sorted(found)
def refuse_unless_pinned_environment():
here = (sys.platform, f"{sys.version_info.major}.{sys.version_info.minor}", os.environ.get("EMOJI_FONT_IMAGE"))
if here != (PINNED_PLATFORM, PINNED_PYTHON, PINNED_IMAGE):
sys.exit(f"refusing to run: the font reproduces only on {PINNED_PLATFORM}, Python {PINNED_PYTHON}, image "
f"{PINNED_IMAGE} (EMOJI_FONT_IMAGE); this is {here}. Nothing was written.")
def licence_text(root):
readme = (root / "README.md").read_text(encoding="utf-8")
attribution = re.search(r"## Attribution Requirements\n\n(.*?)\n\n## ", readme, re.S).group(1)
graphics = re.search(r"Graphics licensed under CC-BY 4.0: \S+", readme).group(0)
copyright_lines = [l for l in (root / "LICENSE").read_text(encoding="utf-8").splitlines() if l.startswith("Copyright")]
return (
f"Twemoji {TWEMOJI_VERSION}: {TWEMOJI_URL}\n"
+ "\n".join(copyright_lines) + "\n" + graphics + "\n\n"
"Change notice (CC BY 4.0 section 3(a)(1)(B)): the SVG graphics are converted to a COLRv0 colour\n"
"font (Twemoji.ttf) by tools/emoji/fetch_emoji_font.py using nanoemoji. No artwork is edited.\n\n"
"Attribution Requirements (upstream README)\n\n" + attribution + "\n\n"
"LICENSE-GRAPHICS (upstream, verbatim)\n"
"=======================================================================\n\n"
+ (root / "LICENSE-GRAPHICS").read_text(encoding="utf-8")
)
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--cache", type=Path, default=Path(tempfile.gettempdir()) / "aetheria-emoji-cache")
ap.add_argument("--jobs", type=int, default=max(1, min(4, (os.cpu_count() or 2) // 2)))
args = ap.parse_args()
refuse_unless_pinned_environment()
archive = download(args.cache, TWEMOJI_URL, f"twemoji-{TWEMOJI_VERSION}.tar.gz", TWEMOJI_SHA256)
emoji_test = download(args.cache, EMOJI_TEST_URL, f"emoji-test-{EMOJI_TEST_VERSION}.txt", EMOJI_TEST_SHA256)
work = args.cache / f"build-{TWEMOJI_VERSION}"
if work.exists():
shutil.rmtree(work)
work.mkdir(parents=True)
with tarfile.open(archive) as tar:
tar.extractall(work / "src", filter="data")
src = next((work / "src").iterdir())
svgs = sorted((src / "assets" / "svg").glob("*.svg"))
env = dict(os.environ, SOURCE_DATE_EPOCH=SOURCE_DATE_EPOCH)
# nanoemoji shells out to ninja and picosvg by name; they live beside this interpreter.
env["PATH"] = str(Path(sys.executable).parent) + os.pathsep + env["PATH"]
build = work / "build"
# 4000 paths overflow the Windows command line, so the inputs travel in an absl flagfile.
flagfile = work / "inputs.flags"
flagfile.write_text("".join(f"{p.as_posix()}\n" for p in svgs), encoding="utf-8")
run = [sys.executable, "-c", "from nanoemoji.nanoemoji import main; main()", "--color_format", "glyf_colr_0",
"--family", FAMILY, "--output_file", f"{FAMILY}.ttf", "--build_dir", str(build), "--noexec_ninja",
f"--flagfile={flagfile}"]
subprocess.run(run, check=True, env=env, cwd=work)
subprocess.run(["ninja", "-j", str(args.jobs), "-C", str(build)], check=True, env=env)
built = build / f"{FAMILY}.ttf"
font_sha = sha256(built)
tools = {n: metadata.version(n) for n in ("nanoemoji", "fonttools", "picosvg", "ninja")}
font_pins = {
"source_sha256": TWEMOJI_SHA256, **{f"tool_{n}": v for n, v in tools.items()},
"source_date_epoch": SOURCE_DATE_EPOCH, "color_format": "glyf_colr_0",
"python_version": platform.python_version(), "platform": PINNED_PLATFORM, "container_image": PINNED_IMAGE,
}
lock_path = FONT_DIR / "emoji-font.lock"
old = dict(l.split("=", 1) for l in lock_path.read_text().splitlines() if "=" in l) if lock_path.exists() else {}
if old and all(old.get(k) == v for k, v in font_pins.items()):
if old.get("font_sha256") != font_sha:
sys.exit(f"NOT REPRODUCED: font_sha256 {font_sha} != lock {old.get('font_sha256')} with identical pins. "
"Nothing was written.")
print("reproduced: font_sha256 equals the lock")
# The smoke's corpus is Unicode's list of single-code-point emoji, not the supplier's file names;
# what Twemoji does not draw is reported, not hidden.
drawn = {int(p.stem, 16) for p in svgs if re.fullmatch(r"[0-9a-f]+", p.stem)}
singles = single_code_points(emoji_test)
unsupported = [cp for cp in singles if cp not in drawn]
FONT_DIR.mkdir(parents=True, exist_ok=True)
out = FONT_DIR / f"{FAMILY}.ttf"
shutil.copyfile(built, out)
(FONT_DIR / "LICENSE.txt").write_text(licence_text(src), encoding="utf-8", newline="\n")
SINGLES.write_text("".join(f"{cp:X}\n" for cp in singles), encoding="utf-8", newline="\n")
UNSUPPORTED.write_text("".join(f"{cp:X}\n" for cp in unsupported), encoding="utf-8", newline="\n")
print(f"Twemoji lacks {len(unsupported)} of {len(singles)} single-code-point emoji: "
+ " ".join(f"U+{cp:04X}" for cp in unsupported))
lock = [
f"source_url={TWEMOJI_URL}", f"source_version={TWEMOJI_VERSION}", f"source_sha256={TWEMOJI_SHA256}",
f"emoji_test_version={EMOJI_TEST_VERSION}", f"emoji_test_url={EMOJI_TEST_URL}", f"emoji_test_sha256={EMOJI_TEST_SHA256}",
f"svg_count={len(svgs)}", f"single_codepoint_count={len(singles)}", f"unsupported_count={len(unsupported)}",
*(f"tool_{n}={v}" for n, v in tools.items()),
f"source_date_epoch={SOURCE_DATE_EPOCH}", "color_format=glyf_colr_0",
f"python_version={font_pins['python_version']}", f"platform={PINNED_PLATFORM}", f"container_image={PINNED_IMAGE}",
f"font_file={out.name}", f"font_sha256={font_sha}",
f"singles_sha256={sha256(SINGLES)}", f"unsupported_sha256={sha256(UNSUPPORTED)}",
]
lock_path.write_text("\n".join(lock) + "\n", encoding="utf-8", newline="\n")
print("\n".join(lock))
if __name__ == "__main__":
main()

View file

@ -0,0 +1,23 @@
# Pinned toolchain for fetch_emoji_font.py (py -3 -m venv, then pip install -r this file).
# nanoemoji is the spec's tool; the rest is its resolved dependency set at 0.16.0.
absl-py==2.5.0
attrs==26.1.0
booleanOperations==0.10.0
cffsubr==0.4.0
fontMath==0.10.0
fonttools==4.66.1
lxml==6.1.3
nanoemoji==0.16.0
ninja==1.13.2
picosvg==0.23.0
pillow==12.3.0
pngquant-cli==3.0.3
pyclipper==1.4.0
regex==2026.9.29
resvg-cli==0.44.0
skia-pathops==0.9.2
toml==0.10.2
typing_extensions==4.16.0
ufo2ft==3.9.1
ufoLib2==0.19.0
zopfli==0.4.3