1/*
2 * Copyright © 2016  Google, Inc.
3 *
4 *  This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
27#ifndef HB_OT_POST_TABLE_HH
28#define HB_OT_POST_TABLE_HH
29
30#include "hb-open-type-private.hh"
31
32
33namespace OT {
34
35
36/*
37 * post -- PostScript
38 */
39
40#define HB_OT_TAG_post HB_TAG('p','o','s','t')
41
42
43struct postV2Tail
44{
45  inline bool sanitize (hb_sanitize_context_t *c) const
46  {
47    TRACE_SANITIZE (this);
48    return_trace (numberOfGlyphs.sanitize (c) &&
49		  c->check_array (glyphNameIndex, sizeof (USHORT), numberOfGlyphs));
50  }
51
52  USHORT	numberOfGlyphs;		/* Number of glyphs (this should be the
53					 * same as numGlyphs in 'maxp' table). */
54  USHORT	glyphNameIndex[VAR];	/* This is not an offset, but is the
55					 * ordinal number of the glyph in 'post'
56					 * string tables. */
57  BYTE		namesX[VAR];		/* Glyph names with length bytes [variable]
58					 * (a Pascal string). */
59
60  DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
61};
62
63struct post
64{
65  static const hb_tag_t tableTag = HB_OT_TAG_post;
66
67  inline bool sanitize (hb_sanitize_context_t *c) const
68  {
69    TRACE_SANITIZE (this);
70    if (unlikely (!c->check_struct (this)))
71      return_trace (false);
72    if (version.to_int () == 0x00020000)
73    {
74      const postV2Tail &v2 = StructAfter<postV2Tail>(*this);
75      return_trace (v2.sanitize (c));
76    }
77    return_trace (true);
78  }
79
80  public:
81  FixedVersion<>version;		/* 0x00010000 for version 1.0
82					 * 0x00020000 for version 2.0
83					 * 0x00025000 for version 2.5 (deprecated)
84					 * 0x00030000 for version 3.0 */
85  Fixed		italicAngle;		/* Italic angle in counter-clockwise degrees
86					 * from the vertical. Zero for upright text,
87					 * negative for text that leans to the right
88					 * (forward). */
89  FWORD		underlinePosition;	/* This is the suggested distance of the top
90					 * of the underline from the baseline
91					 * (negative values indicate below baseline).
92					 * The PostScript definition of this FontInfo
93					 * dictionary key (the y coordinate of the
94					 * center of the stroke) is not used for
95					 * historical reasons. The value of the
96					 * PostScript key may be calculated by
97					 * subtracting half the underlineThickness
98					 * from the value of this field. */
99  FWORD		underlineThickness;	/* Suggested values for the underline
100					   thickness. */
101  ULONG		isFixedPitch;		/* Set to 0 if the font is proportionally
102					 * spaced, non-zero if the font is not
103					 * proportionally spaced (i.e. monospaced). */
104  ULONG		minMemType42;		/* Minimum memory usage when an OpenType font
105					 * is downloaded. */
106  ULONG		maxMemType42;		/* Maximum memory usage when an OpenType font
107					 * is downloaded. */
108  ULONG		minMemType1;		/* Minimum memory usage when an OpenType font
109					 * is downloaded as a Type 1 font. */
110  ULONG		maxMemType1;		/* Maximum memory usage when an OpenType font
111					 * is downloaded as a Type 1 font. */
112/*postV2Tail	v2[VAR];*/
113  DEFINE_SIZE_STATIC (32);
114};
115
116} /* namespace OT */
117
118
119#endif /* HB_OT_POST_TABLE_HH */
120