【问题标题】:OTF, TTF font cmap tableOTF、TTF字体cmap表
【发布时间】:2011-07-15 20:52:05
【问题描述】:

我已设法从 OTF 文件中获取 cmap,如下所示:

object(SimpleXMLElement)#4 (3) {
  ["tableVersion"]=>
  object(SimpleXMLElement)#5 (1) {
    ["@attributes"]=>
    array(1) {
      ["version"]=>
      string(1) "0"
    }
  }
  ["cmap_format_4"]=>
  array(2) {
    [0]=>
    object(SimpleXMLElement)#6 (3) {
      ["@attributes"]=>
      array(3) {
        ["platformID"]=>
        string(1) "0"
        ["platEncID"]=>
        string(1) "3"
        ["language"]=>
        string(1) "0"
      }
      ["map"]=>
      array(222) {
        [0]=>
        object(SimpleXMLElement)#9 (1) {
          ["@attributes"]=>
          array(2) {
            ["code"]=>
            string(4) "0x20"
            ["name"]=>
            string(5) "space"
          }
        }
        [1]=>
        object(SimpleXMLElement)#11 (1) {
          ["@attributes"]=>
          array(2) {
            ["code"]=>
            string(4) "0x21"
            ["name"]=>
            string(6) "exclam"
          }

现在,我需要使用 PHP GD 或任何其他方式生成字符映射。不过,首选 PHP GD。如何将 0x21 格式的字母转换成看起来像字母的东西?

【问题讨论】:

  • 您可能需要检查字体的不同 Unicode CMAP 以查看它们是否不同。例如,如果您正在查看 Windows CMAP,但 FreeType 使用 Apple CMAP,而后者恰好被破坏,则某些字形将无法访问。

标签: php gd truetype opentype


【解决方案1】:

最简单的方法是使用字体定义将字符绘制到图像上。

查看imagettftext() 的定义 - 不建议尝试自己从字形轮廓执行渲染。

【讨论】:

  • 我的意思是,我仅使用此信息来获取字体中的可用字形。现在我需要将它们转换为字母并打印出来。
  • 我可以使用chr() 获得一些简单的值,但它不适用于0x2da
  • Guy:来自上面链接的文档:"May include decimal numeric character references (of the form: €) to access characters in a font beyond position 127. The hexadecimal format (like ©) is supported. Strings in UTF-8 encoding can be passed directly."
  • @Orbling:我已经用0x17e 字符(zcaron)尝试过。我已经尝试过这种方式:imagettftext($im, 20, 0, 10, 20, $black, 'font.otf', 'ž'); 但它不起作用(产生空图像)。
  • @Guy:OTF 格式是个问题,look at the following message
【解决方案2】:

OTF 字体的 CFF 表包含整个字形图像/程序。您可以将它们绘制为几何对象。通过 php api 绘制整个字形集合是不可能的,因为 php api 使用 ENCODING 参数来调用字形,而不是字形的 INDEX 或 NAME。

【讨论】:

    猜你喜欢
    • 2016-03-22
    • 2021-06-08
    • 2017-02-02
    • 2019-07-22
    • 2014-04-27
    • 2016-03-04
    • 1970-01-01
    • 2014-07-23
    • 2014-06-04
    相关资源
    最近更新 更多