/src/harfbuzz/src/OT/Layout/GPOS/Anchor.hh
Line  | Count  | Source  | 
1  |  | #ifndef OT_LAYOUT_GPOS_ANCHOR_HH  | 
2  |  | #define OT_LAYOUT_GPOS_ANCHOR_HH  | 
3  |  |  | 
4  |  | #include "AnchorFormat1.hh"  | 
5  |  | #include "AnchorFormat2.hh"  | 
6  |  | #include "AnchorFormat3.hh"  | 
7  |  |  | 
8  |  | namespace OT { | 
9  |  | namespace Layout { | 
10  |  | namespace GPOS_impl { | 
11  |  |  | 
12  |  | struct Anchor  | 
13  |  | { | 
14  |  |   protected:  | 
15  |  |   union { | 
16  |  |   HBUINT16              format;         /* Format identifier */  | 
17  |  |   AnchorFormat1         format1;  | 
18  |  |   AnchorFormat2         format2;  | 
19  |  |   AnchorFormat3         format3;  | 
20  |  |   } u;  | 
21  |  |   public:  | 
22  |  |   DEFINE_SIZE_UNION (2, format);  | 
23  |  |  | 
24  |  |   bool sanitize (hb_sanitize_context_t *c) const  | 
25  | 3.13k  |   { | 
26  | 3.13k  |     TRACE_SANITIZE (this);  | 
27  | 3.13k  |     if (!u.format.sanitize (c)) return_trace (false);  | 
28  | 3.13k  |     hb_barrier ();  | 
29  | 3.13k  |     switch (u.format) { | 
30  | 3.10k  |     case 1: return_trace (u.format1.sanitize (c));  | 
31  | 31  |     case 2: return_trace (u.format2.sanitize (c));  | 
32  | 0  |     case 3: return_trace (u.format3.sanitize (c));  | 
33  | 0  |     default:return_trace (true);  | 
34  | 3.13k  |     }  | 
35  | 3.13k  |   }  | 
36  |  |  | 
37  |  |   void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id,  | 
38  |  |                    float *x, float *y) const  | 
39  | 0  |   { | 
40  | 0  |     *x = *y = 0;  | 
41  | 0  |     switch (u.format) { | 
42  | 0  |     case 1: u.format1.get_anchor (c, glyph_id, x, y); return;  | 
43  | 0  |     case 2: u.format2.get_anchor (c, glyph_id, x, y); return;  | 
44  | 0  |     case 3: u.format3.get_anchor (c, glyph_id, x, y); return;  | 
45  | 0  |     default:                                          return;  | 
46  | 0  |     }  | 
47  | 0  |   }  | 
48  |  |  | 
49  |  |   bool subset (hb_subset_context_t *c) const  | 
50  | 0  |   { | 
51  | 0  |     TRACE_SUBSET (this);  | 
52  | 0  |     switch (u.format) { | 
53  | 0  |     case 1: return_trace (bool (reinterpret_cast<Anchor *> (u.format1.copy (c->serializer))));  | 
54  | 0  |     case 2:  | 
55  | 0  |       if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)  | 
56  | 0  |       { | 
57  | 0  |         // AnchorFormat 2 just containins extra hinting information, so  | 
58  | 0  |         // if hints are being dropped convert to format 1.  | 
59  | 0  |         return_trace (bool (reinterpret_cast<Anchor *> (u.format1.copy (c->serializer))));  | 
60  | 0  |       }  | 
61  | 0  |       return_trace (bool (reinterpret_cast<Anchor *> (u.format2.copy (c->serializer))));  | 
62  | 0  |     case 3: return_trace (u.format3.subset (c));  | 
63  | 0  |     default:return_trace (false);  | 
64  | 0  |     }  | 
65  | 0  |   }  | 
66  |  |  | 
67  |  |   void collect_variation_indices (hb_collect_variation_indices_context_t *c) const  | 
68  | 0  |   { | 
69  | 0  |     switch (u.format) { | 
70  | 0  |     case 1: case 2:  | 
71  | 0  |       return;  | 
72  | 0  |     case 3:  | 
73  | 0  |       u.format3.collect_variation_indices (c);  | 
74  | 0  |       return;  | 
75  | 0  |     default: return;  | 
76  | 0  |     }  | 
77  | 0  |   }  | 
78  |  | };  | 
79  |  |  | 
80  |  | }  | 
81  |  | }  | 
82  |  | }  | 
83  |  |  | 
84  |  | #endif  // OT_LAYOUT_GPOS_ANCHOR_HH  |