简体   繁体   English

Unicode 字符如何映射到字体中的字形?

[英]How does a Unicode character get mapped to a glyph in a font?

I am wondering, that each char in Unicode has a code point;我想知道,Unicode 中的每个字符都有一个代码点; what's the analogous term for a character in a font?字体中字符的类似术语是什么?

I never understood the part of the process when a decoded file needs to be mapped to font (or fonts, by some modern font substitution technology).当解码文件需要映射到字体(或 fonts,通过一些现代字体替换技术)时,我从来不理解该过程的一部分。

For example, when a text editor has decoded a file from its character encoding, and suppose there's Greek alpha α (U+03B1).例如,当文本编辑器从其字符编码解码文件时,假设有希腊字母 α (U+03B1)。 What's the exact process this app chooses a particular glyph in a font?这个应用程序在字体中选择特定字形的确切过程是什么? Most app has a preferred font.大多数应用程序都有首选字体。 Let's say it's Courier.假设它是快递。 (And what happens in the case of a rare Unicode char likethe heart ♥ (U+2665), that's not in the default font? How does the app know the font doesn't contain that char?) (在罕见的 Unicode char likethe heart ♥ (U+2665) 的情况下会发生什么,这不是默认字体?应用程序如何知道字体不包含该字符?)

Does a font contain meta info about what symbols it has?字体是否包含有关它具有哪些符号的元信息?

If 2 fonts both have the symbol alpha, do they necessarily share the same “code point”?如果 2 fonts 都有符号 alpha,它们是否必须共享相同的“代码点”? Or is it dependent on the type of font such as Type1, Type3, TrueType, OpenType?还是依赖于Type1、Type3、TrueType、OpenType等字体类型? ... ...

Thanks for any pointers or references.感谢任何指针或参考。

TrueType fonts consist of a number of sections, most importantly for this question a table of "glyphs" and a table ("cmap") for mapping characters to those glyphs. TrueType字体由许多部分组成,对于此问题,最重要的是一个“字形”表和一个用于将字符映射到这些字形的表(“ cmap”)。

Long story short, the operating system uses the "cmap" table to convert characters into glyph indexes, substituting a default glyph for any which have no matching entry. 长话短说,操作系统使用“ cmap”表将字符转换为字形索引,用默认字形替换没有匹配条目的字符。 Unfortunately there are multiple versions of the font file specification (not to mention different types of fonts) and different character encodings of the same mappings in those tables, so the actual process of doing the mapping, and doing it efficiently so that text drawing is fast, ends up being extremely complex. 不幸的是,字体文件规范有多个版本(更不用说不同类型的字体)和这些表中相同映射的不同字符编码,因此,进行映射并有效进行映射的实际过程使文本绘制速度很快,最终变得极其复杂。

A "Code Point" is completely independent of characters, encodings and fonts. “代码点”完全独立于字符,编码和字体。 A particular code point is universal, but there are many encodings for it (UTF-8, UTF-16, etc.) and it will map to different glyph indexes in different fonts. 特定的代码点是通用的,但是它有许多编码(UTF-8,UTF-16等),并且它将以不同的字体映射到不同的字形索引。

Apple's developer documentation has a pretty good section on the details of TrueType fonts: Apple的开发人员文档在TrueType字体的细节上有相当不错的部分:

http://developer.apple.com/fonts/ttrefman/ http://developer.apple.com/fonts/ttrefman/

Specifically: 特别:

Glyph table: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html 字形表: https : //developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html

Character map: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html 角色图: https : //developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html

I also recommend an application called BabelMap , which gives you a lot of interesting information about fonts. 我还推荐了一个名为BabelMap的应用程序,它为您提供了许多有关字体的有趣信息。 Specifically look at Tools/Unicode Summary, Fonts/Font Analysis Utility, and Fonts/Font Information, where you can extract the entire glyph mapping table to the clipboard. 专门查看“工具/ Unicode摘要”,“字体/字体分析实用程序”和“字体/字体信息”,您可以在其中将整个字形映射表提取到剪贴板。

So does it mean that, the particular encoding of Greek Alpha has to be present in the /Encoding entry of the Font Dictionary or that Differences array of the Encoding dictionary should take the character code from the encoding and relink to alpha, all these without embedding of the truetype font...?那么这是否意味着,希腊字母的特定编码必须存在于字体字典的 /Encoding 条目中,或者编码字典的差异数组应该从编码中获取字符代码并重新链接到 alpha,所有这些都没有嵌入truetype 字体的...?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM