OTF,TTF字体cmap表

I have managed to get the cmap from the OTF file, which looks like this:

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"
          }

Now, I need to generate character map using PHP GD or any other way. PHP GD preferred, though. How do convert letter in format 0x21 to something that would look like letter?

The simplest way is just to draw the characters on to an image using the font definition.

Have a look at the definition for imagettftext() - trying to perform the rendering yourself from glyph outlines is not advisable.

CFF table of an OTF font consists the whole glyphs images/programs. You can draw them as geometry objects. It is NOT POSSIBLE draw whole collection of the glyph by php api, because php api is using ENCODING parameter to call the glyph, but not the INDEX or NAME of the glyph.