gfx/harfbuzz/src/hb-ot-shape-complex-myanmar-machine.rl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/harfbuzz/src/hb-ot-shape-complex-myanmar-machine.rl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,128 @@
     1.4 +/*
     1.5 + * Copyright © 2011,2012  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_COMPLEX_MYANMAR_MACHINE_HH
    1.31 +#define HB_OT_SHAPE_COMPLEX_MYANMAR_MACHINE_HH
    1.32 +
    1.33 +#include "hb-private.hh"
    1.34 +
    1.35 +%%{
    1.36 +  machine myanmar_syllable_machine;
    1.37 +  alphtype unsigned char;
    1.38 +  write data;
    1.39 +}%%
    1.40 +
    1.41 +%%{
    1.42 +
    1.43 +# Same order as enum myanmar_category_t.  Not sure how to avoid duplication.
    1.44 +A    = 10;
    1.45 +As   = 18;
    1.46 +C    = 1;
    1.47 +D    = 19;
    1.48 +D0   = 20;
    1.49 +DB   = 3;
    1.50 +GB   = 12;
    1.51 +H    = 4;
    1.52 +IV   = 2;
    1.53 +MH   = 21;
    1.54 +MR   = 22;
    1.55 +MW   = 23;
    1.56 +MY   = 24;
    1.57 +PT   = 25;
    1.58 +V    = 8;
    1.59 +VAbv = 26;
    1.60 +VBlw = 27;
    1.61 +VPre = 28;
    1.62 +VPst = 29;
    1.63 +VS   = 30;
    1.64 +ZWJ  = 6;
    1.65 +ZWNJ = 5;
    1.66 +Ra   = 16;
    1.67 +P    = 31;
    1.68 +
    1.69 +j = ZWJ|ZWNJ;			# Joiners
    1.70 +k = (Ra As H);			# Kinzi
    1.71 +
    1.72 +c = C|Ra;			# is_consonant
    1.73 +
    1.74 +medial_group = MY? MR? ((MW MH? | MH) As?)?;
    1.75 +main_vowel_group = VPre* VAbv* VBlw* A* (DB As?)?;
    1.76 +post_vowel_group = VPst MH? As* VAbv* A* (DB As?)?;
    1.77 +pwo_tone_group = PT A* DB? As?;
    1.78 +
    1.79 +complex_syllable_tail = As* medial_group main_vowel_group post_vowel_group* pwo_tone_group* V* j?;
    1.80 +syllable_tail = (H | complex_syllable_tail);
    1.81 +
    1.82 +consonant_syllable =	k? (c|IV|D|GB).VS? (H (c|IV).VS?)* syllable_tail;
    1.83 +punctuation_cluster = 	P V;
    1.84 +broken_cluster =	k? VS? syllable_tail;
    1.85 +other =			any;
    1.86 +
    1.87 +main := |*
    1.88 +	consonant_syllable	=> { found_syllable (consonant_syllable); };
    1.89 +	j			=> { found_syllable (non_myanmar_cluster); };
    1.90 +	punctuation_cluster	=> { found_syllable (punctuation_cluster); };
    1.91 +	broken_cluster		=> { found_syllable (broken_cluster); };
    1.92 +	other			=> { found_syllable (non_myanmar_cluster); };
    1.93 +*|;
    1.94 +
    1.95 +
    1.96 +}%%
    1.97 +
    1.98 +#define found_syllable(syllable_type) \
    1.99 +  HB_STMT_START { \
   1.100 +    if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
   1.101 +    for (unsigned int i = last; i < p+1; i++) \
   1.102 +      info[i].syllable() = (syllable_serial << 4) | syllable_type; \
   1.103 +    last = p+1; \
   1.104 +    syllable_serial++; \
   1.105 +    if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
   1.106 +  } HB_STMT_END
   1.107 +
   1.108 +static void
   1.109 +find_syllables (hb_buffer_t *buffer)
   1.110 +{
   1.111 +  unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
   1.112 +  int cs;
   1.113 +  hb_glyph_info_t *info = buffer->info;
   1.114 +  %%{
   1.115 +    write init;
   1.116 +    getkey info[p].myanmar_category();
   1.117 +  }%%
   1.118 +
   1.119 +  p = 0;
   1.120 +  pe = eof = buffer->len;
   1.121 +
   1.122 +  unsigned int last = 0;
   1.123 +  unsigned int syllable_serial = 1;
   1.124 +  %%{
   1.125 +    write exec;
   1.126 +  }%%
   1.127 +}
   1.128 +
   1.129 +#undef found_syllable
   1.130 +
   1.131 +#endif /* HB_OT_SHAPE_COMPLEX_MYANMAR_MACHINE_HH */

mercurial