QtBase
v6.3.1
src
3rdparty
harfbuzz-ng
src
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
41
struct
SVGDocumentIndexEntry
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. */
65
NNOffset32To<UnsizedArrayOf<HBUINT8>
>
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
:
71
DEFINE_SIZE_STATIC
(12);
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
80
struct
accelerator_t
81
{
82
accelerator_t
(
hb_face_t
*
face
)
83
{
table
=
hb_sanitize_context_t
().reference_table<
SVG
> (
face
); }
84
~accelerator_t
() {
table
.destroy (); }
85
86
hb_blob_t
*
reference_blob_for_glyph
(
hb_codepoint_t
glyph_id)
const
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
:
95
hb_blob_ptr_t<SVG>
table
;
96
};
97
98
const
SVGDocumentIndexEntry
&
get_glyph_entry
(
hb_codepoint_t
glyph_id)
const
99
{
return
(
this
+
svgDocEntries
).bsearch (glyph_id); }
100
101
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
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). */
110
Offset32To<SortedArray16Of<SVGDocumentIndexEntry>
>
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
:
116
DEFINE_SIZE_STATIC
(10);
117
};
118
119
struct
SVG_accelerator_t
:
SVG::accelerator_t
{
120
SVG_accelerator_t
(
hb_face_t
*
face
) :
SVG
::
accelerator_t
(
face
) {}
121
};
122
123
}
/* namespace OT */
124
125
126
#endif
/* HB_OT_COLOR_SVG_TABLE_HH */
base
Definition:
base.h:37
hb_blob_create_sub_blob
hb_blob_t * hb_blob_create_sub_blob(hb_blob_t *parent, unsigned int offset, unsigned int length)
Definition:
hb-blob.cc:169
TRACE_SANITIZE
#define TRACE_SANITIZE(this)
Definition:
hb-debug.hh:414
return_trace
#define return_trace(RET)
Definition:
hb-debug.hh:349
hb-open-type.hh
HB_OT_TAG_SVG
#define HB_OT_TAG_SVG
Definition:
hb-ot-color-svg-table.hh:35
likely
#define likely(expr)
Definition:
hb.hh:250
OT
Definition:
hb-aat-layout-common.hh:33
face
GLenum face
Definition:
qopengles2ext.h:3591
g
GLboolean GLboolean g
Definition:
qopengles2ext.h:337
c
const GLubyte * c
Definition:
qopenglext.h:12701
table
GLenum GLenum GLsizei void * table
Definition:
qopenglext.h:2745
hb_codepoint_t
uint32_t hb_codepoint_t
Definition:
hb-common.h:106
hb_tag_t
uint32_t hb_tag_t
Definition:
hb-common.h:157
OT::IntType< uint16_t >
OT::OffsetTo
Definition:
hb-open-type.hh:301
OT::SVG::accelerator_t
Definition:
hb-ot-color-svg-table.hh:81
OT::SVG::accelerator_t::has_data
bool has_data() const
Definition:
hb-ot-color-svg-table.hh:92
OT::SVG::accelerator_t::~accelerator_t
~accelerator_t()
Definition:
hb-ot-color-svg-table.hh:84
OT::SVG::accelerator_t::accelerator_t
accelerator_t(hb_face_t *face)
Definition:
hb-ot-color-svg-table.hh:82
OT::SVG::accelerator_t::reference_blob_for_glyph
hb_blob_t * reference_blob_for_glyph(hb_codepoint_t glyph_id) const
Definition:
hb-ot-color-svg-table.hh:86
OT::SVG_accelerator_t
Definition:
hb-ot-color-svg-table.hh:119
OT::SVG_accelerator_t::SVG_accelerator_t
SVG_accelerator_t(hb_face_t *face)
Definition:
hb-ot-color-svg-table.hh:120
OT::SVGDocumentIndexEntry
Definition:
hb-ot-color-svg-table.hh:42
OT::SVGDocumentIndexEntry::endGlyphID
HBUINT16 endGlyphID
Definition:
hb-ot-color-svg-table.hh:63
OT::SVGDocumentIndexEntry::cmp
int cmp(hb_codepoint_t g) const
Definition:
hb-ot-color-svg-table.hh:43
OT::SVGDocumentIndexEntry::reference_blob
hb_blob_t * reference_blob(hb_blob_t *svg_blob, unsigned int index_offset) const
Definition:
hb-ot-color-svg-table.hh:46
OT::SVGDocumentIndexEntry::svgDoc
NNOffset32To< UnsizedArrayOf< HBUINT8 > > svgDoc
Definition:
hb-ot-color-svg-table.hh:66
OT::SVGDocumentIndexEntry::sanitize
bool sanitize(hb_sanitize_context_t *c, const void *base) const
Definition:
hb-ot-color-svg-table.hh:53
OT::SVGDocumentIndexEntry::svgDocLength
HBUINT32 svgDocLength
Definition:
hb-ot-color-svg-table.hh:68
OT::SVGDocumentIndexEntry::DEFINE_SIZE_STATIC
DEFINE_SIZE_STATIC(12)
OT::SVGDocumentIndexEntry::startGlyphID
HBUINT16 startGlyphID
Definition:
hb-ot-color-svg-table.hh:61
OT::SVG
Definition:
hb-ot-color-svg-table.hh:75
OT::SVG::has_data
bool has_data() const
Definition:
hb-ot-color-svg-table.hh:78
OT::SVG::tableTag
static constexpr hb_tag_t tableTag
Definition:
hb-ot-color-svg-table.hh:76
OT::SVG::DEFINE_SIZE_STATIC
DEFINE_SIZE_STATIC(10)
OT::SVG::version
HBUINT16 version
Definition:
hb-ot-color-svg-table.hh:109
OT::SVG::get_glyph_entry
const SVGDocumentIndexEntry & get_glyph_entry(hb_codepoint_t glyph_id) const
Definition:
hb-ot-color-svg-table.hh:98
OT::SVG::reserved
HBUINT32 reserved
Definition:
hb-ot-color-svg-table.hh:114
OT::SVG::svgDocEntries
Offset32To< SortedArray16Of< SVGDocumentIndexEntry > > svgDocEntries
Definition:
hb-ot-color-svg-table.hh:111
OT::SVG::sanitize
bool sanitize(hb_sanitize_context_t *c) const
Definition:
hb-ot-color-svg-table.hh:101
hb_blob_ptr_t
Definition:
hb-blob.hh:79
hb_blob_t
Definition:
hb-blob.hh:40
hb_face_t
Definition:
hb-face.hh:48
hb_sanitize_context_t
Definition:
hb-sanitize.hh:122
Generated by
1.9.1