xelatex使用从windows拷过来的系统字体

本文介绍了如何在 XeLaTeX 文档中使用从 Windows 系统复制的楷体和宋体。通过 extbackslash usepackage{CJKutf8} 和 extbackslash begin{CJK}{UTF8}{字体类型} 代码,实现了对汉字的支持,展示了楷体和宋体的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

版本:texlive2011 ubuntu11.04
以root身份执行:
#cp -r /media/Windows/Fonts/* /usr/share/fonts
#fc-cache
#fc-list
#exit
$less test.tex
  1 \documentclass{article}
  2 \usepackage{fontspec}
  3 \setmainfont{SimSun}
 
  5 \begin{document}
  6 好啊!hello world
  7 \end{document}
$xelatex test.tex
出现如下错误:

kpathsea: Running mktexmf SimSun
! I can't find file `SimSun'.
<*> ...:=ljfour; mag:=1;nonstopmode; input SimSun
                                          
Please type another input file name
! Emergency stop.
<*> ...:=ljfour; mag:=1;nonstopmode; input SimSun
                                          
Transcript written on mfput.log.
grep: SimSun.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1;nonstopmode; input SimSun' failed to make SimSun.tfm.
kpathsea: Appending font creation commands tomissfont.log.


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! The font "SimSun" cannot be found.
! See the fontspec documentation for furtherinformation.
! For immediate help type H<return>.
!............................................... 
                                          
l.3 \setmainfont{SimSun}
                    


出现错误的原因是:用root拷过来的字体文件的权限是600,使得xelatex无法正常访问字体,出现字体找不到错误。
执行:
sudo chmod 755 /usr/share/fonts/*#此处要注意,文件夹一定要赋予x权限,否则你的系统就会全是框框了。
接下来写一个文件测试下:
vim test.tex
写入如下内容:
  1. \usepackage{CJKutf8}
  2. \begin{document}
  3. \begin{CJK}{UTF8}{gkai}
  4. 我是楷体
  5. \end{CJK}
  6. \begin{CJK}{UTF8}{gbsn}
  7. 我是宋体
  8. \end{CJK}
  9. \end{document}
用xelatex编译下:
xelatex test.tex
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值