CTeX-org / forum

A temporarily alternate forum of `bbs.ctex.org`
https://t.me/chinesetex
Apache License 2.0
210 stars 16 forks source link

The font "SimHei" cannot be found.无法用伪粗体规避 #297

Open gingerkitti opened 9 months ago

gingerkitti commented 9 months ago

检查

编译环境

描述问题

编译报错SimHei not found, 我尝试用\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{SimSun}来规避这个问题。但是仍然报错是SimHei not found

我注意到TeXworks console output有

Sorry, but miktex-makemf did not succeed.

尝试过updmap,但是仍然没有用

我的MikTex安装方式“user”(仅为自己安装),由于在公司电脑,权限很低,无法自行安装软件以及连接外网,因此也不能下载字体

这是我的编译设置:菜单 -> Edit -> TeXworks Preferences -> Processing tools -> XeLaTeX+MakeIndex+BibTex -> Tool Configuration设置为

Name:       XeLaTeX+MakeIndex+BibTeX
Program:    texify.exe
Arguments:  --pdf
        --engine=xetex
        --synctex=1
        --clean
        $fullname

最小工作示例(MWE)

\documentclass{ctexart}

\setCJKmainfont[
AutoFakeBold,AutoFakeSlant
]{SimSun}

\begin{document}

\textbf{你好}

\end{document}

我还做了这些尝试

附件

用 XeLaTeX+MakeIndex+BibTex 编译后,日志文件输出: ```latex This is XeTeX, Version 3.141592653-2.6-0.999995 (MiKTeX 23.10) (preloaded format=xelatex.fmt) restricted \write18 enabled. entering extended mode (C:/Users/Test Virtual Machine/Desktop/untitled-1.tex LaTeX2e <2023-06-01> patch level 1 L3 programming layer <2023-08-29> (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex\cte xart.cls (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/con fig\ctexbackend.cfg) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/l3kernel \expl3.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/l3backen d\l3backend-xetex.def)) Document Class: ctexart 2022/07/14 v2.5.10 Chinese adapter for class article (C TEX) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex\cte xhook.sty) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex\cte xpatch.sty) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/base\fix -cm.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1 enc.def)) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/con fig\ctexopts.cfg) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/base\art icle.cls Document Class: article 2023/05/17 v1.4n Standard LaTeX document class (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/base\siz e10.clo)) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/eng ine\ctex-engine-xetex.def (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/xelatex/xecjk\ xeCJK.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/l3packag es/xtemplate\xtemplate.sty) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/fontspec \fontspec.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/l3packag es/xparse\xparse.sty) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/fontspec \fontspec-xetex.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/base\fon tenc.sty) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/fontspec \fontspec.cfg))) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/xelatex/xecjk\ xeCJK.cfg))) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/zhnumber \zhnumber.sty (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/zhnumber \zhnumber-utf8.cfg)) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/sch eme\ctex-scheme-chinese-article.def (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/con fig\ctex-name-utf8.cfg)) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex\cte x-c5size.clo) (C:\Users\Test Virtual Machine\AppData\Local\Programs\MiKTeX\tex/latex/ctex/fon tset\ctex-fontset-windows.defRunning miktex-makemf.exe... Sorry, but miktex-makemf did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log Running miktex-hbf2gf.exe... Couldn't open `OT:script=hani;language=dfl.cfg' hbf2gf (CJK ver. 4.8.4) Sorry, but miktex-maketfm did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log Running miktex-makemf.exe... Sorry, but miktex-makemf did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log Running miktex-hbf2gf.exe... Couldn't open `OT:script=hani;language=dfl.cfg' hbf2gf (CJK ver. 4.8.4) Sorry, but miktex-maketfm did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log Running miktex-makemf.exe... Sorry, but miktex-makemf did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log Running miktex-hbf2gf.exe... Couldn't open `OT:script=hani;language=dfl.cfg' hbf2gf (CJK ver. 4.8.4) Sorry, but miktex-maketfm did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log Running miktex-makemf.exe... Sorry, but miktex-makemf did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log Running miktex-hbf2gf.exe... Couldn't open `OT:script=hani;language=dfl.cfg' hbf2gf (CJK ver. 4.8.4) Sorry, but miktex-maketfm did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log Running miktex-makemf.exe... Sorry, but miktex-makemf did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log Running miktex-hbf2gf.exe... Couldn't open `OT:script=hani;language=dfl.cfg' hbf2gf (CJK ver. 4.8.4) Sorry, but miktex-maketfm did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-maketfm.log ! Package fontspec Error: The font "SimHei" cannot be found. For immediate help type H . ... l.101 } ? ```
这是 C:\Users\Test Virtual Machine\AppData\Local\MiKTeX\miktex\log\miktex-makemf.log ``` 2023-10-14 04:43:18,510-0700 INFO miktex-makemf - this process (2916) started by miktex-maketfm in directory C:\Users\TESTVI~1\AppData\Local\Temp\mik69346 with command line: miktex-makemf.exe --miktex-enable-installer --miktex-disable-maintenance --miktex-disable-diagnose --verbose OT:script=hani;language=dflt; 2023-10-14 04:43:18,712-0700 INFO miktex-makemf - running on Windows 10.0.19044 2023-10-14 04:43:18,872-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:43:18,886-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:43:18,886-0700 FATAL miktex-makemf - Info: 2023-10-14 04:43:18,886-0700 FATAL miktex-makemf - Source: 2023-10-14 04:43:18,886-0700 FATAL miktex-makemf - Line: 0 2023-10-14 04:43:19,151-0700 INFO miktex-makemf - this process (2916) finishes with exit code 1 2023-10-14 04:44:39,511-0700 INFO miktex-makemf - this process (8140) started by miktex-maketfm in directory C:\Users\TESTVI~1\AppData\Local\Temp\mik79909 with command line: miktex-makemf.exe --miktex-enable-installer --miktex-disable-maintenance --miktex-disable-diagnose --verbose OT:script=hani;language=dflt; 2023-10-14 04:44:39,511-0700 INFO miktex-makemf - running on Windows 10.0.19044 2023-10-14 04:44:39,527-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:44:39,949-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:44:39,949-0700 FATAL miktex-makemf - Info: 2023-10-14 04:44:39,949-0700 FATAL miktex-makemf - Source: 2023-10-14 04:44:39,949-0700 FATAL miktex-makemf - Line: 0 2023-10-14 04:44:40,386-0700 INFO miktex-makemf - this process (8140) finishes with exit code 1 2023-10-14 04:45:20,304-0700 INFO miktex-makemf - this process (9440) started by miktex-maketfm in directory C:\Users\TESTVI~1\AppData\Local\Temp\mik27784 with command line: miktex-makemf.exe --miktex-enable-installer --miktex-disable-maintenance --miktex-disable-diagnose --verbose OT:script=hani;language=dflt; 2023-10-14 04:45:20,304-0700 INFO miktex-makemf - running on Windows 10.0.19044 2023-10-14 04:45:20,367-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:45:20,367-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:45:20,367-0700 FATAL miktex-makemf - Info: 2023-10-14 04:45:20,383-0700 FATAL miktex-makemf - Source: 2023-10-14 04:45:20,383-0700 FATAL miktex-makemf - Line: 0 2023-10-14 04:45:20,665-0700 INFO miktex-makemf - this process (9440) finishes with exit code 1 2023-10-14 04:45:50,336-0700 INFO miktex-makemf - this process (9700) started by miktex-maketfm in directory C:\Users\TESTVI~1\AppData\Local\Temp\mik42582 with command line: miktex-makemf.exe --miktex-enable-installer --miktex-disable-maintenance --miktex-disable-diagnose --verbose OT:script=hani;language=dflt; 2023-10-14 04:45:50,336-0700 INFO miktex-makemf - running on Windows 10.0.19044 2023-10-14 04:45:50,555-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:45:50,555-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:45:50,555-0700 FATAL miktex-makemf - Info: 2023-10-14 04:45:50,555-0700 FATAL miktex-makemf - Source: 2023-10-14 04:45:50,555-0700 FATAL miktex-makemf - Line: 0 2023-10-14 04:45:50,888-0700 INFO miktex-makemf - this process (9700) finishes with exit code 1 2023-10-14 04:46:33,339-0700 INFO miktex-makemf - this process (10088) started by miktex-maketfm in directory C:\Users\TESTVI~1\AppData\Local\Temp\mik757 with command line: miktex-makemf.exe --miktex-enable-installer --miktex-disable-maintenance --miktex-disable-diagnose --verbose OT:script=hani;language=dflt; 2023-10-14 04:46:33,339-0700 INFO miktex-makemf - running on Windows 10.0.19044 2023-10-14 04:46:33,933-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:46:33,933-0700 FATAL miktex-makemf - The OT:script=hani;language=dflt; source file could not be found. 2023-10-14 04:46:33,933-0700 FATAL miktex-makemf - Info: 2023-10-14 04:46:33,933-0700 FATAL miktex-makemf - Source: 2023-10-14 04:46:33,933-0700 FATAL miktex-makemf - Line: 0 2023-10-14 04:46:33,999-0700 INFO miktex-makemf - this process (10088) finishes with exit code 1 ```
muzimuzhi commented 9 months ago

我尝试用\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{SimSun}来规避这个问题。但是仍然报错是SimHei not found

伪粗体、伪斜体依然需要加载原本的字体,所以这从来不是一个规避的办法。我不在 windows 下,留给用 windows 的用户提供帮助吧。

sikouhjw commented 9 months ago

问题在于,在 \setCJKmainfont 之前,ctex 宏集会预加载 windows 下的字体,而此时已经使用了 SimHei

所以,应该使用 \documentclass[fontset=none]{ctexart} 来避免字体的预加载。

muzimuzhi commented 9 months ago

问题在于,在 \setCJKmainfont 之前,ctex 宏集会预加载 windows 下的字体,而此时已经使用了 SimHei

@sikouhjw 这不冲突吧,在 preamble 里 \setCJKmainfont 可以重复使用。

例如,在 overleaf 的 linux 环境里,下面「把 FandolSong 两次设为 CJK main font」的例子,不报错。

\documentclass{ctexart}
\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{FandolSong}

\begin{document}
\textbf{你好}
\end{document}

@gingerkitti 只加载 fontspec,试试能使用 windows 系统自带的其他 otf 字体(不论中文西文)吗,MiKTeX 自带的 otf 字体(不论中文西文)呢?

sikouhjw commented 9 months ago

@sikouhjw 这不冲突吧,在 preamble 里 \setCJKmainfont 可以重复使用。

例如,在 overleaf 的 linux 环境里,下面「把 FandolSong 两次设为 CJK main font」的例子,不报错。

我理解他的问题是「miktex 找不到 SimHei」,那问题就在于 ctex 的内部字体加载。

\setCJKmainfont 可以重复加载,但是后面的命令不会覆盖前面的命令,也就是说第一个 \setCJKmainfont 如果找不到字体,就会报错,而不会被第二个覆盖。

\documentclass{ctexart}
\setCJKmainfont{SimSun}[BoldFont=aaaa.otf]
\setCJKmainfont{SimSun}
\begin{document}
    test
\end{document}

所以解决他的办法:fontset=fandol 或者 =none 再自己配字体。

muzimuzhi commented 9 months ago

@sikouhjw 啊,是我把 SimHeiSimSun 看成一个字体名了。现在我明白「用伪粗规避」和你提的 fontset=none 建议的意思了。抱歉

更新:想起我自己之前在 GitHub Actions 的 windows hoster 上跑 ctex 也遇到过这个问题,

SimHei is part of the Chinese (Simplified) Supplemental Fonts in Win 10. Thus all we need here is to install those supplemental fonts.

_Originally posted by @muzimuzhi in https://github.com/muzimuzhi/hello-github-actions/pull/10#discussion_r1163720425_

这下我也理解

由于在公司电脑,权限很低,无法自行安装软件以及连接外网,因此也不能下载字体

的意思了。

gingerkitti commented 9 months ago

非常感谢各位的帮忙。我后来在StackExchange也提了个类似的问题,

SimHei is not SimSun, and updmap has nothing to do with using fonts with fontspec. Try \documentclass[fontset=fandol]{ctexart} – Ulrike Fischer 19 hours ago

我照着评论的代码试了一下,居然成功了。

我又查了一下《CTEX 宏集手册》(2022/07/14 v2.5.10),发现第8页(4.3节)有这样一句话

注意:如果希望使用 \ctexset 在导言区指定字库,则需要先在宏包/文档类选项中指定 fontset = none(这会禁用 CTEX 宏集的操作系统检测功能和自动设定字库功能)。

我猜测可能跟这个有关系。之前我看手册里fontset后面没有“五角星”也没有“*”,也就没有管太多了。

我试了一下,如果说先这样设置\documentclass[fontset=none]{ctexart},后面不使用fandol,直接用伪粗体、伪斜体也是可以的,最终也可以输出伪粗伪斜。


@muzimuzhi 我试了一下应该是可以的

只加载 fontspec,试试能使用 windows 系统自带的其他 otf 字体(不论中文西文)吗,MiKTeX 自带的 otf 字体(不论中文西文)呢?

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Microsoft YaHei}
\begin{document}
\textbf{你好}
\end{document}

一些可能的题外话

虽然编译过程中还是会有很多Sorry, but miktex-makemf did not succeed.,但是并不影响结果,我也就没有多管它了(主要是超出了自己的能力范围),如果各位对于这个内容有什么见解还请多多指教(我也不知道这需不需要开新issue)

本来想睡一觉再想想怎么关掉这个issue,但是没想到各位这么热心,一觉功夫就有这么多评论,非常感谢各位的帮忙。

muzimuzhi commented 9 months ago

虽然编译过程中还是会有很多Sorry, but miktex-makemf did not succeed.,但是并不影响结果

可以发第一例出来看看。