1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 // This file is available under and governed by the GNU General Public 26 // License version 2 only, as published by the Free Software Foundation. 27 // However, the following notice accompanied the original version of this 28 // file: 29 // 30 /* 31 * Copyright © 2010 Google, Inc. 32 * 33 * This is part of HarfBuzz, a text shaping library. 34 * 35 * Permission is hereby granted, without written agreement and without 36 * license or royalty fees, to use, copy, modify, and distribute this 37 * software and its documentation for any purpose, provided that the 38 * above copyright notice and the following two paragraphs appear in 39 * all copies of this software. 40 * 41 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 42 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 43 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 44 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 45 * DAMAGE. 46 * 47 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 48 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 49 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 50 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 51 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 52 * 53 * Google Author(s): Behdad Esfahbod 54 */ 55 56 #ifndef HB_OT_SHAPE_PRIVATE_HH 57 #define HB_OT_SHAPE_PRIVATE_HH 58 59 #include "hb-private.hh" 60 61 #include "hb-ot-map-private.hh" 62 #include "hb-ot-layout-private.hh" 63 64 65 66 struct hb_ot_shape_plan_t 67 { 68 hb_segment_properties_t props; 69 const struct hb_ot_complex_shaper_t *shaper; 70 hb_ot_map_t map; 71 const void *data; 72 hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; 73 hb_mask_t kern_mask; 74 unsigned int has_frac : 1; 75 unsigned int has_kern : 1; 76 unsigned int has_mark : 1; 77 78 inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const 79 { 80 unsigned int table_index; 81 switch (table_tag) { 82 case HB_OT_TAG_GSUB: table_index = 0; break; 83 case HB_OT_TAG_GPOS: table_index = 1; break; 84 default: return; 85 } 86 map.collect_lookups (table_index, lookups); 87 } 88 inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); } 89 inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); } 90 91 void finish (void) { map.finish (); } 92 }; 93 94 struct hb_ot_shape_planner_t 95 { 96 /* In the order that they are filled in. */ 97 hb_face_t *face; 98 hb_segment_properties_t props; 99 const struct hb_ot_complex_shaper_t *shaper; 100 hb_ot_map_builder_t map; 101 102 hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) : 103 face (master_plan->face_unsafe), 104 props (master_plan->props), 105 shaper (NULL), 106 map (face, &props) {} 107 ~hb_ot_shape_planner_t (void) { map.finish (); } 108 109 inline void compile (hb_ot_shape_plan_t &plan) 110 { 111 plan.props = props; 112 plan.shaper = shaper; 113 map.compile (plan.map); 114 115 plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); 116 plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); 117 plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); 118 plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); 119 120 plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? 121 HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); 122 123 plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); 124 plan.has_kern = !!plan.kern_mask; 125 plan.has_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); 126 } 127 128 private: 129 NO_COPY (hb_ot_shape_planner_t); 130 }; 131 132 133 #endif /* HB_OT_SHAPE_PRIVATE_HH */