如何使用 XeTeX 获取所有可用 (TTF-) 字体的列表?
非常巧妙的是,我可以在我的 Windows 机器上通过 MikTex 和 XeTeX 使用任何可用的 TrueType 字体。
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[]{article}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\title{Fonttest}
\begin{document}
\section{Section Title} {
\setromanfont{Palatino Linotype}
The quick brown fox jumps over the lazy dog.
}
\section{Section Title} {
\setromanfont{ProggyCleanTTSZBP}
The quick brown fox jumps over the lazy dog.
}
\end{document}
有没有办法为每种可用字体自动生成字体测试页?这样我就不必手动为每种可用字体键入测试页?
实际上,我什至不知道如何获取 \setromanfont
所需的长字体名称——除了从屏幕上输入它之外。显然,Windows 目录仅列出文件名。也许这可以在 TeX 本身中完成,但我可以使用 Python 脚本或类似脚本来管理它。
Very neat that I can use any available TrueType font on my Windows machine with MikTex and XeTeX.
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[]{article}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\title{Fonttest}
\begin{document}
\section{Section Title} {
\setromanfont{Palatino Linotype}
The quick brown fox jumps over the lazy dog.
}
\section{Section Title} {
\setromanfont{ProggyCleanTTSZBP}
The quick brown fox jumps over the lazy dog.
}
\end{document}
Is there a way to automatically generate a font test page for every available font? So that I do not have to type a test page for every available font by hand?
Actually, I do not even know how to get to the Long Font Name required for \setromanfont
-- short of typing it from the screen. The Windows directory only lists the file names, obviously. Maybe this can be done in TeX itself, but I could manage it with a Python script or such like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
两步方法
1. 构建可用字体列表
为此可以使用 albatross,它是 texlive 等 tex 发行版中包含的一个命令行工具。它旨在查找包含某些字形的字体,例如,如果您想用英语排版文本,您可以使用类似的内容
(将
The
替换为您的字体应该能够排版的任何字形)将为您提供字体名称列表
2. 生成测试页
您可以获取步骤 1 中生成的字体名称列表,并让 Latex 对其进行迭代
A two-step-approach
1. Building list of available fonts
For this one can use
albatross
, a command line tool included in tex distributions like texlive. It is designed to find fonts which include certain glyphs, e.g. if you want to typeset a text in English, you can use something like(replace
T h e
with whatever glyphs your font should be able to typeset)This will give you a list of font names
2. Producing a test page
You can take the list of font names produced in step 1 and let latex iterate over them
不是一个可行的答案,而是一个想法。您所要做的就是迭代所有已安装的字体系列,其中存在 API 函数:
EnumFontFamiliesEx
。Not a worked out answer, but an idea. All you have to do is iterate over all installed font families, for which an API function exists:
EnumFontFamiliesEx
.