Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctex: 在 Mac 版 MiKTeX 中系统版本判断错误 #340

Closed
qiuzhu opened this issue Feb 22, 2018 · 9 comments
Closed

ctex: 在 Mac 版 MiKTeX 中系统版本判断错误 #340

qiuzhu opened this issue Feb 22, 2018 · 9 comments
Labels

Comments

@qiuzhu
Copy link

qiuzhu commented Feb 22, 2018

最近miktex更新大统一,也出了MAC版本的APP, 现在有个问题是采用xelatex编译中文文档,提示找不到simsun,simkai,看ctex文档在Mac下,ctex自动调用华文字库,不知道为啥默认调用了Windownew方案。
还有个奇怪的问题是,Mac下有宋体,而且粗体也有,为啥不能直接调用?

@nanmu42
Copy link

nanmu42 commented Feb 23, 2018

#313 其实很类似,有可能是MiKTeX不兼容CTeX宏包的系统判断那一套。

#313 (comment)

@leo-liu
Copy link
Member

leo-liu commented Apr 5, 2018

MiKTeX 真坑,我倾向于不改。

@qiuzhu
Copy link
Author

qiuzhu commented Apr 5, 2018

不知道miktex怎么坑了,我觉得现在大统一下的miktex越来越好,不像texlive,做的太累赘,用到的不及1%。

@zepinglee
Copy link
Member

试试 ifplatform 的机制行不行

@Liam0205
Copy link
Contributor

Liam0205 commented May 2, 2018

Mac 下的宋体问题,见 #351 。这是历史遗留问题,在老版本的 Mac 下,Songti SC 并不好用。

@Liam0205
Copy link
Contributor

Liam0205 commented May 2, 2018

平台选择问题,目前没有装 MiKTeX 到 Mac 上,没办法测试。回头可以调试看一看,但 MiKTeX 坑是实话。

ifplatform 应该是可以的,但是那需要打开 write18ctex 在设计时避免给用户添加这类麻烦,所以不到万不得已,不去用 ifplatform 的方案解决。

对于这个问题, @qiuzhu 可以先在宏包/文档类选项里加上 fontset = mac,通过手工指定字体配置的方式暂时绕过。

@Liam0205 Liam0205 changed the title mac os 下宋体问题 ctex: 在 Mac 版 MiKTeX 中系统版本判断错误 May 2, 2018
@maboloshi
Copy link

maboloshi commented Jun 10, 2018

貌似不仅仅是系统版本判断错误的问题, 用如下小实例 根本无法输出页面

% -*- coding: utf-8 -*-
%!TEX program = xelatex
\documentclass[fontset=none]{ctexart}
\setCJKmainfont{Songti SC}[
  UprightFont    = Songti SC Light,
  ItalicFont     = Kaiti SC,
  BoldItalicFont = Kaiti SC Bold,
]
\setCJKsansfont{Heiti SC}

\begin{document}
中文测试
\end{document}

untitled.log

系统版本为:10.14 Beta (18A293u)
ctex版本为:2.4.14

@WenboSheng
Copy link

MikTeX 思路不错,但至少现阶段确实坑啊。测试了一些代码发现其实涉及到好几个问题,但总而言之跟ctex其实没什么关系。

系统macOS High Sierra 10.13,MikTeX版本2.9.6637,ctex版本2.4.14

  1. 系统判断错误。
    经测试这个应该是MikTeX的锅,无法读取 /dev/null,在另一台10.13上面装了TeXLive2018是可以的。
    使用ifplatform也不行(开启了shell escape)
\documentclass{article}
\usepackage{ifplatform}
\usepackage[fontset=none]{ctex}

\begin{document}

ifplatform test:\\
\ifshellescape shell escape on\else shell escape off\fi\\
\IfFileExists{/dev/null}{dev null exists}{dev null not exists}\\
\ifwindows windows true \else windows false \fi

\ExplSyntaxOn
\LaTeX3 ~ test: \\
\file_if_exist:nTF { /dev/null } { dev ~ null ~ exists } { dev ~ null ~ not ~ exists } \\
\file_if_exist:nTF { /Library/Fonts/Songti.ttc } { Library ~ Fonts ~ Songti ~ exists } { Library ~ Fonts ~ Songti  ~ not ~ exists } \\
\ctex_detected_platform:
g_ctex_fontset_tl: ~ \g__ctex_fontset_tl \\
\ExplSyntaxOff

\end{document}

使用xelatex编译,输出为

ifplatform test:
shell escape on
dev null not exists
windows true
LATEX3 test:
dev null not exists
Library Fonts Songti exists
g_ctex_fontset_tl: windows

可见其实 /Library/Fonts/Songti.ttc 是能读取到的,但是最外层判断使用的 /dev/null 没读取到所以直接判断成windows了。而且ifplatform也如此,因为ifplatform如果读取不到/dev/null就直接判断为windows,不会再开启write18进一步判断了。

  1. 楼上提到的问题是另一回事,也就是Kaiti SC导入失败。我在字体册里面找了半天终于发现这是因为楷体的实际字体路径相当莫名其妙:
    /System/Library/Assets/com_apple_MobileAsset_Font4/8d69c72f04dcc2dfc086aa401dbab7f8ec55d0bb.asset/AssetData/Kaiti.ttc
    而MikTeX的字体配置文件没有包含这个路径,需要自己添加。我的MikTeX数据安装在本地用户下面,fontconfig配置文件位于 ~/Library/Application Support/MiKTeX/texmfs/config/fontconfig/config/下面,在localfonts2.conf里面手动添加字体路径。测试了下改成如下即可
<?xml version="1.0"?>
<fontconfig>
<dir>/System/Library/Assets/com_apple_MobileAsset_Font4</dir>
</fontconfig>

如下代码可以通过(xelatex编译)

\documentclass[fontset=mac]{ctexart}
\setCJKfamilyfont{hanno}{Hannotate SC}

\begin{document}
测试---\textit{测试}---\textbf{测试}---\texttt{测试}---{\CJKfamily{hanno} 测试}

\end{document}
  1. 如果用lualatex编译的话,由于使用os.name而不是判断/dev/null,因此可以正确判断Mac系统。但是上面第二个问题没有解决,导入楷体仍然失败,推测luatex可能并不使用fontconfig配置字体路径?(不确定,似乎是使用luaotfload)。

总之,xelatex无法识别系统,指定fontset选项,并且手动配置fontconfig后可以运行。lualatex可以识别系统,但是无法加载部分字体。

  1. 在另一台macOS 10.13,mactex2018环境下,lualatex编译也不能识别/System/Library/Assets/com_apple_MobileAsset_Font4下的楷体和仿宋字体。但是xelatex没有任何问题。

@Liam0205
Copy link
Contributor

现阶段不做任何改动,待 MiKTeX 更新后再说。这个 issue 先关了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants