7784fae3331e89f2a3557b8d06d52a09358d4814
[platform/upstream/harfbuzz.git] / src / hb-aat-layout.cc
1 /*
2  * Copyright © 2017  Google, 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  * Google Author(s): Behdad Esfahbod
25  */
26
27 #include "hb-open-type-private.hh"
28
29 #include "hb-ot-layout-private.hh"
30 #include "hb-ot-layout-gsubgpos-private.hh"
31
32 #include "hb-aat-layout-private.hh"
33 #include "hb-aat-layout-ankr-table.hh"
34 #include "hb-aat-layout-bsln-table.hh" // Just so we compile it; unused otherwise.
35 #include "hb-aat-layout-feat-table.hh" // Just so we compile it; unused otherwise.
36 #include "hb-aat-layout-kerx-table.hh"
37 #include "hb-aat-layout-morx-table.hh"
38 #include "hb-aat-layout-trak-table.hh"
39 #include "hb-aat-fmtx-table.hh" // Just so we compile it; unused otherwise.
40 #include "hb-aat-gcid-table.hh" // Just so we compile it; unused otherwise.
41 #include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise.
42
43 /*
44  * morx/kerx/trak
45  */
46
47 #if 0
48 static inline const AAT::ankr&
49 _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr)
50 {
51   if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
52   {
53     if (blob)
54       *blob = hb_blob_get_empty ();
55     return Null(AAT::ankr);
56   }
57   hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
58   const AAT::ankr& ankr = *(layout->ankr.get ());
59   if (blob)
60     *blob = layout->ankr.blob;
61   return ankr;
62 }
63
64 static inline const AAT::kerx&
65 _get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr)
66 {
67   if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
68   {
69     if (blob)
70       *blob = hb_blob_get_empty ();
71     return Null(AAT::kerx);
72   }
73   hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
74   /* XXX this doesn't call set_num_glyphs on sanitizer. */
75   const AAT::kerx& kerx = *(layout->kerx.get ());
76   if (blob)
77     *blob = layout->kerx.blob;
78   return kerx;
79 }
80
81 static inline const AAT::morx&
82 _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
83 {
84   if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
85   {
86     if (blob)
87       *blob = hb_blob_get_empty ();
88     return Null(AAT::morx);
89   }
90   hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
91   /* XXX this doesn't call set_num_glyphs on sanitizer. */
92   const AAT::morx& morx = *(layout->morx.get ());
93   if (blob)
94     *blob = layout->morx.blob;
95   return morx;
96 }
97
98 static inline const AAT::trak&
99 _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
100 {
101   if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
102   {
103     if (blob)
104       *blob = hb_blob_get_empty ();
105     return Null(AAT::trak);
106   }
107   hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
108   const AAT::trak& trak = *(layout->trak.get ());
109   if (blob)
110     *blob = layout->trak.blob;
111   return trak;
112 }
113 #endif
114
115 // static inline void
116 // _hb_aat_layout_create (hb_face_t *face)
117 // {
118 //   OT::Sanitizer<AAT::morx> sanitizer;
119 //   sanitizer.set_num_glyphs (face->get_num_glyphs ());
120 //   hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_morx));
121 //   morx_blob->as<AAT::morx> ();
122
123 //   if (0)
124 //   {
125 //     morx_blob->as<AAT::Lookup<OT::GlyphID> > ()->get_value (1, face->get_num_glyphs ());
126 //   }
127 // }
128
129 void
130 hb_aat_layout_substitute (hb_font_t *font, hb_buffer_t *buffer)
131 {
132 #if 0
133   hb_blob_t *blob;
134   const AAT::morx& morx = _get_morx (font->face, &blob);
135
136   AAT::hb_aat_apply_context_t c (font, buffer, blob);
137   morx.apply (&c);
138 #endif
139 }
140
141 void
142 hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer)
143 {
144 #if 0
145   hb_blob_t *blob;
146   const AAT::ankr& ankr = _get_ankr (font->face, &blob);
147   const AAT::kerx& kerx = _get_kerx (font->face, &blob);
148   const AAT::trak& trak = _get_trak (font->face, &blob);
149
150   AAT::hb_aat_apply_context_t c (font, buffer, blob);
151   kerx.apply (&c, &ankr);
152   trak.apply (&c);
153 #endif
154 }