LCOV - code coverage report
Current view: directory - gfx/harfbuzz/src - hb-ot-shape-private.hh (source / functions) Found Hit Coverage
Test: app.info Lines: 21 0 0.0 %
Date: 2012-06-02 Functions: 8 0 0.0 %

       1                 : /*
       2                 :  * Copyright © 2010  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                 : #ifndef HB_OT_SHAPE_PRIVATE_HH
      28                 : #define HB_OT_SHAPE_PRIVATE_HH
      29                 : 
      30                 : #include "hb-private.hh"
      31                 : 
      32                 : #include "hb-ot-shape.h"
      33                 : 
      34                 : #include "hb-ot-map-private.hh"
      35                 : #include "hb-ot-shape-complex-private.hh"
      36                 : 
      37                 : 
      38                 : 
      39                 : enum hb_ot_complex_shaper_t;
      40                 : 
      41                 : struct hb_ot_shape_plan_t
      42                 : {
      43                 :   friend struct hb_ot_shape_planner_t;
      44                 : 
      45                 :   hb_ot_map_t map;
      46                 :   hb_ot_complex_shaper_t shaper;
      47                 : 
      48               0 :   hb_ot_shape_plan_t (void) : map () {}
      49               0 :   ~hb_ot_shape_plan_t (void) { map.finish (); }
      50                 : 
      51                 :   private:
      52                 :   NO_COPY (hb_ot_shape_plan_t);
      53                 : };
      54                 : 
      55                 : struct hb_ot_shape_planner_t
      56                 : {
      57                 :   hb_ot_map_builder_t map;
      58                 :   hb_ot_complex_shaper_t shaper;
      59                 : 
      60               0 :   hb_ot_shape_planner_t (void) : map () {}
      61               0 :   ~hb_ot_shape_planner_t (void) { map.finish (); }
      62                 : 
      63               0 :   inline void compile (hb_face_t *face,
      64                 :                        const hb_segment_properties_t *props,
      65                 :                        struct hb_ot_shape_plan_t &plan)
      66                 :   {
      67               0 :     plan.shaper = shaper;
      68               0 :     map.compile (face, props, plan.map);
      69               0 :   }
      70                 : 
      71                 :   private:
      72                 :   NO_COPY (hb_ot_shape_planner_t);
      73                 : };
      74                 : 
      75                 : 
      76                 : struct hb_ot_shape_context_t
      77                 : {
      78                 :   /* Input to hb_ot_shape_execute() */
      79                 :   hb_ot_shape_plan_t *plan;
      80                 :   hb_font_t *font;
      81                 :   hb_face_t *face;
      82                 :   hb_buffer_t  *buffer;
      83                 :   const hb_feature_t *user_features;
      84                 :   unsigned int        num_user_features;
      85                 : 
      86                 :   /* Transient stuff */
      87                 :   hb_direction_t target_direction;
      88                 :   hb_bool_t applied_substitute_complex;
      89                 :   hb_bool_t applied_position_complex;
      90                 : };
      91                 : 
      92                 : 
      93                 : static inline hb_bool_t
      94               0 : is_variation_selector (hb_codepoint_t unicode)
      95                 : {
      96               0 :   return unlikely ((unicode >=  0x180B && unicode <=  0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
      97                 :                    (unicode >=  0xFE00 && unicode <=  0xFE0F) || /* VARIATION SELECTOR-1..16 */
      98                 :                    (unicode >= 0xE0100 && unicode <= 0xE01EF));  /* VARIATION SELECTOR-17..256 */
      99                 : }
     100                 : 
     101                 : static inline unsigned int
     102               0 : _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
     103                 :                                       hb_codepoint_t      unicode)
     104                 : {
     105               0 :   int c = hb_unicode_combining_class (ufuncs, unicode);
     106                 : 
     107                 :   /* For Hebrew, we permute the "fixed-position" classes 10-25 into the order
     108                 :    * described in the SBL Hebrew manual http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
     109                 :    * (as recommended by http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
     110                 :    */
     111                 :   static const int permuted_hebrew_classes[25 - 10 + 1] = {
     112                 :     /* 10 sheva */        22,
     113                 :     /* 11 hataf segol */  15,
     114                 :     /* 12 hataf patah */  16,
     115                 :     /* 13 hataf qamats */ 17,
     116                 :     /* 14 hiriq */        23,
     117                 :     /* 15 tsere */        18,
     118                 :     /* 16 segol */        19,
     119                 :     /* 17 patah */        20,
     120                 :     /* 18 qamats */       21,
     121                 :     /* 19 holam */        14,
     122                 :     /* 20 qubuts */       24,
     123                 :     /* 21 dagesh */       12,
     124                 :     /* 22 meteg */        25,
     125                 :     /* 23 rafe */         13,
     126                 :     /* 24 shin dot */     10,
     127                 :     /* 25 sin dot */      11,
     128                 :   };
     129                 : 
     130                 :   /* Modify the combining-class to suit Arabic better.  See:
     131                 :    * http://unicode.org/faq/normalization.html#8
     132                 :    * http://unicode.org/faq/normalization.html#9
     133                 :    */
     134               0 :   if (unlikely (hb_in_range<int> (c, 27, 33)))
     135               0 :     c = c == 33 ? 27 : c + 1;
     136                 :   /* The equivalent fix for Hebrew is more complex,
     137                 :    * see the SBL Hebrew manual.
     138                 :    */
     139               0 :   else if (unlikely (hb_in_range<int> (c, 10, 25)))
     140               0 :     c = permuted_hebrew_classes[c - 10];
     141                 : 
     142               0 :   return c;
     143                 : }
     144                 : 
     145                 : static inline void
     146               0 : hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
     147                 : {
     148               0 :   info->general_category() = hb_unicode_general_category (unicode, info->codepoint);
     149               0 :   info->combining_class() = _hb_unicode_modified_combining_class (unicode, info->codepoint);
     150               0 : }
     151                 : 
     152                 : HB_INTERNAL void _hb_set_unicode_props (hb_buffer_t *buffer);
     153                 : 
     154                 : HB_INTERNAL void _hb_ot_shape_normalize (hb_ot_shape_context_t *c);
     155                 : 
     156                 : 
     157                 : #endif /* HB_OT_SHAPE_PRIVATE_HH */

Generated by: LCOV version 1.7