• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SFNTLY_CPP_SRC_SFNTLY_TAG_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_TAG_H_
19 
20 #include <cstddef>
21 
22 #include "sfntly/port/type.h"
23 
24 namespace sfntly {
25 
26 // Font identification tags used for tables, features, etc.
27 // Tag names are consistent with the OpenType and sfnt specs.
28 struct Tag {
29   static const int32_t ttcf;
30 
31   // Table Type Tags
32   // required tables
33   static const int32_t cmap;
34   static const int32_t head;
35   static const int32_t hhea;
36   static const int32_t hmtx;
37   static const int32_t maxp;
38   static const int32_t name;
39   static const int32_t OS_2;
40   static const int32_t post;
41 
42   // TrueType outline tables
43   static const int32_t cvt;
44   static const int32_t fpgm;
45   static const int32_t glyf;
46   static const int32_t loca;
47   static const int32_t prep;
48 
49   // PostScript outline tables
50   static const int32_t CFF;
51   static const int32_t VORG;
52 
53   // opentype bitmap glyph outlines
54   static const int32_t EBDT;
55   static const int32_t EBLC;
56   static const int32_t EBSC;
57 
58   // advanced typographic features
59   static const int32_t BASE;
60   static const int32_t GDEF;
61   static const int32_t GPOS;
62   static const int32_t GSUB;
63   static const int32_t JSTF;
64 
65   // other
66   static const int32_t DSIG;
67   static const int32_t gasp;
68   static const int32_t hdmx;
69   static const int32_t kern;
70   static const int32_t LTSH;
71   static const int32_t PCLT;
72   static const int32_t VDMX;
73   static const int32_t vhea;
74   static const int32_t vmtx;
75 
76   // AAT tables
77   static const int32_t bsln;
78   static const int32_t feat;
79   static const int32_t lcar;
80   static const int32_t morx;
81   static const int32_t opbd;
82   static const int32_t prop;
83 
84   // Graphite tables
85   static const int32_t Feat;
86   static const int32_t Glat;
87   static const int32_t Gloc;
88   static const int32_t Sile;
89   static const int32_t Silf;
90 
91   // truetype bitmap font tables
92   static const int32_t bhed;
93   static const int32_t bdat;
94   static const int32_t bloc;
95 };
96 
97 // Create integer tag value for human readable tag name.
GenerateTag(int32_t a,int32_t b,int32_t c,int32_t d)98 inline int32_t GenerateTag(int32_t a, int32_t b, int32_t c, int32_t d) {
99   return (a << 24) | (b << 16) | (c << 8) | d;
100 }
101 
102 // Translate tag to human readable string.
103 // The Caller must delete[] the returned value.
TagToString(int32_t tag)104 inline char* TagToString(int32_t tag) {
105   char *name = new char[5];
106   name[0] = static_cast<char>((tag & 0xff000000) >> 24);
107   name[1] = static_cast<char>((tag & 0x00ff0000) >> 16);
108   name[2] = static_cast<char>((tag & 0x0000ff00) >> 8);
109   name[3] = static_cast<char>(tag & 0x000000ff);
110   name[4] = 0;
111   return name;
112 }
113 
114 // Note: For Java, these two orderings are in Font class.  Moved here to avoid
115 //       VC++ bug of not populating correct values.
116 extern const int32_t CFF_TABLE_ORDERING[];
117 extern const size_t CFF_TABLE_ORDERING_SIZE;
118 extern const int32_t TRUE_TYPE_TABLE_ORDERING[];
119 extern const size_t TRUE_TYPE_TABLE_ORDERING_SIZE;
120 
121 }  // namespace sfntly
122 
123 #endif  // SFNTLY_CPP_SRC_SFNTLY_TAG_H_
124