Skip to content

Commit d89aa58

Browse files
songhahaha66da-liii
authored andcommitted
!484 [206_5] 重构is_emoji_character函数,支持assign指定方式显示emoji
1 parent ae2a92a commit d89aa58

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed

3rdparty/lolly/lolly/data/unicode.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ unicode_get_range (int code) {
110110
else if (code >= 0x2000 && code <= 0x23ff) return "mathsymbols";
111111
else if (code >= 0x2900 && code <= 0x2e7f) return "mathextra";
112112
else if (code >= 0x1d400 && code <= 0x1d7ff) return "mathletters";
113+
else if ((code >= 0x1F600 && code <= 0x1F64F) || // Emoticons
114+
(code >= 0x1F300 &&
115+
code <= 0x1F5FF) || // Misc Symbols and Pictographs
116+
(code >= 0x1F680 && code <= 0x1F6FF) || // Transport and Map Symbols
117+
(code >= 0x1F700 && code <= 0x1F77F) || // Alchemical Symbols
118+
(code >= 0x1F780 && code <= 0x1F7FF) || // Geometric Shapes Extended
119+
(code >= 0x1F800 && code <= 0x1F8FF) || // Supplemental Arrows-C
120+
(code >= 0x1F900 &&
121+
code <= 0x1F9FF) || // Supplemental Symbols and Pictographs
122+
(code >= 0x1FA00 && code <= 0x1FA6F) || // Chess Symbols
123+
(code >= 0x1FA70 &&
124+
code <= 0x1FAFF) || // Symbols and Pictographs Extended-A
125+
(code >= 0x2600 && code <= 0x26FF) || // Miscellaneous Symbols
126+
(code >= 0x2700 && code <= 0x27BF) || // Dingbats
127+
(code >= 0xFE00 && code <= 0xFE0F) || // Variation Selectors
128+
(code >= 0x1F1E6 && code <= 0x1F1FF) || // Regional Indicator Symbols
129+
code == 0x200D) // Zero Width Joiner
130+
return "emoji";
113131
else return "";
114132
}
115133

TeXmacs/tests/tmu/206_5.tmu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<TMU|<tuple|1.1.0|2025.1.0>>
2+
3+
<style|<tuple|generic|chinese|number-europe>>
4+
5+
<\body>
6+
<\hide-preamble>
7+
<assign|font|cjk=Noto CJK SC,emoji=Noto Color Emoji,CMU>
8+
</hide-preamble>
9+
10+
👋😀😄
11+
</body>
12+
13+
<\initial>
14+
<\collection>
15+
<associate|page-medium|paper>
16+
<associate|page-screen-margin|false>
17+
</collection>
18+
</initial>

devel/206_5.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 重构is_emoji_character函数
2+
3+
## 2025/08/01
4+
5+
### 如何测试
6+
7+
本次提交修改了lolly,所以需要执行
8+
9+
```bash
10+
xmake require --force lolly
11+
```
12+
13+
强制更新这个包
14+
15+
随后在206_5.tmu便可以不指定字体显示emoji(文件已经设置好assign)
16+
17+
### What
18+
19+
修改is_emoji_character和lolly中的unicode_get_range函数,为以后字体选择做准备
20+
21+
### How
22+
23+
修改了unicode.cpp(lolly)和unicode.cpp中的is_emoji_character函数
24+
25+
### Why
26+
27+
为以后字体选择做准备

src/Data/String/unicode.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@ get_unicode_range (string c) {
2727
}
2828

2929
bool
30-
is_emoji_character (unsigned int uc) {
31-
return (uc >= 0x1F600 && uc <= 0x1F64F) || // Emoticons
32-
(uc >= 0x1F300 && uc <= 0x1F5FF) || // Misc Symbols and Pictographs
33-
(uc >= 0x1F680 && uc <= 0x1F6FF) || // Transport and Map Symbols
34-
(uc >= 0x1F700 && uc <= 0x1F77F) || // Alchemical Symbols
35-
(uc >= 0x1F780 && uc <= 0x1F7FF) || // Geometric Shapes Extended
36-
(uc >= 0x1F800 && uc <= 0x1F8FF) || // Supplemental Arrows-C
37-
(uc >= 0x1F900 &&
38-
uc <= 0x1F9FF) || // Supplemental Symbols and Pictographs
39-
(uc >= 0x1FA00 && uc <= 0x1FA6F) || // Chess Symbols
40-
(uc >= 0x1FA70 &&
41-
uc <= 0x1FAFF) || // Symbols and Pictographs Extended-A
42-
(uc >= 0x2600 && uc <= 0x26FF) || // Miscellaneous Symbols
43-
(uc >= 0x2700 && uc <= 0x27BF) || // Dingbats
44-
(uc >= 0xFE00 && uc <= 0xFE0F) || // Variation Selectors
45-
(uc >= 0x1F1E6 && uc <= 0x1F1FF) || // Regional Indicator Symbols
46-
uc == 0x200D; // Zero Width Joiner
30+
is_emoji_character (int uc) {
31+
return lolly::data::unicode_get_range (uc) == "emoji";
4732
}

src/Data/String/unicode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#include "string.hpp"
1818

1919
string get_unicode_range (string c);
20-
bool is_emoji_character (unsigned int uc);
20+
bool is_emoji_character (int uc);
2121

2222
#endif

0 commit comments

Comments
 (0)