-
Notifications
You must be signed in to change notification settings - Fork 2
Description
讨论
TeX 中的虚拟字体
似乎最早是为解决字体的256数量限制,后来又发展出别的功能,比如拼合不同字体的字符覆盖范围(A字体的字母 + B字体的数学符号,或者C字体的小写字母+D字体的大写字母这种)。
当前 typst 只有text.font回落机制。
虚拟字体能在 typst 解决的需求
-
拼合字体
例如将专门的字体用于
math.cal。目前(v0.13.1)文档写了ss01方法,但 typst 内置的ss01版 New Computer Modern 与 LaTeX\mathscr的细节略微不同,想要实现100%原样。 -
不同字重、风格使用不同字体
设置中文字体的简单方式。用户可以为不同的字形(font shape)指定字体(font family),并且为每个元素设置使用什么字形。例如,我可以设置普通文本使用 FandolSong,加粗文本使用 FandolHei 或粗体的 FandolSong。
https://forum.typst.app/t/chinese-layout-gap-analysis-clreq-gap-for-typst/4691/21例如 CTeX
\setCJKmainfont{SimSun}[BoldFont=SimHei, ItalicFont=KaiTi],普通用宋体,加粗用黑体,倾斜用楷体。不过我和一部分人认为这应在语义而非字体层面解决。黑体和楷体是两种强调方式,楷体本身并不倾斜。CTeX 之所以按字体解决,也许是 LaTeX 技术限制。
然而实事求是,目前 typst 的
strong、emph与加粗、倾斜分别高度绑定。双层strong字重递增,双层emph斜正交替。如果你绞尽脑汁给复杂结构的语义上样式,那么结构已经有些杂乱了
-
拼合不同字重的字体
比如用西文字体的 extra bold 配中文字体的 bold。
-
分字体设置样式
协调各字体的基线、字号(Size per font typst/typst#6295)、高度、字距(forum)等。
-
text的参数列表更简洁
Addtext.contextual-alternatesfor the OpenType featurecalttypst/typst#6963 -
由包提供字体
可以让包提供字体对象,实现分发字体。
Load fonts / font families from files or bytes typst/typst#2469
typst 实现虚拟字体的可能性
好像 LuaTeX 把 OpenType API 仿真了一遍。
font object 曾有 PR typst/typst#4093,但关了。
I left a few comments in the Fonts forge on Discord.
typst/typst#4093 (comment)
I think unfortunately this needs more design work before we can proceed with the implementation, so I'll close this for now. :/
typst/typst#4093 (comment)
Note
以上可以提交到 https://github.com/typst-community/rfcs 。
资料
§33.6.2 Virtual fonts — TeX by Topic
With ‘virtual fonts’ (see D.E. Knuth.1990 Virtual fonts: more fun for grand wizards) it is possible that what looks like one font to TeX resides in more than one physical font file. Also, virtual fonts can be used to change in effect the internal organization of font files.
Boris Veytsman 2010 Are virtual fonts obsolete?
Virtual fonts (VF) were created to address a shortcoming of TEX fonts: each slot address occupied exactly one byte, so there were no more than 256 different characters per font. Later, when PostScript fonts got popular, VF became the way of choice for integration of these fonts with TEX. Today new font formats can be directly read by the modern TEX engines, and, for example, XE TEX can directly work with system fonts. There is a temptation to declare VF obsolete.
In this paper we show that there is much more in VF than just making PostScript fonts available for TEX. There are various tricks developed over the years that use VF technology to achieve new striking effects.
The aim of this paper is to convince the users to learn how to employ VF, and to convince the programmers of the new engines to provide the interface for font manipulation comparable to VF.
LLM 总结以上两篇 tug boat:
这两篇文章都探讨了 TeX 中的虚拟字体(VF)技术,并对其在现代 TeX 环境下的应用进行了分析。
第一篇文章 源自 1990 年,由 Donald Knuth 撰写,介绍了虚拟字体的概念和设计初衷。当时,由于 TeX 字体格式限制,每个字体只能包含 256 个字符,而 VF 技术允许 TeX 用户通过映射将 TeX 字符与实际设备上的字符进行匹配,从而突破了这一限制,并实现了多种字体格式与 TeX 的集成。
第二篇文章 源自 2010 年,由 Boris Veytsman 撰写,探讨了 VF 技术在现代 TeX 环境下的应用和局限性。文章指出,随着现代 TeX 引擎(如 XeTeX)对多种字体格式的直接支持,以及 OpenType 字体丰富的功能,VF 技术似乎逐渐被边缘化。然而,文章也强调了 VF 技术在实现一些特殊效果和字体混合方面的优势,例如:
- 添加数学符号: 对于缺乏数学符号的字体,可以使用 VF 技术从其他字体中提取符号进行补充。
- 字体效果: 可以使用 VF 技术实现字体缩放、倾斜、连字和间距调整等效果。
- 字体混合: 可以将不同字体的字符组合在一起,创造出新的字体风格。
核心观点:
- VF 技术并非过时: 尽管现代 TeX 环境提供了更便捷的字体处理方式,但 VF 技术在实现特殊效果和字体混合方面仍然具有优势。
- VF 技术学习曲线陡峭: VF 技术的设置和使用需要一定的技术门槛,对于新手用户来说可能比较困难。
- 现代 TeX 引擎需要提供类似 VF 的接口: 为了方便用户进行低级字体操作,现代 TeX 引擎需要提供类似 VF 的接口,以支持更丰富的字体处理功能。
ISO/IEC 14496-28:2012 - Information technology — Coding of audio-visual objects — Part 28: Composite font representation
This part of ISO/IEC 14496 specifies the Composite Font Representation, an XML-based document format that allows combining individual component font resources into a single virtual font. Recent advances in developing the Unicode Standard and the addition of new characters that represent most of the world's languages and writing systems have resulted in a significant increase of the Unicode character repertoire, and this process is likely to continue in the future. Therefore, the ability to combine a number of individual fonts supporting different languages and Unicode ranges in a single virtual font description provides the opportunity for various users and creators of multimedia, graphics and textual content to support all of the world's languages and utilize the existing font rendering solutions that are implemented in current computing platforms and deployed in many existing devices.
该标准零元购,但不需要具体付款信息,但付款地区不能选中国。
CFR 标准似乎只能拼合不同语言字体的字符,比如 Times New Roman + 宋体的汉字部分,而不涉及 strong、emph 这些。