forum icon indicating copy to clipboard operation
forum copied to clipboard

ctexbook 与 emoji 联用

Open inkydragon opened this issue 5 years ago • 7 comments

检查

  • [x] 已在 issues 中进行搜索(包括已关闭的问题)

编译环境

  • 操作系统

    • [x] Windows 10
    • [ ] Windows 8/8.1
    • [ ] Windows 7
    • [ ] 更早版本的 Windows
    • [ ] macOS
    • [ ] Linux(请附发行版)
  • TeX 发行版

    • [x] TeX Live 2020
    • [ ] MiKTeX
    • [ ] CTeX 套装 2.9.2.164
    • [ ] 更早版本的 CTeX 套装

描述问题

使用 fontspec 为 emoji 指定字体,使用 book 文档类可以正常编译。 从 book 改为 ctexbook 后编译报错。

例子补充说明:

  • Twemoji Mozilla 字体包含这四个符号。
  • 根据 emoji-data 四个 emoji 的例子并非 unified 的形式:例如:
"name": "WAVY DASH",
"unified": "3030-FE0F",
"non_qualified": "3030",

X-Y Problem 备注:我的主要目的是排版所有单码点的 emoji。

最小工作示例(MWE)

\documentclass{ctexbook}
% \documentclass{book}

\usepackage{fontspec}
\newfontface\EmojiFont{Twemoji Mozilla}[Renderer=HarfBuzz]

\begin{document}

U+03030 | {\EmojiFont 〰}
U+0303D | {\EmojiFont 〽}
U+03297 | {\EmojiFont ㊗}
U+03299 | {\EmojiFont ㊙}

\end{document}

(用 lualatex-dev 编译后)输出

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

)
(see the transcript file for additional information)
 1025 words of node memory still in use:
   4 hlist, 1 vlist, 1 rule, 2 glue, 5 kern, 1 glyph, 249 attribute, 60 glue_sp
ec, 17 attribute_list, 1 write, 6 user_defined nodes
   avail lists: 1:8,2:1388,3:10,4:13,5:19,6:2,7:126,9:22,10:1
<c:/Windows/Fonts/simsun.ttc
! error:  (file c:/Windows/Fonts/simsun.ttc) (type 2): there are no glyphs in t
he subset
!  ==> Fatal error occurred, no output PDF file produced!

链接

我还做了这些尝试

  • 使用 lualatex 编译有同样的问题
  • 改用 \usepackage{luatexja-fontspec} 有同样问题
  • 尝试 ctexbook + luatexja-fontspec + \newjfontface
(c:/texlive/2020/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec-27c.st
y))
! Undefined control sequence.
<argument> ...topts_clist {YokoFeatures={JFM=\ltj@stdyokojfm
                                                  },TateFeatures={JFM=\ltj@s...

l.9
  • 尝试使用 emoji 宏包 + \emoji{wavy_dash}:”! Package emoji Error: The emoji name "wavy_dash" can't be found.“
  • 尝试使用 { \EmojiFont ^^^^^^003030^^^^fe0f } 的形式,问题依旧

附件

inkydragon avatar Jun 30 '20 12:06 inkydragon

luatexja 默认把 emoji 设为 JAchar,即使用 CJK 字体输出,所以要改为使用 \setjfontfamily 或者\newjfontface(它没有提供 \setjfontface)定义 emoji 字体。

CTeX 宏集内部调用 luatexja,但对 luatexja 的命令做了封装,不能直接使用,而应该用 \setCJKfamilyfont 或者 \newCJKfontfamily(它也没有提供 \setCJKfontface)。

emoji 宏包中,单词之间是用 - 分割的,所以应该写作 \emoji{wavy-dash}(你没看文档 🤣)。上面的问题也是存在的,我等会儿打个补丁修一下。

stone-zeng avatar Jun 30 '20 14:06 stone-zeng

比较坑的一点是:用 \newfontface ,1000 多 emoji 就这四个有问题,其他的都挺好。

inkydragon avatar Jun 30 '20 14:06 inkydragon

我试了下如果使用 \newCJKfontfamily\EmojiFont{Twemoji Mozilla}[Renderer=HarfBuzz] 则除了这四个之外,其余的 emoji 就都没了。 所以只有这四个需要特殊处理。

\documentclass{ctexbook}

\newfontface\EmojiFontOne{Twemoji Mozilla}[Renderer=HarfBuzz]
\newCJKfontfamily\EmojiFont{Twemoji Mozilla}[Renderer=HarfBuzz]

\begin{document}

\verb!\newCJKfontfamily\EmojiFont! \\
U+03030 | {\EmojiFont 〰}
U+0303D | {\EmojiFont 〽}
U+03297 | {\EmojiFont ㊗}
U+03299 | {\EmojiFont ㊙} \\


\verb!\newCJKfontfamily\EmojiFont! \\
U+02194 | {\EmojiFont ↔} 
U+02195 | {\EmojiFont ↕} \\

\verb!\newfontface\EmojiFontOne! \\
U+02194 | {\EmojiFontOne ↔} 
U+02195 | {\EmojiFontOne ↕} \\


\end{document}

image

inkydragon avatar Jun 30 '20 15:06 inkydragon

ctex 比较坑啊……我再看看

stone-zeng avatar Jun 30 '20 15:06 stone-zeng

我下了 ce38618 的 emoji.styemoji-table.def 放在同目录下,使用 \newCJKfontfamily 然后测试。 这四个是没问题,但其他的 emoji 还是显示不了。

测试代码,使用 lualatex-dev 编译
\documentclass{ctexbook}

\usepackage{./emoji}
\setemojifont{Twemoji Mozilla}
\newCJKfontfamily\EmojiFont{Twemoji Mozilla}[Renderer=HarfBuzz]

\begin{document}

\verb!\newCJKfontfamily\EmojiFont! \\
U+03030 | {\EmojiFont 〰}
U+0303D | {\EmojiFont 〽}
U+03297 | {\EmojiFont ㊗}
U+03299 | {\EmojiFont ㊙}
U+02194 | {\EmojiFont ↔} 
U+02195 | {\EmojiFont ↕} \\

\verb!\newCJKfontfamily\EmojiFont + \emoji{}! \\
U+03030 | \emoji{wavy-dash}
U+0303D | \emoji{part-alternation-mark}
U+03297 | \emoji{congratulations}
U+03299 | \emoji{secret}
U+02194 | \emoji{left-right-arrow} 
U+02195 | \emoji{left-right-arrow} \\

\end{document}

更长一些的测试

均使用 lualatex-dev "mwe.tex" 编译

inkydragon avatar Jul 01 '20 15:07 inkydragon

可以和字体命令一起使用 \ltj@allalchar ,避免把 emoji 设为 JAchar。

{\ltj@allalchar\EmojiFont ㊗}

qinglee avatar Jul 01 '20 15:07 qinglee