Unicode字符如何映射到字体的字形? [英] How does a Unicode character get mapped to a glyph in a font?

查看:252
本文介绍了Unicode字符如何映射到字体的字形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Unicode中的每个字符都有一个代码点;字体中字符的类似术语是什么?

I am wondering, that each char in Unicode has a code point; 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).

例如,当文本编辑器从其字符编码中解码文件时,并假设存在希腊字母α(U + 03B1).此应用选择字体中的特定字形的确切过程是什么?大多数应用都有首选字体.假设是快递. (在像心♥(U + 2665)这样的罕见Unicode字符发生了什么,那不是默认字体吗?应用程序如何知道该字体不包含那个字符?)

For example, when a text editor has decoded a file from its character encoding, and suppose there's Greek alpha α (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?)

字体是否包含有关其具有哪些符号的元信息?

Does a font contain meta info about what symbols it has?

如果2种字体都具有符号alpha,它们是否必然共享相同的代码点"?还是取决于字体的类型,例如Type1,Type3,TrueType,OpenType? ...

If 2 fonts both have the symbol alpha, do they necessarily share the same "code point"? Or is it dependent on the type of font such as Type1, Type3, TrueType, OpenType? ...

感谢任何指针或引用.

推荐答案

TrueType字体由许多部分组成,最重要的是,对于这个问题,一个字形"表和一个用于将字符映射到这些字形的表("cmap")字形.

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.

长话短说,操作系统使用"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. 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.

代码点"完全独立于字符,编码和字体.特定的代码点是通用的,但是它有许多编码(UTF-8,UTF-16等),它将映射到不同字体的不同字形索引.

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.

Apple的开发人员文档中有关于TrueType字体详细信息的相当不错的部分:

Apple's developer documentation has a pretty good section on the details of TrueType fonts:

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

特别是:

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

字符映射: https://developer.apple.com /fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html

我还推荐了一个名为 BabelMap 的应用程序,它为您提供了很多有关字体的有趣信息.专门查看工具/Unicode摘要",字体/字体分析实用程序"和字体/字体信息",您可以在其中将整个字形映射表提取到剪贴板.

I also recommend an application called BabelMap, which gives you a lot of interesting information about fonts. 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字符如何映射到字体的字形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆