QtBase  v6.3.1
hb-ot-vorg-table.hh
Go to the documentation of this file.
1 /*
2  * Copyright © 2018 Adobe 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  * Adobe Author(s): Michiharu Ariza
25  */
26 
27 #ifndef HB_OT_VORG_TABLE_HH
28 #define HB_OT_VORG_TABLE_HH
29 
30 #include "hb-open-type.hh"
31 
32 /*
33  * VORG -- Vertical Origin Table
34  * https://docs.microsoft.com/en-us/typography/opentype/spec/vorg
35  */
36 #define HB_OT_TAG_VORG HB_TAG('V','O','R','G')
37 
38 namespace OT {
39 
41 {
42  int cmp (hb_codepoint_t g) const { return glyph.cmp (g); }
43 
45  {
46  TRACE_SANITIZE (this);
47  return_trace (c->check_struct (this));
48  }
49 
50  public:
53 
54  public:
56 };
57 
58 struct VORG
59 {
60  static constexpr hb_tag_t tableTag = HB_OT_TAG_VORG;
61 
62  bool has_data () const { return version.to_int (); }
63 
64  int get_y_origin (hb_codepoint_t glyph) const
65  {
66  unsigned int i;
67  if (!vertYOrigins.bfind (glyph, &i))
68  return defaultVertOriginY;
69  return vertYOrigins[i].vertOriginY;
70  }
71 
72  template <typename Iterator,
73  hb_requires (hb_is_iterator (Iterator))>
75  Iterator it,
77  {
78 
79  if (unlikely (!c->extend_min ((*this)))) return;
80 
81  this->version.major = 1;
82  this->version.minor = 0;
83 
84  this->defaultVertOriginY = defaultVertOriginY;
85  this->vertYOrigins.len = it.len ();
86 
87  c->copy_all (it);
88  }
89 
91  {
92  TRACE_SUBSET (this);
93  VORG *vorg_prime = c->serializer->start_embed<VORG> ();
94  if (unlikely (!c->serializer->check_success (vorg_prime))) return_trace (false);
95 
96  auto it =
97  + vertYOrigins.as_array ()
98  | hb_filter (c->plan->glyphset (), &VertOriginMetric::glyph)
99  | hb_map ([&] (const VertOriginMetric& _)
100  {
102  c->plan->new_gid_for_old_gid (_.glyph, &new_glyph);
103 
104  VertOriginMetric metric;
105  metric.glyph = new_glyph;
106  metric.vertOriginY = _.vertOriginY;
107  return metric;
108  })
109  ;
110 
111  /* serialize the new table */
112  vorg_prime->serialize (c->serializer, it, defaultVertOriginY);
113  return_trace (true);
114  }
115 
117  {
118  TRACE_SANITIZE (this);
119  return_trace (c->check_struct (this) &&
120  version.major == 1 &&
121  vertYOrigins.sanitize (c));
122  }
123 
124  protected:
125  FixedVersion<>version; /* Version of VORG table. Set to 0x00010000u. */
127  /* The default vertical origin. */
129  vertYOrigins; /* The array of vertical origins. */
130 
131  public:
133 };
134 } /* namespace OT */
135 
136 #endif /* HB_OT_VORG_TABLE_HH */
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
#define TRACE_SANITIZE(this)
Definition: hb-debug.hh:414
#define return_trace(RET)
Definition: hb-debug.hh:349
#define TRACE_SUBSET(this)
Definition: hb-debug.hh:438
#define hb_is_iterator(Iter)
Definition: hb-iter.hh:265
auto it hb_map(hb_second)) template< typename Type > inline hb_array_t< Type > operator()(hb_array_t< Type > array
static auto hb_requires(hb_is_iterable(Iterable))> static inline auto end(Iterable &&iterable) HB_AUTO_RETURN(hb_iter(iterable).end()) namespace OT
Definition: hb-iter.hh:331
#define _(S, M)
#define HB_OT_TAG_VORG
#define unlikely(expr)
Definition: hb.hh:251
GLboolean GLboolean g
const GLubyte * c
Definition: qopenglext.h:12701
uint32_t hb_codepoint_t
Definition: hb-common.h:106
uint32_t hb_tag_t
Definition: hb-common.h:157
#define HB_SET_VALUE_INVALID
Definition: hb-set.h:46
QStringList::Iterator it
uint32_t to_int() const
static HB_INTERNAL int cmp(const IntType *a, const IntType *b)
Definition: hb-open-type.hh:79
SortedArray16Of< VertOriginMetric > vertYOrigins
int get_y_origin(hb_codepoint_t glyph) const
void serialize(hb_serialize_context_t *c, Iterator it, FWORD defaultVertOriginY)
bool sanitize(hb_sanitize_context_t *c) const
bool subset(hb_subset_context_t *c) const
FixedVersion version
static constexpr hb_tag_t tableTag
DEFINE_SIZE_ARRAY(8, vertYOrigins)
bool has_data() const
FWORD defaultVertOriginY
int cmp(hb_codepoint_t g) const
bool sanitize(hb_sanitize_context_t *c) const