16fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org/*
26fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * Copyright 2011 Google Inc. All Rights Reserved.
36fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *
46fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * Licensed under the Apache License, Version 2.0 (the "License");
56fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * you may not use this file except in compliance with the License.
66fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * You may obtain a copy of the License at
76fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *
86fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *      http://www.apache.org/licenses/LICENSE-2.0
96fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org *
106fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * Unless required by applicable law or agreed to in writing, software
116fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * distributed under the License is distributed on an "AS IS" BASIS,
126fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * See the License for the specific language governing permissions and
146fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org * limitations under the License.
156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org */
16f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
17f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org#ifndef SFNTLY_CPP_SRC_SFNTLY_TAG_H_
18f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org#define SFNTLY_CPP_SRC_SFNTLY_TAG_H_
19f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
206fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#include <cstddef>
21f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
22dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org#include "sfntly/port/type.h"
2387997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org
24dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.orgnamespace sfntly {
25dddee1ec7cedf276305b107429f684539b105276johannkoenig@chromium.org
266fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org// Font identification tags used for tables, features, etc.
276fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org// Tag names are consistent with the OpenType and sfnt specs.
286fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgstruct Tag {
296fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t ttcf;
30923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org
31923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  // Table Type Tags
32923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  // required tables
33f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t cmap;
34923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  static const int32_t head;
35f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t hhea;
36923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  static const int32_t hmtx;
37923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  static const int32_t maxp;
38923acb6a717b7f2719ed21184c1bc533b0a14888johannkoenig@chromium.org  static const int32_t name;
39f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t OS_2;
406fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t post;
416fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
426fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  // TrueType outline tables
436fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t cvt;
446fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t fpgm;
456fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t glyf;
466fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t loca;
476fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t prep;
48f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
49f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  // PostScript outline tables
50f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t CFF;
516fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t VORG;
526fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
536fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  // opentype bitmap glyph outlines
546fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t EBDT;
556fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t EBLC;
566fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t EBSC;
576fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
586fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  // advanced typographic features
596fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t BASE;
606fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t GDEF;
616fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t GPOS;
626fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t GSUB;
636fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t JSTF;
64f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
65f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  // other
66f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t DSIG;
67f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t gasp;
68f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t hdmx;
69f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t kern;
70f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t LTSH;
71f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t PCLT;
72f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t VDMX;
73f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t vhea;
74f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t vmtx;
75f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
76f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  // AAT tables
77f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t bsln;
78f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t feat;
79f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t lcar;
80f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org  static const int32_t morx;
816fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t opbd;
826fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t prop;
836fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
846fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  // Graphite tables
856fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t Feat;
866fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t Glat;
876fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t Gloc;
886fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t Sile;
896fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t Silf;
906fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
916fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  // truetype bitmap font tables
926fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t bhed;
936fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t bdat;
946fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  static const int32_t bloc;
956fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org};
966fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
976fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org// Create integer tag value for human readable tag name.
986fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orginline int32_t GenerateTag(int32_t a, int32_t b, int32_t c, int32_t d) {
996fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  return (a << 24) | (b << 16) | (c << 8) | d;
1006fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
1016fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
1026fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org// Translate tag to human readable string.
1036fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org// The Caller must delete[] the returned value.
1046fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orginline char* TagToString(int32_t tag) {
1056fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  char *name = new char[5];
1066fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  name[0] = static_cast<char>((tag & 0xff000000) >> 24);
1076fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  name[1] = static_cast<char>((tag & 0x00ff0000) >> 16);
1086fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  name[2] = static_cast<char>((tag & 0x0000ff00) >> 8);
1096fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  name[3] = static_cast<char>(tag & 0x000000ff);
1106fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  name[4] = 0;
1116fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  return name;
1126fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
113f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
114f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org// Note: For Java, these two orderings are in Font class.  Moved here to avoid
1156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org//       VC++ bug of not populating correct values.
1166fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgextern const int32_t CFF_TABLE_ORDERING[];
117f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.orgextern const size_t CFF_TABLE_ORDERING_SIZE;
118f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.orgextern const int32_t TRUE_TYPE_TABLE_ORDERING[];
1196fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgextern const size_t TRUE_TYPE_TABLE_ORDERING_SIZE;
1206fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
121f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org}  // namespace sfntly
122f9586bb54d74c97d07b09eb2512f8569c9c1c025fgalligan@chromium.org
1236fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org#endif  // SFNTLY_CPP_SRC_SFNTLY_TAG_H_
1246fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org