1464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com/*
2464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Copyright 2011 Google Inc. All Rights Reserved.
3464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
4464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Licensed under the Apache License, Version 2.0 (the "License");
5464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * you may not use this file except in compliance with the License.
6464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * You may obtain a copy of the License at
7464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
8464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *      http://www.apache.org/licenses/LICENSE-2.0
9464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com *
10464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * Unless required by applicable law or agreed to in writing, software
11464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * distributed under the License is distributed on an "AS IS" BASIS,
12464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * See the License for the specific language governing permissions and
14464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com * limitations under the License.
15464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com */
16464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
175af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#ifndef SFNTLY_CPP_SRC_SFNTLY_TAG_H_
185af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#define SFNTLY_CPP_SRC_SFNTLY_TAG_H_
19464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
20ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com#include <cstddef>
21ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com
22464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com#include "sfntly/port/type.h"
23464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
24464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comnamespace sfntly {
25464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
26464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com// Font identification tags used for tables, features, etc.
27464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com// Tag names are consistent with the OpenType and sfnt specs.
28464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comstruct Tag {
29464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t ttcf;
30464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
31464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // Table Type Tags
32464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // required tables
33464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t cmap;
34464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t head;
35464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t hhea;
36464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t hmtx;
37464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t maxp;
38464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t name;
39464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t OS_2;
40464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t post;
41464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
42464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // TrueType outline tables
43464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t cvt;
44464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t fpgm;
45464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t glyf;
46464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t loca;
47464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t prep;
48464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
49464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // PostScript outline tables
50464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t CFF;
51464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t VORG;
52464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
53be87cfe77f08387d23cabc3a403fa53531b687a8arthurhsu@google.com  // opentype bitmap glyph outlines
54464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t EBDT;
55464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t EBLC;
56464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t EBSC;
57464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
58464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // advanced typographic features
59464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t BASE;
60464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t GDEF;
61464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t GPOS;
62464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t GSUB;
63464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t JSTF;
64464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
65464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  // other
66464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t DSIG;
67464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t gasp;
68464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t hdmx;
69464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t kern;
70464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t LTSH;
71464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t PCLT;
72464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t VDMX;
73464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t vhea;
74464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t vmtx;
75464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
766b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  // AAT tables
776b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t bsln;
786b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t feat;
796b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t lcar;
806b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t morx;
816b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t opbd;
826b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t prop;
836b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
846b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  // Graphite tables
856b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t Feat;
866b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t Glat;
876b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t Gloc;
886b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t Sile;
896b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  static const int32_t Silf;
90464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
91be87cfe77f08387d23cabc3a403fa53531b687a8arthurhsu@google.com  // truetype bitmap font tables
92464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t bhed;
93464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t bdat;
94464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com  static const int32_t bloc;
95464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com};
96464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
972b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com// Create integer tag value for human readable tag name.
9832a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.cominline int32_t GenerateTag(int32_t a, int32_t b, int32_t c, int32_t d) {
9932a01c7c6e7be46dda9bfc78de9ce32d99e4c8b7arthurhsu@google.com  return (a << 24) | (b << 16) | (c << 8) | d;
100464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com}
101464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
1022b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com// Translate tag to human readable string.
1032b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com// The Caller must delete[] the returned value.
1042b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.cominline char* TagToString(int32_t tag) {
1052b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com  char *name = new char[5];
1066b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  name[0] = static_cast<char>((tag & 0xff000000) >> 24);
1076b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  name[1] = static_cast<char>((tag & 0x00ff0000) >> 16);
1086b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  name[2] = static_cast<char>((tag & 0x0000ff00) >> 8);
1096b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  name[3] = static_cast<char>(tag & 0x000000ff);
1102b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com  name[4] = 0;
1112b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com  return name;
1122b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com}
1132b411c787a15a455c83abb03f2d458830f8b02dedfilimon@google.com
114464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com// Note: For Java, these two orderings are in Font class.  Moved here to avoid
115464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com//       VC++ bug of not populating correct values.
116464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comextern const int32_t CFF_TABLE_ORDERING[];
117464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comextern const size_t CFF_TABLE_ORDERING_SIZE;
118464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comextern const int32_t TRUE_TYPE_TABLE_ORDERING[];
119464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.comextern const size_t TRUE_TYPE_TABLE_ORDERING_SIZE;
120464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
121464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com}  // namespace sfntly
122464987db923362e596195f9eebd34fc508c9a41arthurhsu@google.com
1235af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#endif  // SFNTLY_CPP_SRC_SFNTLY_TAG_H_
124