1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/harfbuzz/src/hb-ot-shape-private.hh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +/* 1.5 + * Copyright © 2010 Google, Inc. 1.6 + * 1.7 + * This is part of HarfBuzz, a text shaping library. 1.8 + * 1.9 + * Permission is hereby granted, without written agreement and without 1.10 + * license or royalty fees, to use, copy, modify, and distribute this 1.11 + * software and its documentation for any purpose, provided that the 1.12 + * above copyright notice and the following two paragraphs appear in 1.13 + * all copies of this software. 1.14 + * 1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1.19 + * DAMAGE. 1.20 + * 1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 1.23 + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 1.26 + * 1.27 + * Google Author(s): Behdad Esfahbod 1.28 + */ 1.29 + 1.30 +#ifndef HB_OT_SHAPE_PRIVATE_HH 1.31 +#define HB_OT_SHAPE_PRIVATE_HH 1.32 + 1.33 +#include "hb-private.hh" 1.34 + 1.35 +#include "hb-ot-map-private.hh" 1.36 +#include "hb-ot-layout-private.hh" 1.37 + 1.38 + 1.39 + 1.40 +struct hb_ot_shape_plan_t 1.41 +{ 1.42 + hb_segment_properties_t props; 1.43 + const struct hb_ot_complex_shaper_t *shaper; 1.44 + hb_ot_map_t map; 1.45 + const void *data; 1.46 + hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; 1.47 + hb_mask_t kern_mask; 1.48 + unsigned int has_frac : 1; 1.49 + unsigned int has_kern : 1; 1.50 + 1.51 + inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const 1.52 + { 1.53 + unsigned int table_index; 1.54 + switch (table_tag) { 1.55 + case HB_OT_TAG_GSUB: table_index = 0; break; 1.56 + case HB_OT_TAG_GPOS: table_index = 1; break; 1.57 + default: return; 1.58 + } 1.59 + map.collect_lookups (table_index, lookups); 1.60 + } 1.61 + inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); } 1.62 + inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); } 1.63 + 1.64 + void finish (void) { map.finish (); } 1.65 +}; 1.66 + 1.67 +struct hb_ot_shape_planner_t 1.68 +{ 1.69 + /* In the order that they are filled in. */ 1.70 + hb_face_t *face; 1.71 + hb_segment_properties_t props; 1.72 + const struct hb_ot_complex_shaper_t *shaper; 1.73 + hb_ot_map_builder_t map; 1.74 + 1.75 + hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) : 1.76 + face (master_plan->face_unsafe), 1.77 + props (master_plan->props), 1.78 + shaper (NULL), 1.79 + map (face, &props) {} 1.80 + ~hb_ot_shape_planner_t (void) { map.finish (); } 1.81 + 1.82 + inline void compile (hb_ot_shape_plan_t &plan) 1.83 + { 1.84 + plan.props = props; 1.85 + plan.shaper = shaper; 1.86 + map.compile (plan.map); 1.87 + 1.88 + plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); 1.89 + plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); 1.90 + plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); 1.91 + plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); 1.92 + 1.93 + plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? 1.94 + HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); 1.95 + 1.96 + plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); 1.97 + plan.has_kern = !!plan.kern_mask; 1.98 + } 1.99 + 1.100 + private: 1.101 + NO_COPY (hb_ot_shape_planner_t); 1.102 +}; 1.103 + 1.104 + 1.105 +#endif /* HB_OT_SHAPE_PRIVATE_HH */