2 * Copyright © 2018 Ebrahim Byagowi
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
25 #ifndef HB_AAT_LAYOUT_BSLN_TABLE_HH
26 #define HB_AAT_LAYOUT_BSLN_TABLE_HH
28 #include "hb-aat-layout-common.hh"
32 * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
34 #define HB_AAT_TAG_bsln HB_TAG('b','s','l','n')
40 struct BaselineTableFormat0Part
42 bool sanitize (hb_sanitize_context_t *c) const
44 TRACE_SANITIZE (this);
45 return_trace (likely (c->check_struct (this)));
49 // Roman, Ideographic centered, Ideographic low, Hanging and Math
50 // are the default defined ones, but any other maybe accessed also.
51 HBINT16 deltas[32]; /* These are the FUnit distance deltas from
52 * the font's natural baseline to the other
53 * baselines used in the font. */
55 DEFINE_SIZE_STATIC (64);
58 struct BaselineTableFormat1Part
60 bool sanitize (hb_sanitize_context_t *c) const
62 TRACE_SANITIZE (this);
63 return_trace (likely (c->check_struct (this) &&
64 lookupTable.sanitize (c)));
68 HBINT16 deltas[32]; /* ditto */
70 lookupTable; /* Lookup table that maps glyphs to their
76 struct BaselineTableFormat2Part
78 bool sanitize (hb_sanitize_context_t *c) const
80 TRACE_SANITIZE (this);
81 return_trace (likely (c->check_struct (this)));
85 HBGlyphID stdGlyph; /* The specific glyph index number in this
86 * font that is used to set the baseline values.
87 * This is the standard glyph.
88 * This glyph must contain a set of control points
89 * (whose numbers are contained in the ctlPoints field)
90 * that are used to determine baseline distances. */
91 HBUINT16 ctlPoints[32]; /* Set of control point numbers,
92 * associated with the standard glyph.
93 * A value of 0xFFFF means there is no corresponding
94 * control point in the standard glyph. */
96 DEFINE_SIZE_STATIC (66);
99 struct BaselineTableFormat3Part
101 bool sanitize (hb_sanitize_context_t *c) const
103 TRACE_SANITIZE (this);
104 return_trace (c->check_struct (this) && lookupTable.sanitize (c));
108 HBGlyphID stdGlyph; /* ditto */
109 HBUINT16 ctlPoints[32]; /* ditto */
111 lookupTable; /* Lookup table that maps glyphs to their
112 * baseline values. */
114 DEFINE_SIZE_MIN (68);
119 static constexpr hb_tag_t tableTag = HB_AAT_TAG_bsln;
121 bool sanitize (hb_sanitize_context_t *c) const
123 TRACE_SANITIZE (this);
124 if (unlikely (!(c->check_struct (this) && defaultBaseline < 32)))
125 return_trace (false);
129 case 0: return_trace (parts.format0.sanitize (c));
130 case 1: return_trace (parts.format1.sanitize (c));
131 case 2: return_trace (parts.format2.sanitize (c));
132 case 3: return_trace (parts.format3.sanitize (c));
133 default:return_trace (true);
138 FixedVersion<>version; /* Version number of the Baseline table. */
139 HBUINT16 format; /* Format of the baseline table. Only one baseline
140 * format may be selected for the font. */
141 HBUINT16 defaultBaseline;/* Default baseline value for all glyphs.
142 * This value can be from 0 through 31. */
144 // Distance-Based Formats
145 BaselineTableFormat0Part format0;
146 BaselineTableFormat1Part format1;
147 // Control Point-based Formats
148 BaselineTableFormat2Part format2;
149 BaselineTableFormat3Part format3;
155 } /* namespace AAT */
158 #endif /* HB_AAT_LAYOUT_BSLN_TABLE_HH */