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.
24 #ifndef HB_AAT_LAYOUT_LCAR_TABLE_HH
25 #define HB_AAT_LAYOUT_LCAR_TABLE_HH
27 #include "hb-open-type.hh"
28 #include "hb-aat-layout-common.hh"
31 * lcar -- Ligature caret
32 * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html
34 #define HB_AAT_TAG_lcar HB_TAG('l','c','a','r')
39 typedef ArrayOf<HBINT16> LigCaretClassEntry;
43 unsigned int get_lig_carets (hb_font_t *font,
44 hb_direction_t direction,
46 unsigned int start_offset,
47 unsigned int *caret_count /* IN/OUT */,
48 hb_position_t *caret_array /* OUT */,
49 const void *base) const
51 const OffsetTo<LigCaretClassEntry>* entry_offset = lookupTable.get_value (glyph,
52 font->face->get_num_glyphs ());
53 const LigCaretClassEntry& array = entry_offset ? base+*entry_offset : Null (LigCaretClassEntry);
56 hb_array_t<const HBINT16> arr = array.sub_array (start_offset, caret_count);
57 for (unsigned int i = 0; i < arr.length; ++i)
58 caret_array[i] = font->em_scale_dir (arr[i], direction);
63 bool sanitize (hb_sanitize_context_t *c, const void *base) const
65 TRACE_SANITIZE (this);
66 return_trace (likely (c->check_struct (this) && lookupTable.sanitize (c, base)));
70 Lookup<OffsetTo<LigCaretClassEntry>>
71 lookupTable; /* data Lookup table associating glyphs */
78 unsigned int get_lig_carets (hb_font_t *font,
79 hb_direction_t direction,
81 unsigned int start_offset,
82 unsigned int *caret_count /* IN/OUT */,
83 hb_position_t *caret_array /* OUT */,
84 const void *base) const
86 const OffsetTo<LigCaretClassEntry>* entry_offset = lookupTable.get_value (glyph,
87 font->face->get_num_glyphs ());
88 const LigCaretClassEntry& array = entry_offset ? base+*entry_offset : Null (LigCaretClassEntry);
91 hb_array_t<const HBINT16> arr = array.sub_array (start_offset, caret_count);
92 for (unsigned int i = 0; i < arr.length; ++i)
94 hb_position_t x = 0, y = 0;
95 font->get_glyph_contour_point_for_origin (glyph, arr[i], direction, &x, &y);
96 caret_array[i] = HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
102 bool sanitize (hb_sanitize_context_t *c, const void *base) const
104 TRACE_SANITIZE (this);
105 return_trace (likely (c->check_struct (this) && lookupTable.sanitize (c, base)));
109 Lookup<OffsetTo<LigCaretClassEntry>>
110 lookupTable; /* data Lookup table associating glyphs */
117 static constexpr hb_tag_t tableTag = HB_AAT_TAG_lcar;
119 bool has_data () const { return version.major; }
121 unsigned int get_lig_carets (hb_font_t *font,
122 hb_direction_t direction,
123 hb_codepoint_t glyph,
124 unsigned int start_offset,
125 unsigned int *caret_count /* IN/OUT */,
126 hb_position_t *caret_array /* OUT */) const
137 case 0: return u.format0.get_lig_carets (font, direction, glyph, start_offset,
138 caret_count, caret_array, this);
139 case 1: return u.format1.get_lig_carets (font, direction, glyph, start_offset,
140 caret_count, caret_array, this);
141 default:if (caret_count) *caret_count = 0; return 0;
145 bool sanitize (hb_sanitize_context_t *c) const
147 TRACE_SANITIZE (this);
148 if (unlikely (!c->check_struct (this) || version.major != 1))
149 return_trace (false);
152 case 0: return_trace (u.format0.sanitize (c, this));
153 case 1: return_trace (u.format1.sanitize (c, this));
154 default:return_trace (true);
159 FixedVersion<>version; /* Version number of the ligature caret table */
160 HBUINT16 format; /* Format of the ligature caret table. */
169 } /* namespace AAT */
171 #endif /* HB_AAT_LAYOUT_LCAR_TABLE_HH */