QtBase  v6.3.1
hb-ot-color-svg-table.hh
Go to the documentation of this file.
1 /*
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_OT_COLOR_SVG_TABLE_HH
26 #define HB_OT_COLOR_SVG_TABLE_HH
27 
28 #include "hb-open-type.hh"
29 
30 /*
31  * SVG -- SVG (Scalable Vector Graphics)
32  * https://docs.microsoft.com/en-us/typography/opentype/spec/svg
33  */
34 
35 #define HB_OT_TAG_SVG HB_TAG('S','V','G',' ')
36 
37 
38 namespace OT {
39 
40 
42 {
43  int cmp (hb_codepoint_t g) const
44  { return g < startGlyphID ? -1 : g > endGlyphID ? 1 : 0; }
45 
46  hb_blob_t *reference_blob (hb_blob_t *svg_blob, unsigned int index_offset) const
47  {
48  return hb_blob_create_sub_blob (svg_blob,
49  index_offset + (unsigned int) svgDoc,
50  svgDocLength);
51  }
52 
53  bool sanitize (hb_sanitize_context_t *c, const void *base) const
54  {
55  TRACE_SANITIZE (this);
56  return_trace (c->check_struct (this) &&
57  svgDoc.sanitize (c, base, svgDocLength));
58  }
59 
60  protected:
61  HBUINT16 startGlyphID; /* The first glyph ID in the range described by
62  * this index entry. */
63  HBUINT16 endGlyphID; /* The last glyph ID in the range described by
64  * this index entry. Must be >= startGlyphID. */
66  svgDoc; /* Offset from the beginning of the SVG Document Index
67  * to an SVG document. Must be non-zero. */
68  HBUINT32 svgDocLength; /* Length of the SVG document.
69  * Must be non-zero. */
70  public:
72 };
73 
74 struct SVG
75 {
76  static constexpr hb_tag_t tableTag = HB_OT_TAG_SVG;
77 
78  bool has_data () const { return svgDocEntries; }
79 
81  {
83  { table = hb_sanitize_context_t ().reference_table<SVG> (face); }
84  ~accelerator_t () { table.destroy (); }
85 
87  {
88  return table->get_glyph_entry (glyph_id).reference_blob (table.get_blob (),
89  table->svgDocEntries);
90  }
91 
92  bool has_data () const { return table->has_data (); }
93 
94  private:
96  };
97 
99  { return (this+svgDocEntries).bsearch (glyph_id); }
100 
102  {
103  TRACE_SANITIZE (this);
104  return_trace (likely (c->check_struct (this) &&
105  (this+svgDocEntries).sanitize_shallow (c)));
106  }
107 
108  protected:
109  HBUINT16 version; /* Table version (starting at 0). */
111  svgDocEntries; /* Offset (relative to the start of the SVG table) to the
112  * SVG Documents Index. Must be non-zero. */
113  /* Array of SVG Document Index Entries. */
114  HBUINT32 reserved; /* Set to 0. */
115  public:
117 };
118 
121 };
122 
123 } /* namespace OT */
124 
125 
126 #endif /* HB_OT_COLOR_SVG_TABLE_HH */
Definition: base.h:37
hb_blob_t * hb_blob_create_sub_blob(hb_blob_t *parent, unsigned int offset, unsigned int length)
Definition: hb-blob.cc:169
#define TRACE_SANITIZE(this)
Definition: hb-debug.hh:414
#define return_trace(RET)
Definition: hb-debug.hh:349
#define HB_OT_TAG_SVG
#define likely(expr)
Definition: hb.hh:250
GLenum face
GLboolean GLboolean g
const GLubyte * c
Definition: qopenglext.h:12701
GLenum GLenum GLsizei void * table
Definition: qopenglext.h:2745
uint32_t hb_codepoint_t
Definition: hb-common.h:106
uint32_t hb_tag_t
Definition: hb-common.h:157
hb_blob_t * reference_blob_for_glyph(hb_codepoint_t glyph_id) const
SVG_accelerator_t(hb_face_t *face)
HBUINT16 endGlyphID
int cmp(hb_codepoint_t g) const
hb_blob_t * reference_blob(hb_blob_t *svg_blob, unsigned int index_offset) const
NNOffset32To< UnsizedArrayOf< HBUINT8 > > svgDoc
bool sanitize(hb_sanitize_context_t *c, const void *base) const
HBUINT32 svgDocLength
DEFINE_SIZE_STATIC(12)
HBUINT16 startGlyphID
bool has_data() const
static constexpr hb_tag_t tableTag
DEFINE_SIZE_STATIC(10)
const SVGDocumentIndexEntry & get_glyph_entry(hb_codepoint_t glyph_id) const
Offset32To< SortedArray16Of< SVGDocumentIndexEntry > > svgDocEntries
bool sanitize(hb_sanitize_context_t *c) const