blob: 63fac84524f336b5239c3898d5f523d2422c4a6c [file] [log] [blame]
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +03301/*
2 * Copyright © 2018 Ebrahim Byagowi
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
25#ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH
26#define HB_AAT_LAYOUT_ANKR_TABLE_HH
27
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070028#include "hb-aat-layout-common.hh"
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033029
Ebrahim Byagowia02c3ee2018-04-12 13:38:19 +043030/*
31 * ankr -- Anchor Point
32 * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
33 */
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033034#define HB_AAT_TAG_ankr HB_TAG('a','n','k','r')
35
36
37namespace AAT {
38
Behdad Esfahbodb605db22018-11-04 12:58:02 -050039using namespace OT;
40
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033041
Behdad Esfahbod28c42452018-02-26 01:10:42 -080042struct Anchor
43{
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033044 bool sanitize (hb_sanitize_context_t *c) const
Behdad Esfahbod28c42452018-02-26 01:10:42 -080045 {
46 TRACE_SANITIZE (this);
47 return_trace (c->check_struct (this));
48 }
49
Behdad Esfahbod947962a2018-10-10 23:07:03 -040050 public:
Behdad Esfahbod28c42452018-02-26 01:10:42 -080051 FWORD xCoordinate;
52 FWORD yCoordinate;
53 public:
54 DEFINE_SIZE_STATIC (4);
55};
56
Behdad Esfahbod2520a822021-03-31 15:34:26 -060057typedef Array32Of<Anchor> GlyphAnchors;
Behdad Esfahbod947962a2018-10-10 23:07:03 -040058
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033059struct ankr
60{
Behdad Esfahbodef006542019-01-22 12:08:57 +010061 static constexpr hb_tag_t tableTag = HB_AAT_TAG_ankr;
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033062
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033063 const Anchor &get_anchor (hb_codepoint_t glyph_id,
64 unsigned int i,
Behdad Esfahbod347ad452019-01-17 17:47:29 -050065 unsigned int num_glyphs) const
Behdad Esfahbod947962a2018-10-10 23:07:03 -040066 {
Behdad Esfahbodad28f972021-03-31 12:49:14 -060067 const NNOffset16To<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
Behdad Esfahbodf7c0b432018-10-19 15:23:49 -070068 if (!offset)
Ebrahim Byagowi2dda6dd2020-04-20 14:12:45 +043069 return Null (Anchor);
Behdad Esfahbodcc8e9a42019-01-17 14:54:32 -050070 const GlyphAnchors &anchors = &(this+anchorData) + *offset;
Behdad Esfahbod947962a2018-10-10 23:07:03 -040071 return anchors[i];
72 }
73
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033074 bool sanitize (hb_sanitize_context_t *c) const
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033075 {
76 TRACE_SANITIZE (this);
Ebrahim Byagowia47070c2018-04-18 12:09:37 +043077 return_trace (likely (c->check_struct (this) &&
78 version == 0 &&
Behdad Esfahbod96f12372019-03-26 16:17:45 -070079 c->check_range (this, anchorData) &&
Behdad Esfahbodcc8e9a42019-01-17 14:54:32 -050080 lookupTable.sanitize (c, this, &(this+anchorData))));
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033081 }
82
83 protected:
Ebrahim Byagowice114d62019-12-31 15:53:02 +033084 HBUINT16 version; /* Version number (set to zero) */
Ebrahim Byagowi211da5e2018-04-11 17:41:24 +043085 HBUINT16 flags; /* Flags (currently unused; set to zero) */
Behdad Esfahbodad28f972021-03-31 12:49:14 -060086 Offset32To<Lookup<NNOffset16To<GlyphAnchors>>>
Ebrahim Byagowi211da5e2018-04-11 17:41:24 +043087 lookupTable; /* Offset to the table's lookup table */
Behdad Esfahbodad28f972021-03-31 12:49:14 -060088 NNOffset32To<HBUINT8>
Behdad Esfahbod7281cb32018-10-10 22:56:52 -040089 anchorData; /* Offset to the glyph data table */
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033090
91 public:
Behdad Esfahbod05fbd142018-02-26 01:04:16 -080092 DEFINE_SIZE_STATIC (12);
Ebrahim Byagowiae14dd02018-02-26 00:31:09 +033093};
94
95} /* namespace AAT */
96
97
98#endif /* HB_AAT_LAYOUT_ANKR_TABLE_HH */