1 /*
2 * Copyright © 2018 Ebrahim Byagowi
3 * Copyright © 2020 Google, Inc.
4 *
5 * This is part of HarfBuzz, a text shaping library.
6 *
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 */
26
27 #ifndef OT_COLOR_COLR_COLRV1_CLOSURE_HH
28 #define OT_COLOR_COLR_COLRV1_CLOSURE_HH
29
30 #include "../../../hb-open-type.hh"
31 #include "COLR.hh"
32
33 /*
34 * COLR -- Color
35 * https://docs.microsoft.com/en-us/typography/opentype/spec/colr
36 */
37 namespace OT {
38
closurev1(hb_colrv1_closure_context_t * c) const39 HB_INTERNAL void PaintColrLayers::closurev1 (hb_colrv1_closure_context_t* c) const
40 {
41 c->add_layer_indices (firstLayerIndex, numLayers);
42 const LayerList &paint_offset_lists = c->get_colr_table ()->get_layerList ();
43 for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++)
44 {
45 const Paint &paint = std::addressof (paint_offset_lists) + paint_offset_lists[i];
46 paint.dispatch (c);
47 }
48 }
49
closurev1(hb_colrv1_closure_context_t * c) const50 HB_INTERNAL void PaintGlyph::closurev1 (hb_colrv1_closure_context_t* c) const
51 {
52 c->add_glyph (gid);
53 (this+paint).dispatch (c);
54 }
55
closurev1(hb_colrv1_closure_context_t * c) const56 HB_INTERNAL void PaintColrGlyph::closurev1 (hb_colrv1_closure_context_t* c) const
57 {
58 const COLR *colr_table = c->get_colr_table ();
59 const BaseGlyphPaintRecord* baseglyph_paintrecord = colr_table->get_base_glyph_paintrecord (gid);
60 if (!baseglyph_paintrecord) return;
61 c->add_glyph (gid);
62
63 const BaseGlyphList &baseglyph_list = colr_table->get_baseglyphList ();
64 (&baseglyph_list+baseglyph_paintrecord->paint).dispatch (c);
65 }
66
67 template <template<typename> class Var>
closurev1(hb_colrv1_closure_context_t * c) const68 HB_INTERNAL void PaintTransform<Var>::closurev1 (hb_colrv1_closure_context_t* c) const
69 {
70 (this+src).dispatch (c);
71 (this+transform).closurev1 (c);
72 }
73
closurev1(hb_colrv1_closure_context_t * c) const74 HB_INTERNAL void PaintTranslate::closurev1 (hb_colrv1_closure_context_t* c) const
75 {
76 (this+src).dispatch (c);
77 c->num_var_idxes = 2;
78 }
79
closurev1(hb_colrv1_closure_context_t * c) const80 HB_INTERNAL void PaintScale::closurev1 (hb_colrv1_closure_context_t* c) const
81 {
82 (this+src).dispatch (c);
83 c->num_var_idxes = 2;
84 }
85
closurev1(hb_colrv1_closure_context_t * c) const86 HB_INTERNAL void PaintScaleAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
87 {
88 (this+src).dispatch (c);
89 c->num_var_idxes = 4;
90 }
91
closurev1(hb_colrv1_closure_context_t * c) const92 HB_INTERNAL void PaintScaleUniform::closurev1 (hb_colrv1_closure_context_t* c) const
93 {
94 (this+src).dispatch (c);
95 c->num_var_idxes = 1;
96 }
97
closurev1(hb_colrv1_closure_context_t * c) const98 HB_INTERNAL void PaintScaleUniformAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
99 {
100 (this+src).dispatch (c);
101 c->num_var_idxes = 3;
102 }
103
closurev1(hb_colrv1_closure_context_t * c) const104 HB_INTERNAL void PaintRotate::closurev1 (hb_colrv1_closure_context_t* c) const
105 {
106 (this+src).dispatch (c);
107 c->num_var_idxes = 1;
108 }
109
closurev1(hb_colrv1_closure_context_t * c) const110 HB_INTERNAL void PaintRotateAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
111 {
112 (this+src).dispatch (c);
113 c->num_var_idxes = 3;
114 }
115
closurev1(hb_colrv1_closure_context_t * c) const116 HB_INTERNAL void PaintSkew::closurev1 (hb_colrv1_closure_context_t* c) const
117 {
118 (this+src).dispatch (c);
119 c->num_var_idxes = 2;
120 }
121
closurev1(hb_colrv1_closure_context_t * c) const122 HB_INTERNAL void PaintSkewAroundCenter::closurev1 (hb_colrv1_closure_context_t* c) const
123 {
124 (this+src).dispatch (c);
125 c->num_var_idxes = 4;
126 }
127
closurev1(hb_colrv1_closure_context_t * c) const128 HB_INTERNAL void PaintComposite::closurev1 (hb_colrv1_closure_context_t* c) const
129 {
130 (this+src).dispatch (c);
131 (this+backdrop).dispatch (c);
132 }
133
134 } /* namespace OT */
135
136
137 #endif /* OT_COLOR_COLR_COLRV1_CLOSURE_HH */
138