问题描述
想知道 cmap表以TrueType字体显示. Microsoft谈论了字形索引映射表的字符,但是我看不到字符或字形索引的含义.
Wondering what the "character codes" are for the cmap table in TrueType fonts. Microsoft talks about the Character to Glyph Index Mapping Table, but I don't see what the character or glyph index mean.
想知道是否在字体文件中的某处指定了 encoding ,例如Unicode 11.0,然后字符代码等于Unicode代码点,例如a
的U+0061
.或者,如果字符代码是浏览器"字符代码(我猜是十进制代码),例如97
表示a
.
Wondering if somewhere in the font file you specify the encoding, such as Unicode 11.0, and then the character codes are equal to the Unicode code points such as U+0061
for a
. Or if the character codes are instead the "browser" character codes (decimal codes I guess), such as 97
for a
.
基本上想知道如何将键盘字符映射到字形,以及这的真正含义.我想您不是很想将键盘代码映射到字形,而是将U+0061
这样的unicode代码映射到字形,因此,如果使用JavaScript(),您可以执行\u03A9
,并且如果您的字体支持,它将显示Ω
.
Basically wondering how you map keyboard characters to font glyphs, and what that really means. I think you not so much want to map keyboard codes to the font glyphs, but unicode codes like U+0061
to the font glyphs, so if in JavaScript (for example) you can do \u03A9
and it will give you Ω
if your font supports that.
试图从字体文件如何将数学字形作为矢量/路径映射到某种字符或代码的角度来理解字体文件的结构.
Trying to understand the anatomy of a font file in terms of how it maps the mathematical glyphs as vectors/paths, to characters or codes of some sort.
推荐答案
简短但可能不希望的答案当然是阅读OpenType规范.这需要一段时间",因此稍长一些,但更容易且更少详细的答案是 http://pomax.github.io/CFF-glyphlet-fonts,尽管这会跳过TTF,所以让我们在这里看一下:
The short, but perhaps not desired, answer is of course "read the OpenType spec. It takes a while", so a slightly longer, but easier and less detailed answer would be http://pomax.github.io/CFF-glyphlet-fonts, although that skips over TTF so let's look at that here:
在给定要应用字体的上下文的情况下,您的输入代码将通过适用的CMAP运行,它将计算机代码(ASCII代码,Unicode代码点,ISO-2022-jp,您拥有的内容)映射到字形ID.专门针对TTF,然后将该ID用作"loca"中的数组偏移量表",它是数据位置的字形索引"表,并为字体包含的每个字形指定"glyf"表中的字节偏移量.然后,您在该字节偏移处查询glyf表,并开始解析 https://docs.microsoft.com/zh-cn/typography/opentype/spec/glyf
Your input code gets run through whatever is the applicable CMAP given the context you're applying the font to, which maps the computer's code (ascii code, unicode code point, ISO-2022-jp, what have you) to a glyph id. For TTF specifically, that id is then used as array offset in the "loca" table, which is the "glyph index to data location" table and specifies the byte offset in the "glyf" table for each glyph that the font contains. You then consult the glyf table at that byte offset, and start parsing the bytes as specified by https://docs.microsoft.com/en-us/typography/opentype/spec/glyf
这篇关于TrueType字体的cmap表中的字符代码是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!