An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support Unicode 17 emoji https://github.com/siyuan-note/siyuan/issues/19612
Daniel360b5de945ee
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex e37da9624c..1aab6f3994 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -76,6 +76,7 @@ The component list is informational and does not replace the license terms. Copy| theSVG | Snapshot aa0605996b4ad4fdda98502f84021b3c3a64847d | MIT | [upstream](https://github.com/glincker/thesvg) | Volcengine logo in app/stage/images/ai-providers/ || AI provider brand assets | Bundled snapshots | Upstream brand and trademark terms | [upstream](https://github.com/siyuan-note/siyuan/blob/master/app/stage/images/ai-providers/README.md) | OpenAI, Zhipu AI, SiliconFlow, and other provider marks; exact sources and terms are recorded below || Unicode CLDR emoji annotations | Bundled snapshot | Unicode-3.0 | [upstream](https://github.com/unicode-org/cldr) | Localized names and search keywords in app/appearance/emojis/conf.json |+| Unicode Emoji test data | 17.0 | Unicode-3.0 | [upstream](https://www.unicode.org/Public/17.0.0/emoji/emoji-test.txt) | New fully-qualified sequences in app/tests/fixtures/unicode17-emoji.json || Pexels cover photos | 72 selected photographs | Pexels License | [upstream](https://www.pexels.com/license/) | app/appearance/covers/; photographer and source attribution is recorded below || Microsoft Edge Demos PWA service worker example | Bundled adaptation | MIT | [upstream](https://github.com/MicrosoftEdge/Demos/tree/main/pwamp) | app/stage/service-worker.js |@@ -87,7 +88,8 @@ Minified files that contain their own bundled-license blocks retain those blocks|---|---|---|---|---|| JetBrains Mono | 2.304 | OFL-1.1 | [upstream](https://github.com/JetBrains/JetBrainsMono) | app/appearance/fonts/JetBrainsMono-2.304/LICENSE || LXGW WenKai Lite | 1.501 | OFL-1.1 | [upstream](https://github.com/lxgw/LxgwWenKai-Lite) | app/appearance/fonts/LxgwWenKai-Lite-1.501/LICENSE |-| Noto COLRv1 Emoji | 2.047 | OFL-1.1 | [upstream](https://github.com/googlefonts/noto-emoji) | app/appearance/fonts/Noto-COLRv1-2.047/LICENSE |+| Noto COLRv1 Emoji | 2.051 | OFL-1.1 | [upstream](https://github.com/googlefonts/noto-emoji) | app/appearance/fonts/Noto-COLRv1-2.051/LICENSE |+| Noto COLRv1 Emoji (retained version) | 2.047 | OFL-1.1 | [upstream](https://github.com/googlefonts/noto-emoji) | app/appearance/fonts/Noto-COLRv1-2.047/LICENSE |## Go standard library and runtime@@ -1891,6 +1893,103 @@ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROMOTHER DEALINGS IN THE FONT SOFTWARE.```+### app/appearance/fonts/Noto-COLRv1-2.051/LICENSE++```text+This Font Software is licensed under the SIL Open Font License,+Version 1.1.++This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font+creation efforts of academic and linguistic communities, and to+provide a free and open framework in which fonts may be shared and+improved in partnership with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply to+any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software+components as distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to,+deleting, or substituting -- in part or in whole -- any of the+components of the Original Version, by changing formats or by porting+the Font Software to a new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed,+modify, redistribute, and sell modified and unmodified copies of the+Font Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components, in+Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the+corresponding Copyright Holder. This restriction only applies to the+primary font name as presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created using+the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.+```+### app/appearance/icons/color-icon/LICENSE```textdiff --git a/app/appearance/emojis/conf.json b/app/appearance/emojis/conf.jsonindex e55997a83c..3fc265e661 100644--- a/app/appearance/emojis/conf.json+++ b/app/appearance/emojis/conf.json@@ -600,6 +600,13 @@"description_zh_cn": "脸红","keywords": "amazed,awk,awkward,blame,dazed,dead,disbelief,embarrassed,exercise,face,flushed,geez,heat,hot,impressed,jeez,that’s crazy,what,wow,えーっ,とまどい,赤くなる,顔,驚き,困惑,天呀,害羞,羞涩,脸,茫然,迷茫,难以置信"},+ {+ "unicode": "1faea",+ "description": "Distorted Face",+ "description_ja_jp": "ゆがんだ顔",+ "description_zh_cn": "变形的脸",+ "keywords": "anxiety,bloated,panic,shocked,surprised,vulnerable,あぜん,ぼう然,ショック,不安,惊喜,惊恐,惊慌,焦虑,脆弱,膨れた,膨胀,震惊,驚いた"+ },{"unicode": "1f97a","description": "Pleading Face",@@ -1111,6 +1118,13 @@"description_zh_cn": "怒","keywords": "angry,comic,mad,upset,マンガ,怒った,怒り,怒りマーク,火大,生气,青筋"},+ {+ "unicode": "1faef",+ "description": "Fight Cloud",+ "description_ja_jp": "ボカスカ",+ "description_zh_cn": "打斗云团",+ "keywords": "argument,brawl,debate,disagreement,fight,ruckus,wrestle,ケンカ,バトル,ボカスカ,争い,争论,取っ組み合い,吵架,喧嘩,土煙,战斗,打斗,打架,摔跤,斗殴,骚动"+ },{"unicode": "1f4a5","description": "Collision",@@ -2819,6 +2833,13 @@"description_zh_cn": "穴居巨怪","keywords": "fairy tale,fantasy,monster,trolling,おとぎ話,ファンタジー,モンスター,幻想,怪兽,怪物,神话故事"},+ {+ "unicode": "1fac8",+ "description": "Hairy Creature",+ "description_ja_jp": "毛むくじゃらの生物",+ "description_zh_cn": "毛怪",+ "keywords": "bigfoot,cryptid,forest,giant,hairy,sasquatch,woodwose,yeti,イエティ,サスカッチ,ビッグフット,多毛,大型,大脚怪,大脚野人,巨人,未確認動物,森,森林,欧洲野人,毛むくじゃら,神秘生物,雪怪"+ },{"unicode": "1f486","description": "Person Getting Massage",@@ -3134,6 +3155,13 @@"description_zh_cn": "朝右跑步的女人","keywords": "coming,facing right,fast,hurry,marathon,quick,racing,runner,running,rush,speed,woman,ジョギング,スピード,ダッシュ,マラソン,ランナー,ランニング,レース,右向き,大急ぎ,急ぐ,移動,速い,冲刺,女,比赛,跑,跑步,面向右,马拉松"},+ {+ "unicode": "1f9d1-200d-1fa70",+ "description": "Ballet Dancer",+ "description_ja_jp": "バレエダンサー",+ "description_zh_cn": "芭蕾舞者",+ "keywords": "ballet,dancer,ダンサー,バレエ,舞者,芭蕾,芭蕾舞"+ },{"unicode": "1f57a","description": "Man Dancing",@@ -4654,6 +4682,13 @@"description_zh_cn": "海豚","keywords": "animal,beach,flipper,ocean,ドルフィン,動物,哺乳類,鸭脚板"},+ {+ "unicode": "1facd",+ "description": "Orca",+ "description_ja_jp": "シャチ",+ "description_zh_cn": "虎鲸",+ "keywords": "marine,ocean,whale,クジラ,大海,海,海洋,鲸,鲸鱼"+ },{"unicode": "1f9ad","description": "Seal",@@ -6666,6 +6701,13 @@"description_zh_cn": "山","keywords": "山岳,峰"},+ {+ "unicode": "1f6d8",+ "description": "Landslide",+ "description_ja_jp": "地滑り",+ "description_zh_cn": "山体滑坡",+ "keywords": "avalanche,danger,disaster,earthquake,mountain,mudslide,rocks,危险,土砂災害,地震,塌方,山,山崩,山崩れ,山石,岩石,崩落,泥石流,災害,灾害,灾难,落石"+ },{"unicode": "1f30b","description": "Volcano",@@ -8627,6 +8669,13 @@"description_zh_cn": "小号","keywords": "instrument,jazz,music,ジャズ,ラッパ,吹奏楽,楽器,金管楽器,音楽,乐器,吹奏,喇叭,音乐"},+ {+ "unicode": "1fa8a",+ "description": "Trombone",+ "description_ja_jp": "トロンボーン",+ "description_zh_cn": "长号",+ "keywords": "brass,instrument,jazz,music,sad,slide,ジャズ,スライド,乐器,吹奏楽,悲伤,楽器,滑动,爵士,管楽器,铜管乐,音乐,音楽"+ },{"unicode": "1f3bb","description": "Violin",@@ -9054,6 +9103,13 @@"description_zh_cn": "钱袋","keywords": "$,bag,bank,bet,billion,cash,cash out,cost,dollar,million,money,moneybag,paid,paying,pot of gold,rich,win,お金,キャッシュ,ドル,現金,賞金,賭け金,金持ち,金袋,銀行,付钱,十亿,变现,守财奴,富有,有钱,现金,百万,美元,赌钱,赢钱,钱,钱包,银行"},+ {+ "unicode": "1fa8e",+ "description": "Treasure Chest",+ "description_ja_jp": "宝箱",+ "description_zh_cn": "宝箱",+ "keywords": "gem,gold,jewels,loot,money,prize,silver,valuables,wealth,お宝,お金,ジュエリー,劫掠,奖赏,宝物,宝石,富,抢劫,珍宝,珠宝,藏宝箱,財宝,貴金属,财富,金子,金貨,钱,银,黄金"+ },{"unicode": "1fa99","description": "Coin",diff --git a/app/appearance/fonts/Noto-COLRv1-2.051/LICENSE b/app/appearance/fonts/Noto-COLRv1-2.051/LICENSEnew file mode 100644index 0000000000..d952d62c06--- /dev/null+++ b/app/appearance/fonts/Noto-COLRv1-2.051/LICENSE@@ -0,0 +1,92 @@+This Font Software is licensed under the SIL Open Font License,+Version 1.1.++This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font+creation efforts of academic and linguistic communities, and to+provide a free and open framework in which fonts may be shared and+improved in partnership with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply to+any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software+components as distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to,+deleting, or substituting -- in part or in whole -- any of the+components of the Original Version, by changing formats or by porting+the Font Software to a new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed,+modify, redistribute, and sell modified and unmodified copies of the+Font Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components, in+Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the+corresponding Copyright Holder. This restriction only applies to the+primary font name as presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created using+the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/app/appearance/fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2 b/app/appearance/fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2new file mode 100644index 0000000000..9245f58248Binary files /dev/null and b/app/appearance/fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2 differdiff --git a/app/appearance/fonts/Noto-COLRv1-2.051/README.md b/app/appearance/fonts/Noto-COLRv1-2.051/README.mdnew file mode 100644index 0000000000..2edc2ef9c5--- /dev/null+++ b/app/appearance/fonts/Noto-COLRv1-2.051/README.md@@ -0,0 +1,22 @@+# Noto COLRv1 2.051++来源:[googlefonts/noto-emoji v2.051](https://github.com/googlefonts/noto-emoji/releases/tag/v2.051),固定提交 `8998f5dd683424a73e2314a8c1f1e359c19e8742`。字体和许可证分别取自该提交的 `fonts/Noto-COLRv1.ttf` 和 `fonts/LICENSE`,许可证为 OFL-1.1。++原始 TTF 的 SHA-256:`0ae57fe58645638523ba35f388d93739d292539a9acb84df5700c81b1e1a28d2`。++使用 Python、fontTools 4.65.0 和 Brotli 1.2.0 压缩,保留完整字形、COLR/CPAL 彩色表及 GSUB 组合规则,不做字符子集化:++```sh+python -m pip install fonttools==4.65.0 brotli==1.2.0+python -m fontTools.ttLib.woff2 compress Noto-COLRv1.ttf -o Noto-COLRv1.woff2+```++生成的 WOFF2 的 SHA-256:`eea43aa18f7ae8ac50828d3b0907d2a881d0896a8ca4f5f6da471beecc7c13a2`,大小为 1,972,940 字节。++同次更新的八个表情条目使用 [CLDR 48](https://github.com/unicode-org/cldr/tree/acd6d88ae493633240e19a87a721076a8a75c310/common/annotations) 的英文、简体中文及日文名称和关键词。沿用面板不枚举肤色组合的规则,已有表情标识保持不变。++回归数据 `app/tests/fixtures/unicode17-emoji.json` 来自 [Unicode 17.0 emoji-test.txt](https://www.unicode.org/Public/17.0.0/emoji/emoji-test.txt) 中全部 163 条 `fully-qualified`、`E17.0` 序列,按原顺序保留。源文件 SHA-256 为 `1d8a944f88d7952f7ef7c5167fef3c67995bcae24543949710231b03a201acda`,适用仓库第三方声明中的 Unicode-3.0 许可证。++在 `app/` 目录运行 `node --import tsx --test src/util/emojiFont.test.ts tests/emojiFont.test.js`,检查新增列表、补充范围、实际字形组合和离线字体加载。浏览器测试使用 Electron,分别检查三种平台样式分支;这不替代实际 Apple WebKit 和移动端的兼容性验证。++保留 `Noto-COLRv1-2.047` 目录以兼容历史引用;当前前端和离线 HTML 导出使用本目录。diff --git a/app/src/assets/template/app/index.tpl b/app/src/assets/template/app/index.tplindex 05c9613e74..6da001aca0 100644--- a/app/src/assets/template/app/index.tpl+++ b/app/src/assets/template/app/index.tpl@@ -5,7 +5,7 @@<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag<meta http-equiv="Content-Security-Policy" content="script-src 'self'"/>--><title>SiYuan</title>- <link rel="preload" href="../../../appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2" as="font" type="font/woff2" crossorigin>+ <link rel="preload" href="../../../appearance/fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="../../../appearance/fonts/JetBrainsMono-2.304/JetBrainsMono-Regular.woff2" as="font" type="font/woff2" crossorigin><script src="../../protyle/js/pdf/pdf.min.mjs?v=4.8.69" type="module"></script></head>diff --git a/app/src/util/assets.ts b/app/src/util/assets.tsindex d80900690b..b9ceb0d569 100644--- a/app/src/util/assets.ts+++ b/app/src/util/assets.ts@@ -24,6 +24,7 @@ import {getBackend, getFrontend} from "./functions";import {getWorkspaceName} from "./processTitle";import {ensureSelectedCustomFonts, getExportCustomFontStyle} from "./customFont";import {getGlobalFontStyle} from "./globalFont";+import {getEmojiFontStyle} from "./emojiFont";import {isCurrentThemeSupported, shouldUnloadThemeScript} from "./themeCompatibility";import {getInlineStylesCSS,@@ -36,8 +37,6 @@ let headingNumberMeasurementRefreshTimer: number;let appearanceUpdate = Promise.resolve();let appearanceReloadPending = false;const appearancePackageRevisions = new Map<string, string>();-const DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE = "U+25fd-25fe, U+2614-2615, U+2648-2653, U+267f, U+2693, U+26a1, " +- "U+26aa-26ab, U+1f0cf, U+1f311-1f318, U+1f42d-1f42e, U+1f431, U+1f435, U+1f600-1f64f";// 串行应用外观变更,等待脚本加载和卸载完成后再处理下一次推送。export const enqueueAppearanceUpdate = (apply: () => Promise<void>) => {@@ -354,84 +353,8 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {if (set && allowCustomAppearance) {await ensureSelectedCustomFonts([...globalFonts, ...editorFonts, ...codeFonts]);}- let style;- // Emojis Reset: 字体中包含了 emoji,需重置- // Emojis Additional: 苹果/win11 字体中没有的 emoji- if (isMac() || isIPad() || isIPhone()) {- style = `@font-face {- font-family: "Emojis Additional";- src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");- unicode-range: U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1fa8f;-}-@font-face {- font-family: "Emojis Reset";- src: local("Apple Color Emoji"),- local("Segoe UI Emoji"),- local("Segoe UI Symbol");- unicode-range: U+21a9, U+21aa, U+2122, U+2194-2199, U+23cf, U+25b6, U+25c0, U+25fb, U+25fc, U+25aa, U+25ab, U+2600-2603,- U+260e, U+2611, U+261d, U+2639, U+263a, U+2640, U+2642, U+2660, U+2663, U+2665, U+2666, U+2668, U+267b, U+26aa, U+26ab,- U+2702, U+2708, U+2934, U+2935, U+1f170, U+1f171, U+1f17e, U+1f17f, U+1f202, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250,- U+1f251, U+1fae4, U+2049, U+203c, U+3030, U+303d, U+24c2, U+26a0, U+26a1, U+26be, U+27a1, U+2b05-2b07, U+3297, U+3299, U+a9, U+ae,- ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE};- size-adjust: 115%;-}-@font-face {- font-family: "Emojis";- src: local("Apple Color Emoji"),- local("Segoe UI Emoji"),- local("Segoe UI Symbol");- size-adjust: 115%;-}`;- } else if (await isWin11()) {- // Win11 Browser- style = `@font-face {- font-family: "Emojis Additional";- src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");- unicode-range: U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1f3f4, U+e0067, U+e0062,- U+e0065, U+e006e, U+e007f, U+e0073, U+e0063, U+e0074, U+e0077, U+e006c;- size-adjust: 85%;-}-@font-face {- font-family: "Emojis Reset";- src: local("Segoe UI Emoji"),- local("Segoe UI Symbol");- unicode-range: U+263a, U+21a9, U+2642, U+303d, U+2197, U+2198, U+2199, U+2196, U+2195, U+2194, U+2660, U+2665, U+2666,- U+2663, U+3030, U+21aa, U+25b6, U+25c0, U+2640, U+203c, U+a9, U+ae, U+2122, ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE};- size-adjust: 85%;-}-@font-face {- font-family: "Emojis";- src: local("Segoe UI Emoji"),- local("Segoe UI Symbol");- size-adjust: 85%;-}`;- } else {- style = `@font-face {- font-family: "Emojis Reset";- src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");- unicode-range: U+1f170-1f171, U+1f17e, U+1f17f, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250, U+1f251, U+1f32b, U+1f3bc,- U+1f411, U+1f42d, U+1f42e, U+1f431, U+1f435, U+1f441, U+1f4a8, U+1f4ab, U+1f525, ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE},- U+1f79, U+1f8f, U+1fa79, U+1fae4, U+1fae9, U+1fac6, U+1fabe, U+1fadf,- U+200d, U+203c, U+2049, U+2122, U+2139, U+2194-2199, U+21a9, U+21aa, U+23cf, U+25aa, U+25ab, U+25b6, U+25c0, U+25fb-25fe,- U+2611, U+2615, U+2618, U+261d, U+2620, U+2622, U+2623, U+2626, U+262a, U+262e, U+2638-263a, U+2640, U+2642, U+2648-2653,- U+265f, U+2660, U+2663, U+2665, U+2666, U+267b, U+267e, U+267f, U+2692-2697, U+2699, U+269b, U+269c, U+26a0, U+26a1,- U+26a7, U+26aa, U+26ab, U+26b0, U+26b1, U+2702, U+2708, U+2709, U+270c, U+270d, U+2712, U+2714, U+2716, U+271d, U+2733,- U+2734, U+2744, U+2747, U+2763, U+2764, U+2934-2935, U+3030, U+303d, U+3297, U+3299, U+fe0f, U+e50a, U+a9, U+ae;- size-adjust: 92%;-}-@font-face {- font-family: "Emojis";- src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2"),- local("Segoe UI Emoji"),- local("Segoe UI Symbol"),- local("Apple Color Emoji"),- local("Twemoji Mozilla"),- local("Noto Color Emoji"),- local("Android Emoji"),- local("EmojiSymbols");- size-adjust: 92%;-}`;- }+ const emojiPlatform = isMac() || isIPad() || isIPhone() ? "apple" : await isWin11() ? "windows11" : "other";+ let style = getEmojiFontStyle(emojiPlatform, servePath);style += getGlobalFontStyle(globalFonts);if (!set) {style += "\n" + await getExportCustomFontStyle([...globalFonts, ...editorFonts, ...codeFonts]);diff --git a/app/src/util/emojiFont.test.ts b/app/src/util/emojiFont.test.tsnew file mode 100644index 0000000000..6633b53ce4--- /dev/null+++ b/app/src/util/emojiFont.test.ts@@ -0,0 +1,74 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import * as path from "node:path";+import {describe, it} from "node:test";+import {getEmojiFontStyle, NOTO_EMOJI_FONT_PATH} from "./emojiFont";++const appPath = path.resolve(__dirname, "../..");+const sequences: string[] = JSON.parse(readFileSync(path.join(appPath, "tests/fixtures/unicode17-emoji.json"), "utf8"));+const categories: IEmoji[] = JSON.parse(readFileSync(path.join(appPath, "appearance/emojis/conf.json"), "utf8"));++describe("Unicode 17 emoji fonts", () => {+ it("covers every code point of the 163 new fully qualified sequences in each platform override", () => {+ assert.equal(sequences.length, 163);+ for (const platform of ["apple", "windows11", "other"] as const) {+ const style = getEmojiFontStyle(platform, "../../../");+ const firstFace = style.slice(0, style.indexOf("}"));+ assert.ok(firstFace.includes(NOTO_EMOJI_FONT_PATH));+ const ranges = firstFace.match(/unicode-range: ([^;]+);/)[1].split(",").map(range => {+ const [start, end] = range.trim().slice(2).split("-").map(value => parseInt(value, 16));+ return [start, end ?? start];+ });+ for (const sequence of sequences) {+ for (const value of sequence.split("-")) {+ const code = parseInt(value, 16);+ assert.ok(ranges.some(([start, end]) => code >= start && code <= end), `${platform}: ${sequence} misses ${value}`);+ }+ }+ }+ });++ it("keeps native emoji sources on Apple and Windows 11 and bundled sources elsewhere", () => {+ for (const [platform, native] of [["apple", "Apple Color Emoji"], ["windows11", "Segoe UI Emoji"]] as const) {+ const style = getEmojiFontStyle(platform, "");+ const mainFace = style.slice(style.lastIndexOf("@font-face"));+ assert.ok(mainFace.includes(`src: local("${native}")`));+ assert.ok(!mainFace.includes(NOTO_EMOJI_FONT_PATH));+ }+ const other = getEmojiFontStyle("other", "");+ assert.ok(other.slice(other.lastIndexOf("@font-face")).includes(`src: url(${NOTO_EMOJI_FONT_PATH})`));+ });++ it("resolves the same bundled font from app, PDF and offline HTML paths", () => {+ const font = readFileSync(path.join(appPath, NOTO_EMOJI_FONT_PATH));+ assert.equal(font.subarray(0, 4).toString(), "wOF2");+ for (const prefix of ["../../../", "", "http://127.0.0.1:6806/"]) {+ assert.ok(getEmojiFontStyle("windows11", prefix).includes(`url(${prefix}${NOTO_EMOJI_FONT_PATH})`));+ }+ const template = readFileSync(path.join(appPath, "src/assets/template/app/index.tpl"), "utf8");+ assert.ok(template.includes(`href="../../../${NOTO_EMOJI_FONT_PATH}"`));+ const exporter = readFileSync(path.join(appPath, "../kernel/model/appearance_export.go"), "utf8");+ assert.ok(exporter.includes(`"${NOTO_EMOJI_FONT_PATH.split("/")[2]}"`));+ });++ it("adds localized base emoji without expanding skin tone variants in the picker", () => {+ const expected: Record<string, string> = {+ "1faea": "people", "1faef": "people", "1fac8": "people", "1f9d1-200d-1fa70": "people",+ "1facd": "nature", "1f6d8": "travel", "1fa8a": "objects", "1fa8e": "objects",+ };+ const items = categories.flatMap(category => category.items);+ assert.equal(new Set(items.map(item => item.unicode)).size, items.length);+ const added = items.filter(item => sequences.includes(item.unicode));+ assert.deepEqual(added.map(item => item.unicode).sort(), Object.keys(expected).sort());+ for (const [unicode, categoryID] of Object.entries(expected)) {+ const item = categories.find(category => category.id === categoryID).items.find(item => item.unicode === unicode);+ assert.ok(item);+ for (const key of ["description", "description_zh_cn", "description_ja_jp", "keywords"] as const) {+ assert.ok(item[key]?.trim(), `${unicode}: ${key}`);+ }+ assert.notEqual(item.description, item.description_zh_cn);+ assert.notEqual(item.description, item.description_ja_jp);+ assert.ok(/^[a-f0-9]+(?:-[a-f0-9]+)*$/.test(item.unicode));+ }+ });+});diff --git a/app/src/util/emojiFont.ts b/app/src/util/emojiFont.tsnew file mode 100644index 0000000000..9fe03a9de6--- /dev/null+++ b/app/src/util/emojiFont.ts@@ -0,0 +1,89 @@+export const NOTO_EMOJI_FONT_PATH = "appearance/fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2";++// 组合表情需覆盖完整序列的码点;这些码点对应的独立表情也使用 Noto,保证组合字形完整。+const UNICODE_17_EMOJI_RANGE = "U+200d, U+2640, U+2642, U+fe0f, U+1f3fb-1f3ff, U+1f430, U+1f468-1f469, " ++ "U+1f46f, U+1f6d8, U+1f93c, U+1f9d1, U+1fa70, U+1fa8a, U+1fa8e, U+1fac8, U+1facd, U+1faea, U+1faef";++const DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE = "U+25fd-25fe, U+2614-2615, U+2648-2653, U+267f, U+2693, U+26a1, " ++ "U+26aa-26ab, U+1f0cf, U+1f311-1f318, U+1f42d-1f42e, U+1f431, U+1f435, U+1f600-1f64f";++export const getEmojiFontStyle = (platform: "apple" | "windows11" | "other", servePath: string) => {+ let style;+ // Emojis Reset:覆盖正文和代码字体中的表情字形。+ // Emojis Additional:为系统表情字体补充指定字符和组合。+ if (platform === "apple") {+ style = `@font-face {+ font-family: "Emojis Additional";+ src: url(${servePath}${NOTO_EMOJI_FONT_PATH}) format("woff2");+ unicode-range: ${UNICODE_17_EMOJI_RANGE}, U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1fa8f;+}+@font-face {+ font-family: "Emojis Reset";+ src: local("Apple Color Emoji"),+ local("Segoe UI Emoji"),+ local("Segoe UI Symbol");+ unicode-range: U+21a9, U+21aa, U+2122, U+2194-2199, U+23cf, U+25b6, U+25c0, U+25fb, U+25fc, U+25aa, U+25ab, U+2600-2603,+ U+260e, U+2611, U+261d, U+2639, U+263a, U+2640, U+2642, U+2660, U+2663, U+2665, U+2666, U+2668, U+267b, U+26aa, U+26ab,+ U+2702, U+2708, U+2934, U+2935, U+1f170, U+1f171, U+1f17e, U+1f17f, U+1f202, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250,+ U+1f251, U+1fae4, U+2049, U+203c, U+3030, U+303d, U+24c2, U+26a0, U+26a1, U+26be, U+27a1, U+2b05-2b07, U+3297, U+3299, U+a9, U+ae,+ ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE};+ size-adjust: 115%;+}+@font-face {+ font-family: "Emojis";+ src: local("Apple Color Emoji"),+ local("Segoe UI Emoji"),+ local("Segoe UI Symbol");+ size-adjust: 115%;+}`;+ } else if (platform === "windows11") {+ style = `@font-face {+ font-family: "Emojis Additional";+ src: url(${servePath}${NOTO_EMOJI_FONT_PATH}) format("woff2");+ unicode-range: ${UNICODE_17_EMOJI_RANGE}, U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1f3f4, U+e0067, U+e0062,+ U+e0065, U+e006e, U+e007f, U+e0073, U+e0063, U+e0074, U+e0077, U+e006c;+ size-adjust: 85%;+}+@font-face {+ font-family: "Emojis Reset";+ src: local("Segoe UI Emoji"),+ local("Segoe UI Symbol");+ unicode-range: U+263a, U+21a9, U+2642, U+303d, U+2197, U+2198, U+2199, U+2196, U+2195, U+2194, U+2660, U+2665, U+2666,+ U+2663, U+3030, U+21aa, U+25b6, U+25c0, U+2640, U+203c, U+a9, U+ae, U+2122, ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE};+ size-adjust: 85%;+}+@font-face {+ font-family: "Emojis";+ src: local("Segoe UI Emoji"),+ local("Segoe UI Symbol");+ size-adjust: 85%;+}`;+ } else {+ style = `@font-face {+ font-family: "Emojis Reset";+ src: url(${servePath}${NOTO_EMOJI_FONT_PATH}) format("woff2");+ unicode-range: ${UNICODE_17_EMOJI_RANGE}, U+1f170-1f171, U+1f17e, U+1f17f, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250, U+1f251, U+1f32b, U+1f3bc,+ U+1f411, U+1f42d, U+1f42e, U+1f431, U+1f435, U+1f441, U+1f4a8, U+1f4ab, U+1f525, ${DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE},+ U+1f79, U+1f8f, U+1fa79, U+1fae4, U+1fae9, U+1fac6, U+1fabe, U+1fadf,+ U+200d, U+203c, U+2049, U+2122, U+2139, U+2194-2199, U+21a9, U+21aa, U+23cf, U+25aa, U+25ab, U+25b6, U+25c0, U+25fb-25fe,+ U+2611, U+2615, U+2618, U+261d, U+2620, U+2622, U+2623, U+2626, U+262a, U+262e, U+2638-263a, U+2640, U+2642, U+2648-2653,+ U+265f, U+2660, U+2663, U+2665, U+2666, U+267b, U+267e, U+267f, U+2692-2697, U+2699, U+269b, U+269c, U+26a0, U+26a1,+ U+26a7, U+26aa, U+26ab, U+26b0, U+26b1, U+2702, U+2708, U+2709, U+270c, U+270d, U+2712, U+2714, U+2716, U+271d, U+2733,+ U+2734, U+2744, U+2747, U+2763, U+2764, U+2934-2935, U+3030, U+303d, U+3297, U+3299, U+fe0f, U+e50a, U+a9, U+ae;+ size-adjust: 92%;+}+@font-face {+ font-family: "Emojis";+ src: url(${servePath}${NOTO_EMOJI_FONT_PATH}) format("woff2"),+ local("Segoe UI Emoji"),+ local("Segoe UI Symbol"),+ local("Apple Color Emoji"),+ local("Twemoji Mozilla"),+ local("Noto Color Emoji"),+ local("Android Emoji"),+ local("EmojiSymbols");+ size-adjust: 92%;+}`;+ }+ return style;+};diff --git a/app/tests/emojiFont.test.js b/app/tests/emojiFont.test.jsnew file mode 100644index 0000000000..76655b41ec--- /dev/null+++ b/app/tests/emojiFont.test.js@@ -0,0 +1,108 @@+const assert = require("node:assert/strict");+const {readFileSync, writeFileSync, mkdirSync, copyFileSync, mkdtempSync, rmSync} = require("node:fs");+const path = require("node:path");+const os = require("node:os");++const runElectron = async () => {+ const {app, BrowserWindow} = require("electron");+ const profile = process.argv[2];+ app.setPath("userData", path.join(profile, "profile"));+ app.commandLine.appendSwitch("disable-gpu");+ await app.whenReady();+ const win = new BrowserWindow({show: false, width: 1000, height: 800});+ let exitCode = 0;+ try {+ const ts = require("typescript");+ const moduleExports = {};+ const source = readFileSync(path.join(__dirname, "../src/util/emojiFont.ts"), "utf8");+ new Function("exports", ts.transpileModule(source, {+ compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020},+ }).outputText)(moduleExports);+ const {getEmojiFontStyle, NOTO_EMOJI_FONT_PATH} = moduleExports;+ const fontPath = path.join(profile, NOTO_EMOJI_FONT_PATH);+ mkdirSync(path.dirname(fontPath), {recursive: true});+ copyFileSync(path.join(__dirname, "..", NOTO_EMOJI_FONT_PATH), fontPath);+ const sequences = JSON.parse(readFileSync(path.join(__dirname, "fixtures/unicode17-emoji.json"), "utf8"));+ const oldSequences = ["1f600", "1f1e8-1f1f3", "1f46f", "1f93c", "1fa70", "1f9d1-200d-1f4bb",+ "1f469-1f3fd-200d-1f4bb", "1f468-200d-1f469-200d-1f467", "1f469-200d-2764-fe0f-200d-1f469"];+ const characters = [...sequences, ...oldSequences].map(sequence => String.fromCodePoint(...sequence.split("-").map(value => parseInt(value, 16))));+ win.webContents.debugger.attach("1.3");+ const command = (method, params) => win.webContents.debugger.sendCommand(method, params);+ for (const platform of ["apple", "windows11", "other"]) {+ // 从导出目录加载真实 WOFF2,确保字体声明及相对路径能在离线页面使用。+ const html = `<html><meta charset="utf-8"><style>${getEmojiFontStyle(platform, "")}+body { background: white; }+.emoji { display: inline-block; font-size: 32px; margin: 3px; font-family: "Emojis Additional", "Emojis"; }+.text { font-family: "Emojis Additional", "Emojis Reset", Arial, "Emojis"; }+</style><body>${characters.map((char, index) => `<span id="emoji-${index}" class="emoji">${char}</span>`).join("")}+<hr>${characters.map((char, index) => `<span id="text-${index}" class="emoji text">${char}</span>`).join("")}+${characters.map((char, index) => `<span id="native-${index}" style='font-family:"Emojis"'>${char}</span>`).join("")}</body></html>`;+ const htmlPath = path.join(profile, `${platform}.html`);+ writeFileSync(htmlPath, html);+ await win.loadFile(htmlPath);+ await command("DOM.enable");+ await command("CSS.enable");+ await win.webContents.executeJavaScript("document.fonts.ready.then(() => true)");+ const {root} = await command("DOM.getDocument");+ for (const context of ["emoji", "text"]) {+ for (let index = 0; index < characters.length; index++) {+ const {nodeId} = await command("DOM.querySelector", {nodeId: root.nodeId, selector: `#${context}-${index}`});+ const {fonts} = await command("CSS.getPlatformFontsForNode", {nodeId});+ const label = `${platform}/${context}: ${[...sequences, ...oldSequences][index]}`;+ const glyphCount = fonts.reduce((count, font) => count + font.glyphCount, 0);+ if (index < sequences.length || platform === "other") {+ assert.equal(glyphCount, 1, `${label}: ${JSON.stringify(fonts)}`);+ assert.ok(fonts.every(font => font.isCustomFont), `${label}: ${JSON.stringify(fonts)}`);+ } else {+ // 系统字体对旧组合的支持各异,补充字体不能使既有组合进一步拆分。+ const native = await command("DOM.querySelector", {nodeId: root.nodeId, selector: `#native-${index}`});+ const {fonts: nativeFonts} = await command("CSS.getPlatformFontsForNode", {nodeId: native.nodeId});+ const nativeCount = nativeFonts.reduce((count, font) => count + font.glyphCount, 0);+ assert.ok(glyphCount > 0 && glyphCount <= nativeCount, `${label}: ${JSON.stringify(fonts)}`);+ }+ }+ }+ const pdf = await win.webContents.printToPDF({printBackground: true});+ assert.equal(pdf.subarray(0, 4).toString(), "%PDF");+ assert.ok(pdf.length > 10000);+ if (process.env.SIYUAN_EMOJI_TEST_ARTIFACTS) {+ const artifacts = path.resolve(process.env.SIYUAN_EMOJI_TEST_ARTIFACTS);+ mkdirSync(artifacts, {recursive: true});+ writeFileSync(path.join(artifacts, `${platform}.pdf`), pdf);+ writeFileSync(path.join(artifacts, `${platform}.png`), (await win.webContents.capturePage()).toPNG());+ }+ }+ console.log("Unicode 17 emoji rendering cases passed");+ } catch (error) {+ console.error(error);+ exitCode = 1;+ } finally {+ win.destroy();+ app.exit(exitCode);+ }+};++if (process.versions.electron && process.type === "browser") {+ runElectron().catch(error => {+ console.error(error);+ require("electron").app.exit(1);+ });+} else {+ require("node:test").it("renders Unicode 17 sequences and existing emoji with platform and offline export styles", {+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,+ timeout: 90000,+ }, async () => {+ const env = {...process.env};+ delete env.ELECTRON_RUN_AS_NODE;+ const profile = mkdtempSync(path.join(os.tmpdir(), "siyuan-emoji-font-"));+ try {+ const {stdout} = await require("node:util").promisify(require("node:child_process").execFile)(+ require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 85000});+ assert.match(stdout, /Unicode 17 emoji rendering cases passed/);+ } finally {+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));+ assert.ok(path.basename(profile).startsWith("siyuan-emoji-font-"));+ rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});+ }+ });+}diff --git a/app/tests/fixtures/unicode17-emoji.json b/app/tests/fixtures/unicode17-emoji.jsonnew file mode 100644index 0000000000..900b841a01--- /dev/null+++ b/app/tests/fixtures/unicode17-emoji.json@@ -0,0 +1,165 @@+[+ "1faea",+ "1faef",+ "1fac8",+ "1f9d1-200d-1fa70",+ "1f9d1-1f3fb-200d-1fa70",+ "1f9d1-1f3fc-200d-1fa70",+ "1f9d1-1f3fd-200d-1fa70",+ "1f9d1-1f3fe-200d-1fa70",+ "1f9d1-1f3ff-200d-1fa70",+ "1f46f-1f3fb",+ "1f46f-1f3fc",+ "1f46f-1f3fd",+ "1f46f-1f3fe",+ "1f46f-1f3ff",+ "1f46f-1f3fb-200d-2642-fe0f",+ "1f46f-1f3fc-200d-2642-fe0f",+ "1f46f-1f3fd-200d-2642-fe0f",+ "1f46f-1f3fe-200d-2642-fe0f",+ "1f46f-1f3ff-200d-2642-fe0f",+ "1f46f-1f3fb-200d-2640-fe0f",+ "1f46f-1f3fc-200d-2640-fe0f",+ "1f46f-1f3fd-200d-2640-fe0f",+ "1f46f-1f3fe-200d-2640-fe0f",+ "1f46f-1f3ff-200d-2640-fe0f",+ "1f9d1-1f3fb-200d-1f430-200d-1f9d1-1f3fc",+ "1f9d1-1f3fb-200d-1f430-200d-1f9d1-1f3fd",+ "1f9d1-1f3fb-200d-1f430-200d-1f9d1-1f3fe",+ "1f9d1-1f3fb-200d-1f430-200d-1f9d1-1f3ff",+ "1f9d1-1f3fc-200d-1f430-200d-1f9d1-1f3fb",+ "1f9d1-1f3fc-200d-1f430-200d-1f9d1-1f3fd",+ "1f9d1-1f3fc-200d-1f430-200d-1f9d1-1f3fe",+ "1f9d1-1f3fc-200d-1f430-200d-1f9d1-1f3ff",+ "1f9d1-1f3fd-200d-1f430-200d-1f9d1-1f3fb",+ "1f9d1-1f3fd-200d-1f430-200d-1f9d1-1f3fc",+ "1f9d1-1f3fd-200d-1f430-200d-1f9d1-1f3fe",+ "1f9d1-1f3fd-200d-1f430-200d-1f9d1-1f3ff",+ "1f9d1-1f3fe-200d-1f430-200d-1f9d1-1f3fb",+ "1f9d1-1f3fe-200d-1f430-200d-1f9d1-1f3fc",+ "1f9d1-1f3fe-200d-1f430-200d-1f9d1-1f3fd",+ "1f9d1-1f3fe-200d-1f430-200d-1f9d1-1f3ff",+ "1f9d1-1f3ff-200d-1f430-200d-1f9d1-1f3fb",+ "1f9d1-1f3ff-200d-1f430-200d-1f9d1-1f3fc",+ "1f9d1-1f3ff-200d-1f430-200d-1f9d1-1f3fd",+ "1f9d1-1f3ff-200d-1f430-200d-1f9d1-1f3fe",+ "1f468-1f3fb-200d-1f430-200d-1f468-1f3fc",+ "1f468-1f3fb-200d-1f430-200d-1f468-1f3fd",+ "1f468-1f3fb-200d-1f430-200d-1f468-1f3fe",+ "1f468-1f3fb-200d-1f430-200d-1f468-1f3ff",+ "1f468-1f3fc-200d-1f430-200d-1f468-1f3fb",+ "1f468-1f3fc-200d-1f430-200d-1f468-1f3fd",+ "1f468-1f3fc-200d-1f430-200d-1f468-1f3fe",+ "1f468-1f3fc-200d-1f430-200d-1f468-1f3ff",+ "1f468-1f3fd-200d-1f430-200d-1f468-1f3fb",+ "1f468-1f3fd-200d-1f430-200d-1f468-1f3fc",+ "1f468-1f3fd-200d-1f430-200d-1f468-1f3fe",+ "1f468-1f3fd-200d-1f430-200d-1f468-1f3ff",+ "1f468-1f3fe-200d-1f430-200d-1f468-1f3fb",+ "1f468-1f3fe-200d-1f430-200d-1f468-1f3fc",+ "1f468-1f3fe-200d-1f430-200d-1f468-1f3fd",+ "1f468-1f3fe-200d-1f430-200d-1f468-1f3ff",+ "1f468-1f3ff-200d-1f430-200d-1f468-1f3fb",+ "1f468-1f3ff-200d-1f430-200d-1f468-1f3fc",+ "1f468-1f3ff-200d-1f430-200d-1f468-1f3fd",+ "1f468-1f3ff-200d-1f430-200d-1f468-1f3fe",+ "1f469-1f3fb-200d-1f430-200d-1f469-1f3fc",+ "1f469-1f3fb-200d-1f430-200d-1f469-1f3fd",+ "1f469-1f3fb-200d-1f430-200d-1f469-1f3fe",+ "1f469-1f3fb-200d-1f430-200d-1f469-1f3ff",+ "1f469-1f3fc-200d-1f430-200d-1f469-1f3fb",+ "1f469-1f3fc-200d-1f430-200d-1f469-1f3fd",+ "1f469-1f3fc-200d-1f430-200d-1f469-1f3fe",+ "1f469-1f3fc-200d-1f430-200d-1f469-1f3ff",+ "1f469-1f3fd-200d-1f430-200d-1f469-1f3fb",+ "1f469-1f3fd-200d-1f430-200d-1f469-1f3fc",+ "1f469-1f3fd-200d-1f430-200d-1f469-1f3fe",+ "1f469-1f3fd-200d-1f430-200d-1f469-1f3ff",+ "1f469-1f3fe-200d-1f430-200d-1f469-1f3fb",+ "1f469-1f3fe-200d-1f430-200d-1f469-1f3fc",+ "1f469-1f3fe-200d-1f430-200d-1f469-1f3fd",+ "1f469-1f3fe-200d-1f430-200d-1f469-1f3ff",+ "1f469-1f3ff-200d-1f430-200d-1f469-1f3fb",+ "1f469-1f3ff-200d-1f430-200d-1f469-1f3fc",+ "1f469-1f3ff-200d-1f430-200d-1f469-1f3fd",+ "1f469-1f3ff-200d-1f430-200d-1f469-1f3fe",+ "1f93c-1f3fb",+ "1f93c-1f3fc",+ "1f93c-1f3fd",+ "1f93c-1f3fe",+ "1f93c-1f3ff",+ "1f93c-1f3fb-200d-2642-fe0f",+ "1f93c-1f3fc-200d-2642-fe0f",+ "1f93c-1f3fd-200d-2642-fe0f",+ "1f93c-1f3fe-200d-2642-fe0f",+ "1f93c-1f3ff-200d-2642-fe0f",+ "1f93c-1f3fb-200d-2640-fe0f",+ "1f93c-1f3fc-200d-2640-fe0f",+ "1f93c-1f3fd-200d-2640-fe0f",+ "1f93c-1f3fe-200d-2640-fe0f",+ "1f93c-1f3ff-200d-2640-fe0f",+ "1f9d1-1f3fb-200d-1faef-200d-1f9d1-1f3fc",+ "1f9d1-1f3fb-200d-1faef-200d-1f9d1-1f3fd",+ "1f9d1-1f3fb-200d-1faef-200d-1f9d1-1f3fe",+ "1f9d1-1f3fb-200d-1faef-200d-1f9d1-1f3ff",+ "1f9d1-1f3fc-200d-1faef-200d-1f9d1-1f3fb",+ "1f9d1-1f3fc-200d-1faef-200d-1f9d1-1f3fd",+ "1f9d1-1f3fc-200d-1faef-200d-1f9d1-1f3fe",+ "1f9d1-1f3fc-200d-1faef-200d-1f9d1-1f3ff",+ "1f9d1-1f3fd-200d-1faef-200d-1f9d1-1f3fb",+ "1f9d1-1f3fd-200d-1faef-200d-1f9d1-1f3fc",+ "1f9d1-1f3fd-200d-1faef-200d-1f9d1-1f3fe",+ "1f9d1-1f3fd-200d-1faef-200d-1f9d1-1f3ff",+ "1f9d1-1f3fe-200d-1faef-200d-1f9d1-1f3fb",+ "1f9d1-1f3fe-200d-1faef-200d-1f9d1-1f3fc",+ "1f9d1-1f3fe-200d-1faef-200d-1f9d1-1f3fd",+ "1f9d1-1f3fe-200d-1faef-200d-1f9d1-1f3ff",+ "1f9d1-1f3ff-200d-1faef-200d-1f9d1-1f3fb",+ "1f9d1-1f3ff-200d-1faef-200d-1f9d1-1f3fc",+ "1f9d1-1f3ff-200d-1faef-200d-1f9d1-1f3fd",+ "1f9d1-1f3ff-200d-1faef-200d-1f9d1-1f3fe",+ "1f468-1f3fb-200d-1faef-200d-1f468-1f3fc",+ "1f468-1f3fb-200d-1faef-200d-1f468-1f3fd",+ "1f468-1f3fb-200d-1faef-200d-1f468-1f3fe",+ "1f468-1f3fb-200d-1faef-200d-1f468-1f3ff",+ "1f468-1f3fc-200d-1faef-200d-1f468-1f3fb",+ "1f468-1f3fc-200d-1faef-200d-1f468-1f3fd",+ "1f468-1f3fc-200d-1faef-200d-1f468-1f3fe",+ "1f468-1f3fc-200d-1faef-200d-1f468-1f3ff",+ "1f468-1f3fd-200d-1faef-200d-1f468-1f3fb",+ "1f468-1f3fd-200d-1faef-200d-1f468-1f3fc",+ "1f468-1f3fd-200d-1faef-200d-1f468-1f3fe",+ "1f468-1f3fd-200d-1faef-200d-1f468-1f3ff",+ "1f468-1f3fe-200d-1faef-200d-1f468-1f3fb",+ "1f468-1f3fe-200d-1faef-200d-1f468-1f3fc",+ "1f468-1f3fe-200d-1faef-200d-1f468-1f3fd",+ "1f468-1f3fe-200d-1faef-200d-1f468-1f3ff",+ "1f468-1f3ff-200d-1faef-200d-1f468-1f3fb",+ "1f468-1f3ff-200d-1faef-200d-1f468-1f3fc",+ "1f468-1f3ff-200d-1faef-200d-1f468-1f3fd",+ "1f468-1f3ff-200d-1faef-200d-1f468-1f3fe",+ "1f469-1f3fb-200d-1faef-200d-1f469-1f3fc",+ "1f469-1f3fb-200d-1faef-200d-1f469-1f3fd",+ "1f469-1f3fb-200d-1faef-200d-1f469-1f3fe",+ "1f469-1f3fb-200d-1faef-200d-1f469-1f3ff",+ "1f469-1f3fc-200d-1faef-200d-1f469-1f3fb",+ "1f469-1f3fc-200d-1faef-200d-1f469-1f3fd",+ "1f469-1f3fc-200d-1faef-200d-1f469-1f3fe",+ "1f469-1f3fc-200d-1faef-200d-1f469-1f3ff",+ "1f469-1f3fd-200d-1faef-200d-1f469-1f3fb",+ "1f469-1f3fd-200d-1faef-200d-1f469-1f3fc",+ "1f469-1f3fd-200d-1faef-200d-1f469-1f3fe",+ "1f469-1f3fd-200d-1faef-200d-1f469-1f3ff",+ "1f469-1f3fe-200d-1faef-200d-1f469-1f3fb",+ "1f469-1f3fe-200d-1faef-200d-1f469-1f3fc",+ "1f469-1f3fe-200d-1faef-200d-1f469-1f3fd",+ "1f469-1f3fe-200d-1faef-200d-1f469-1f3ff",+ "1f469-1f3ff-200d-1faef-200d-1f469-1f3fb",+ "1f469-1f3ff-200d-1faef-200d-1f469-1f3fc",+ "1f469-1f3ff-200d-1faef-200d-1f469-1f3fd",+ "1f469-1f3ff-200d-1faef-200d-1f469-1f3fe",+ "1facd",+ "1f6d8",+ "1fa8a",+ "1fa8e"+]diff --git a/kernel/model/appearance_export.go b/kernel/model/appearance_export.goindex 4654844ca8..1d0f25950c 100644--- a/kernel/model/appearance_export.go+++ b/kernel/model/appearance_export.go@@ -61,5 +61,14 @@ func copyExportAppearance(savePath, theme, icon string) error {copied[name] = true}}+ // 离线 HTML 使用与前端声明一致的内置表情字体,不复制用户字体或历史版本。+ fontDir := "Noto-COLRv1-2.051"+ for _, name := range []string{"Noto-COLRv1.woff2", "LICENSE"} {+ from := filepath.Join(util.BuiltInAppearancePath(), "fonts", fontDir, name)+ to := filepath.Join(savePath, "appearance", "fonts", fontDir, name)+ if err := filelock.Copy(from, to); err != nil {+ return fmt.Errorf("copy emoji font [%s]: %w", name, err)+ }+ }return nil}diff --git a/kernel/model/appearance_packages_test.go b/kernel/model/appearance_packages_test.goindex d7dfcb07a4..e6faeb07ff 100644--- a/kernel/model/appearance_packages_test.go+++ b/kernel/model/appearance_packages_test.go@@ -47,6 +47,13 @@ func setupAppearancePackagesTest(t *testing.T) {for _, name := range []string{"litheness", "custom"} {writeAppearanceTestPackage(t, "icons", name, "1.0.0", "")}+ writeAppearanceTestEmojiFont(t)+}++func writeAppearanceTestEmojiFont(t *testing.T) {+ t.Helper()+ writeAppearanceTestFile(t, filepath.Join(util.AppearancePath, "fonts", "Noto-COLRv1-2.051", "Noto-COLRv1.woff2"), "emoji font")+ writeAppearanceTestFile(t, filepath.Join(util.AppearancePath, "fonts", "Noto-COLRv1-2.051", "LICENSE"), "emoji license")}func writeAppearanceTestFile(t *testing.T, path, content string) {@@ -113,23 +120,45 @@ func TestExportAppearancePackagesUsesDataAndCopiesResources(t *testing.T) {writeAppearanceTestFile(t, filepath.Join(util.ThemesPath, "custom", "assets", "font.woff2"), "font")writeAppearanceTestFile(t, filepath.Join(util.IconsPath, "custom", "assets", "image.png"), "image")writeAppearanceTestFile(t, filepath.Join(util.AppearancePath, "themes", "custom", "theme.css"), "legacy")+ writeAppearanceTestFile(t, filepath.Join(util.AppearancePath, "fonts", "custom", "private.ttf"), "private font")+ writeAppearanceTestFile(t, filepath.Join(util.AppearancePath, "fonts", "Noto-COLRv1-2.047", "Noto-COLRv1.woff2"), "old emoji font")destination := t.TempDir()if err := copyExportAppearance(destination, "custom", "custom"); err != nil {t.Fatal(err)}for name, expected := range map[string]string{- "themes/custom/theme.css": "resource custom",- "themes/custom/assets/font.woff2": "font",- "themes/daylight/theme.css": "resource daylight",- "themes/midnight/theme.css": "resource midnight",- "icons/custom/assets/image.png": "image",- "icons/litheness/icon.js": "resource litheness",+ "themes/custom/theme.css": "resource custom",+ "themes/custom/assets/font.woff2": "font",+ "themes/daylight/theme.css": "resource daylight",+ "themes/midnight/theme.css": "resource midnight",+ "icons/custom/assets/image.png": "image",+ "icons/litheness/icon.js": "resource litheness",+ "fonts/Noto-COLRv1-2.051/Noto-COLRv1.woff2": "emoji font",+ "fonts/Noto-COLRv1-2.051/LICENSE": "emoji license",} {data, err := os.ReadFile(filepath.Join(destination, "appearance", name))if err != nil || string(data) != expected {t.Errorf("%s: got %q, error %v", name, data, err)}}+ for _, name := range []string{"custom", "Noto-COLRv1-2.047"} {+ if _, err := os.Stat(filepath.Join(destination, "appearance", "fonts", name)); !os.IsNotExist(err) {+ t.Errorf("unexpected exported font directory %s: %v", name, err)+ }+ if _, err := os.Stat(filepath.Join(util.AppearancePath, "fonts", name)); err != nil {+ t.Errorf("source font directory %s was not preserved: %v", name, err)+ }+ }+}++func TestExportAppearanceReportsMissingEmojiFont(t *testing.T) {+ setupAppearancePackagesTest(t)+ if err := os.Remove(filepath.Join(util.AppearancePath, "fonts", "Noto-COLRv1-2.051", "Noto-COLRv1.woff2")); err != nil {+ t.Fatal(err)+ }+ if err := copyExportAppearance(t.TempDir(), "daylight", "litheness"); err == nil {+ t.Fatal("missing bundled emoji font was silently ignored")+ }}func TestRefreshAppearanceConfigFallsBackAfterRemoval(t *testing.T) {diff --git a/kernel/model/asset_download_regression_test.go b/kernel/model/asset_download_regression_test.goindex 09b329418e..a628e8faac 100644--- a/kernel/model/asset_download_regression_test.go+++ b/kernel/model/asset_download_regression_test.go@@ -95,6 +95,7 @@ func TestAssetDownloadFootnoteExport(t *testing.T) {appearancePath := util.AppearancePatht.Cleanup(func() { util.AppearancePath = appearancePath })util.AppearancePath = t.TempDir()+ writeAppearanceTestEmojiFont(t)for _, theme := range []string{Conf.Appearance.ThemeLight, Conf.Appearance.ThemeDark} {if err := os.MkdirAll(filepath.Join(util.AppearancePath, "themes", theme), 0755); err != nil {t.Fatal(err)diff --git a/kernel/model/export_footnotes_fts5_test.go b/kernel/model/export_footnotes_fts5_test.goindex 31b841743a..1352a1d79c 100644--- a/kernel/model/export_footnotes_fts5_test.go+++ b/kernel/model/export_footnotes_fts5_test.go@@ -45,6 +45,7 @@ func TestExportFootnotesAfterMerge(t *testing.T) {oldAppearance := util.AppearancePathutil.AppearancePath = t.TempDir()t.Cleanup(func() { util.AppearancePath = oldAppearance })+ writeAppearanceTestEmojiFont(t)for _, dir := range []string{"themes/daylight", "themes/midnight", "icons/litheness"} {if err := os.MkdirAll(filepath.Join(util.AppearancePath, dir), 0755); err != nil {t.Fatal(err)diff --git a/scripts/generate-third-party-notices.py b/scripts/generate-third-party-notices.pyindex 6d101730e1..6b5a4b5a71 100644--- a/scripts/generate-third-party-notices.py+++ b/scripts/generate-third-party-notices.py@@ -420,6 +420,13 @@ BUNDLED_COMPONENTS = ["https://github.com/unicode-org/cldr","Localized names and search keywords in app/appearance/emojis/conf.json",),+ (+ "Unicode Emoji test data",+ "17.0",+ "Unicode-3.0",+ "https://www.unicode.org/Public/17.0.0/emoji/emoji-test.txt",+ "New fully-qualified sequences in app/tests/fixtures/unicode17-emoji.json",+ ),("Pexels cover photos","72 selected photographs",@@ -453,6 +460,13 @@ FONT_COMPONENTS = [),("Noto COLRv1 Emoji",+ "2.051",+ "OFL-1.1",+ "https://github.com/googlefonts/noto-emoji",+ "app/appearance/fonts/Noto-COLRv1-2.051/LICENSE",+ ),+ (+ "Noto COLRv1 Emoji (retained version)","2.047","OFL-1.1","https://github.com/googlefonts/noto-emoji",