Skip to content

Commit e5f6d0a

Browse files
songhahaha66da-liii
authored andcommitted
!488 [206_7] Emoji字体自动选择
1 parent 34bbf2c commit e5f6d0a

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

TeXmacs/tests/tmu/206_7.tmu

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<TMU|<tuple|1.1.0|2025.1.0>>
2+
3+
<style|<tuple|generic|chinese|number-europe>>
4+
5+
<\body>
6+
<doc-data|<doc-title|😀Emoji支持>>
7+
8+
<section|Mogan已经支持Emoji渲染🎉>
9+
10+
Enjoy it!🎉🎉🎉🎉🎉🎉🎉
11+
</body>
12+
13+
<\initial>
14+
<\collection>
15+
<associate|page-medium|paper>
16+
<associate|page-screen-margin|false>
17+
</collection>
18+
</initial>
19+
20+
<\references>
21+
<\collection>
22+
<associate|auto-1|<tuple|1|?>>
23+
</collection>
24+
</references>

devel/206_7.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Emoji字体自动选择
2+
3+
## 2025/08/02
4+
5+
### 如何测试
6+
7+
206_7.tmu
8+
9+
### What
10+
11+
新加emoji字体自动选择
12+
13+
### How
14+
15+
修改了smart_font.cpp和font.cpp,font.hpp
16+
17+
### Why
18+
19+
需要自动选择emoji字体,免去手动选择

src/Graphics/Fonts/font.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,18 @@ default_korean_font_name () {
650650
return "roman";
651651
}
652652

653+
string
654+
default_emoji_font_name () {
655+
if (has_user_preference ("default emoji font name")) {
656+
return get_user_preference ("default emoji font name");
657+
}
658+
659+
// Noto Color Emoji is the default emoji font on all system if exists
660+
if (tt_font_exists ("NotoColorEmoji")) return "Noto Color Emoji";
661+
662+
return "roman";
663+
}
664+
653665
bool
654666
use_macos_fonts () {
655667
#ifdef OS_MACOS

src/Graphics/Fonts/font.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct font_rep : rep<font> {
184184
string default_chinese_font_name ();
185185
string default_japanese_font_name ();
186186
string default_korean_font_name ();
187+
string default_emoji_font_name ();
187188

188189
font error_font (font fn);
189190
font virtual_font (font base, string fam, int sz, int hdpi, int vdpi, bool ext);

src/Graphics/Fonts/smart_font.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,15 @@ math_fix (string family, string series, string shape) {
591591
return family;
592592
}
593593

594+
string
595+
emoji_fix (string family, string series, string shape) {
596+
if (contains (family, "emoji=")) {
597+
return family;
598+
}
599+
string name= default_emoji_font_name ();
600+
return family * ",emoji=" * name;
601+
}
602+
594603
/******************************************************************************
595604
* The smart font class
596605
******************************************************************************/
@@ -1690,6 +1699,7 @@ smart_font_bis (string family, string variant, string series, string shape,
16901699
family= kepler_fix (family, series, shape);
16911700
// family= stix_fix (family, series, shape);
16921701
family = math_fix (family, series, shape);
1702+
family = emoji_fix (family, series, shape);
16931703
string sh= shape;
16941704
if (shape == "mathitalic" || shape == "mathshape") sh= "right";
16951705
string mfam = main_family (family);

0 commit comments

Comments
 (0)