blob: e8c81015c792ea52b53cb9636aae4cabcc316ccf [file] [log] [blame]
Behdad Esfahboda8067622010-10-08 19:18:40 -04001/*
Behdad Esfahbod2409d5f2011-04-21 17:14:28 -04002 * Copyright © 2010 Google, Inc.
Behdad Esfahboda8067622010-10-08 19:18:40 -04003 *
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
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070027#ifndef HB_OT_SHAPE_HH
28#define HB_OT_SHAPE_HH
Behdad Esfahboda8067622010-10-08 19:18:40 -040029
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070030#include "hb.hh"
Behdad Esfahboda8067622010-10-08 19:18:40 -040031
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070032#include "hb-ot-map.hh"
Behdad Esfahbodffe34782018-10-23 14:14:03 -070033#include "hb-aat-map.hh"
Behdad Esfahboda8067622010-10-08 19:18:40 -040034
Behdad Esfahboda8067622010-10-08 19:18:40 -040035
Behdad Esfahbodcc842872018-11-12 18:48:10 -050036struct hb_ot_shape_plan_key_t
37{
38 unsigned int variations_index[2];
39
Ebrahim Byagowi071e2e32020-03-26 12:01:53 +043040 void init (hb_face_t *face,
41 const int *coords,
42 unsigned num_coords)
Behdad Esfahbodcc842872018-11-12 18:48:10 -050043 {
44 for (unsigned int table_index = 0; table_index < 2; table_index++)
45 hb_ot_layout_table_find_feature_variations (face,
46 table_tags[table_index],
47 coords,
48 num_coords,
49 &variations_index[table_index]);
50 }
51
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033052 bool equal (const hb_ot_shape_plan_key_t *other)
Behdad Esfahbodcc842872018-11-12 18:48:10 -050053 {
54 return 0 == memcmp (this, other, sizeof (*this));
55 }
56};
57
58
Behdad Esfahbod10823382018-11-12 18:05:02 -050059struct hb_shape_plan_key_t;
60
Behdad Esfahbod13403bc2010-10-12 17:23:54 -040061struct hb_ot_shape_plan_t
62{
Behdad Esfahbod16c6a272012-08-02 09:38:28 -040063 hb_segment_properties_t props;
64 const struct hb_ot_complex_shaper_t *shaper;
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -040065 hb_ot_map_t map;
Behdad Esfahbodffe34782018-10-23 14:14:03 -070066 hb_aat_map_t aat_map;
Behdad Esfahboda8c6da92012-08-02 10:46:34 -040067 const void *data;
Behdad Esfahbodd84932b2019-06-19 16:57:48 -070068#ifndef HB_NO_OT_SHAPE_FRACTIONS
Behdad Esfahbodcf92d652018-10-23 03:10:56 -070069 hb_mask_t frac_mask, numr_mask, dnom_mask;
Behdad Esfahbodd84932b2019-06-19 16:57:48 -070070#else
71 static constexpr hb_mask_t frac_mask = 0;
72 static constexpr hb_mask_t numr_mask = 0;
73 static constexpr hb_mask_t dnom_mask = 0;
74#endif
Behdad Esfahbodcf92d652018-10-23 03:10:56 -070075 hb_mask_t rtlm_mask;
Behdad Esfahbodd8bf6722019-06-19 17:04:16 -070076#ifndef HB_NO_OT_KERN
Behdad Esfahbod5497a8a2013-12-22 20:48:53 -050077 hb_mask_t kern_mask;
Behdad Esfahbodd8bf6722019-06-19 17:04:16 -070078#else
79 static constexpr hb_mask_t kern_mask = 0;
80#endif
Behdad Esfahbod12092a42019-06-26 13:31:01 -070081#ifndef HB_NO_AAT_SHAPE
Behdad Esfahbodcf92d652018-10-23 03:10:56 -070082 hb_mask_t trak_mask;
Behdad Esfahbod43d70482019-06-19 17:02:32 -070083#else
84 static constexpr hb_mask_t trak_mask = 0;
85#endif
Behdad Esfahbod96eca872018-10-02 13:24:40 +020086
Behdad Esfahbodd8bf6722019-06-19 17:04:16 -070087#ifndef HB_NO_OT_KERN
Behdad Esfahbod60f86d32018-10-10 18:10:05 -040088 bool requested_kerning : 1;
Behdad Esfahbodd8bf6722019-06-19 17:04:16 -070089#else
90 static constexpr bool requested_kerning = false;
91#endif
Behdad Esfahbod12092a42019-06-26 13:31:01 -070092#ifndef HB_NO_AAT_SHAPE
Behdad Esfahbodcf92d652018-10-23 03:10:56 -070093 bool requested_tracking : 1;
Behdad Esfahbod43d70482019-06-19 17:02:32 -070094#else
95 static constexpr bool requested_tracking = false;
96#endif
Behdad Esfahbodd84932b2019-06-19 16:57:48 -070097#ifndef HB_NO_OT_SHAPE_FRACTIONS
Behdad Esfahbod1d1734e2018-10-02 13:04:05 +020098 bool has_frac : 1;
Behdad Esfahbodd84932b2019-06-19 16:57:48 -070099#else
100 static constexpr bool has_frac = false;
101#endif
Behdad Esfahbod2dc20e62019-12-05 15:28:42 +0000102 bool has_vert : 1;
Behdad Esfahbod1d1734e2018-10-02 13:04:05 +0200103 bool has_gpos_mark : 1;
Behdad Esfahbodca235672018-11-07 16:19:51 -0500104 bool zero_marks : 1;
Behdad Esfahbod96eca872018-10-02 13:24:40 +0200105 bool fallback_glyph_classes : 1;
Behdad Esfahbod09ad2612018-10-08 23:30:24 -0400106 bool fallback_mark_positioning : 1;
Behdad Esfahboda201fa72018-11-22 15:52:29 -0500107 bool adjust_mark_positioning_when_zeroing : 1;
Behdad Esfahbod8bb5deb2012-08-02 10:07:58 -0400108
Behdad Esfahbodb59a4282018-10-11 13:24:17 -0400109 bool apply_gpos : 1;
Behdad Esfahbod588697a2019-06-19 16:24:51 -0700110#ifndef HB_NO_OT_KERN
Behdad Esfahboda5195882018-10-08 23:57:45 -0400111 bool apply_kern : 1;
Behdad Esfahbod588697a2019-06-19 16:24:51 -0700112#else
113 static constexpr bool apply_kern = false;
114#endif
Behdad Esfahbod79e8b302021-07-16 15:06:10 -0600115 bool apply_fallback_kern : 1;
Behdad Esfahbod12092a42019-06-26 13:31:01 -0700116#ifndef HB_NO_AAT_SHAPE
Behdad Esfahbod809c5872019-05-13 14:45:51 -0700117 bool apply_kerx : 1;
Behdad Esfahbodb59a4282018-10-11 13:24:17 -0400118 bool apply_morx : 1;
119 bool apply_trak : 1;
Behdad Esfahbod809c5872019-05-13 14:45:51 -0700120#else
121 static constexpr bool apply_kerx = false;
122 static constexpr bool apply_morx = false;
123 static constexpr bool apply_trak = false;
124#endif
Behdad Esfahbod14ff3cb2018-10-04 11:34:21 +0200125
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +0330126 void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800127 {
128 unsigned int table_index;
129 switch (table_tag) {
130 case HB_OT_TAG_GSUB: table_index = 0; break;
131 case HB_OT_TAG_GPOS: table_index = 1; break;
132 default: return;
133 }
134 map.collect_lookups (table_index, lookups);
135 }
Behdad Esfahbod8bb5deb2012-08-02 10:07:58 -0400136
Behdad Esfahbod3e284e02018-11-11 22:51:34 -0500137 HB_INTERNAL bool init0 (hb_face_t *face,
Behdad Esfahbod10823382018-11-12 18:05:02 -0500138 const hb_shape_plan_key_t *key);
Ebrahim Byagowie4120082018-12-17 21:31:01 +0330139 HB_INTERNAL void fini ();
Behdad Esfahbodc221dc02018-11-14 14:49:34 -0500140
141 HB_INTERNAL void substitute (hb_font_t *font, hb_buffer_t *buffer) const;
142 HB_INTERNAL void position (hb_font_t *font, hb_buffer_t *buffer) const;
Behdad Esfahbod13403bc2010-10-12 17:23:54 -0400143};
144
Behdad Esfahbodf521a282018-11-11 21:32:01 -0500145struct hb_shape_plan_t;
146
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -0400147struct hb_ot_shape_planner_t
148{
149 /* In the order that they are filled in. */
150 hb_face_t *face;
151 hb_segment_properties_t props;
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -0400152 hb_ot_map_builder_t map;
Behdad Esfahbodffe34782018-10-23 14:14:03 -0700153 hb_aat_map_builder_t aat_map;
Behdad Esfahbod12092a42019-06-26 13:31:01 -0700154#ifndef HB_NO_AAT_SHAPE
Behdad Esfahbod76324d92018-10-23 13:09:30 -0700155 bool apply_morx : 1;
Behdad Esfahbod809c5872019-05-13 14:45:51 -0700156#else
157 static constexpr bool apply_morx = false;
158#endif
Behdad Esfahboda201fa72018-11-22 15:52:29 -0500159 bool script_zero_marks : 1;
160 bool script_fallback_mark_positioning : 1;
Behdad Esfahbod76324d92018-10-23 13:09:30 -0700161 const struct hb_ot_complex_shaper_t *shaper;
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -0400162
Behdad Esfahbod3e284e02018-11-11 22:51:34 -0500163 HB_INTERNAL hb_ot_shape_planner_t (hb_face_t *face,
164 const hb_segment_properties_t *props);
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -0400165
Behdad Esfahbodcc842872018-11-12 18:48:10 -0500166 HB_INTERNAL void compile (hb_ot_shape_plan_t &plan,
167 const hb_ot_shape_plan_key_t &key);
Behdad Esfahbod5393e3a2012-08-02 09:24:35 -0400168};
169
170
Behdad Esfahbodc77ae402018-08-25 22:36:36 -0700171#endif /* HB_OT_SHAPE_HH */