(b []byte)
| 74 | } |
| 75 | |
| 76 | func (e builtinEncoding) Encode(b []byte) ([]byte, error) { |
| 77 | s := []byte{} |
| 78 | for _, r := range string(b) { |
| 79 | gid := e.sfnt.Cmap.Get(r) |
| 80 | if e.bytes == 1 { |
| 81 | if 256 <= gid { |
| 82 | return nil, fmt.Errorf("invalid GID %v for character '%v' (0x%X)\n", gid, string(r), r) |
| 83 | } |
| 84 | s = append(s, byte(gid)) |
| 85 | } else { |
| 86 | s = binary.BigEndian.AppendUint16(s, gid) |
| 87 | } |
| 88 | } |
| 89 | return s, nil |
| 90 | } |
| 91 | |
| 92 | func (e builtinEncoding) Decode(b []byte) ([]byte, error) { |
| 93 | runes := []rune{} |