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

Mac下找不到字体 #45

Closed
jinyu121 opened this issue Jan 10, 2019 · 9 comments
Closed

Mac下找不到字体 #45

jinyu121 opened this issue Jan 10, 2019 · 9 comments

Comments

@jinyu121
Copy link
Contributor

Mac下找不到字体。有几个:

Package fontspec Error: The font "XITS" cannot be found. \documentclass{fduthesis} \begin{document}

Font TU/XITS(0)/m/n/12.045=XITS at 12.045pt not loadable: Metric (TFM) file or installed font not found. \documentclass{fduthesis} \begin{document}

Package fontspec Error: The font "TeX Gyre Heros" cannot be found. \documentclass{fduthesis} \begin{document}

Package fontspec Error: The font "XITS Math" cannot be found. \documentclass{fduthesis} \begin{document}

Package fontspec Error: The font "FandolSong" cannot be found. \documentclass{fduthesis} \begin{document}

Package fontspec Error: The font "FandolKai" cannot be found. \documentclass{fduthesis} \begin{document}

@stone-zeng
Copy link
Owner

fontspec 文档中有关于此的说明:

In XeTeX, fonts found in the TEXMF tree can be loaded in Windows and Linux, but not on macOS.

然而在 fduthesis 中,我都是用字体名(而非文件名)。可以试一下在导言区加上

\setmainfont{XITS}[
  Extension=.otf,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic]
\setsansfont{texgyreheros}[
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic]
\setmonofont{texgyrecursor}[
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic]

这边以 times 风格为例,当然换成其他的也可以。至于中文字体的话,建议用 style/cjk-font=mac,省得配置了。

@stone-zeng
Copy link
Owner

字体配置可能近段时间需要大改,这个 issue 先留这里了。

@jinyu121
Copy link
Contributor Author

备忘: https://email.esm.psu.edu/pipermail/macosx-tex/2010-August/044926.html

@zepinglee
Copy link

mac 上 texmf 的字体只能通过文件名调用,另外 XITS 字体在去年 10 改过一次文件名,如果考虑兼容性最好判断一下,参考

https://github.com/xueruini/thuthesis/blob/0d3776f3bf654ed154c5a4aae8f1a148d75a184d/thuthesis.dtx#L1512

@stone-zeng
Copy link
Owner

实验了一下,大概是这样:

File Name (XeLaTeX) File Name (LuaLaTeX) Font Name (XeLaTeX) Font Name (LuaLaTeX)
macOS (System) ×
macOS (TEXMF) ×
Windows/Linux (System)
Windows/Linux (TEXMF)

反正 XeLaTeX 必有一个会炸 😂。

@zepinglee 你看看还有没有其他问题?

@zepinglee
Copy link

应该没问题

@hzy46
Copy link

hzy46 commented Feb 22, 2019

mac下终于搞好了,耗时2小时。。步骤如下:
下载mactex (https://mirrors.ustc.edu.cn/CTAN/systems/mac/mactex/ ) 双击根据向导安装。
下载本repo:

git clone https://github.com/stone-zeng/fduthesis.git

按@jinyu121的方法解决max下字体问题:

Open the Font Book application. For convenience create a File->New Library > (Opt-Cmd-N), give it a name and have it selected. Then File->Add Fonts… and > then (here's the trick) use the Go To Folder… command shortcut (Shift-Cmd-G) > which will open up a dialog box to put in the path to the font folder. Enter > /usr/local/texlive/2010/texmf-dist/fonts/opentype and press return.

其中 /usr/local/texlive/2010/texmf-dist/路径根据textlive版本各有不同,我的是 /usr/local/texlive/2018/texmf-dist/fonts/opentype

回到fduthesis路径执行:

sh install-linux.sh
sh source/run.sh

前者安装模板,后者生成一堆logo文件,复制一个到fduthesis文件夹:

cp logo/fudan-name-black.pdf fudan-name.pdf

更改thesis/fduthesis-template.tex中的logo = {../logo/pdf/fudan-name-black.pdf},将其注释掉,然后反注释logo = {fudan-name.pdf}

编译两次:

xelatex thesis/fduthesis-template.tex 
xelatex thesis/fduthesis-template.tex 

就可以了。。。配latex环境真的是精神伤害。。

@zepinglee
Copy link

@hzy46 嗯这样可以让 xelatex 通过字体名识别。稍微改进一下的方法是

ln -s /usr/local/texlive/2018/texmf-dist/fonts/opentype ~/Library/Fonts/

这样就可以让字体跟随 tlmgr 进行更新了。

当然,最好还是等 @stone-zeng 把模板改得更通用一点吧

@stone-zeng
Copy link
Owner

目前,在 working 分支下已基本兼容 macOS 平台,欢迎测试。

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

No branches or pull requests

4 participants