2011-06-18 00:35:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Google, Inc.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
|
|
|
|
#define HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH
|
|
|
|
|
|
|
|
#include "hb-private.hh"
|
|
|
|
|
|
|
|
HB_BEGIN_DECLS
|
|
|
|
|
|
|
|
%%{
|
|
|
|
machine indic_syllable_machine;
|
|
|
|
alphtype unsigned char;
|
|
|
|
write data;
|
|
|
|
}%%
|
|
|
|
|
|
|
|
%%{
|
|
|
|
|
2011-06-25 01:05:34 +02:00
|
|
|
# Same order as enum indic_category_t. Not sure how to avoid duplication.
|
2011-06-18 00:35:46 +02:00
|
|
|
X = 0;
|
|
|
|
C = 1;
|
|
|
|
Ra = 2;
|
|
|
|
V = 3;
|
|
|
|
N = 4;
|
|
|
|
H = 5;
|
|
|
|
ZWNJ = 6;
|
|
|
|
ZWJ = 7;
|
|
|
|
M = 8;
|
|
|
|
SM = 9;
|
|
|
|
VD = 10;
|
|
|
|
A = 11;
|
|
|
|
NBSP = 12;
|
|
|
|
|
|
|
|
c = C | Ra;
|
|
|
|
z = ZWJ|ZWNJ;
|
|
|
|
matra_group = M N? H?;
|
|
|
|
syllable_tail = SM? (VD VD?)?;
|
|
|
|
|
2012-05-09 17:56:03 +02:00
|
|
|
action found_consonant_syllable { initial_reordering_consonant_syllable (map, buffer, mask_array, last, p); }
|
|
|
|
action found_vowel_syllable { initial_reordering_vowel_syllable (map, buffer, mask_array, last, p); }
|
|
|
|
action found_standalone_cluster { initial_reordering_standalone_cluster (map, buffer, mask_array, last, p); }
|
|
|
|
action found_non_indic { initial_reordering_non_indic (map, buffer, mask_array, last, p); }
|
|
|
|
|
|
|
|
action next_syllable {
|
|
|
|
for (unsigned int i = last; i < p; i++)
|
|
|
|
info[i].indic_syllable() = syllable_serial;
|
|
|
|
last = p;
|
|
|
|
syllable_serial++;
|
|
|
|
}
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2012-04-17 03:05:11 +02:00
|
|
|
consonant_syllable = (c.N? (H.z?|z.H))* c.N? A? (H.z? | matra_group*)? syllable_tail %(found_consonant_syllable);
|
2012-04-17 03:05:51 +02:00
|
|
|
vowel_syllable = (Ra H)? V N? (z?.H.c | ZWJ.c)? matra_group* syllable_tail %(found_vowel_syllable);
|
2011-07-29 22:37:02 +02:00
|
|
|
standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail %(found_standalone_cluster);
|
|
|
|
non_indic = X %(found_non_indic);
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
syllable =
|
|
|
|
consonant_syllable
|
|
|
|
| vowel_syllable
|
|
|
|
| standalone_cluster
|
|
|
|
| non_indic
|
|
|
|
;
|
|
|
|
|
2011-07-29 22:37:02 +02:00
|
|
|
main := (syllable %(next_syllable))**;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
}%%
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2011-07-29 22:37:02 +02:00
|
|
|
find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array)
|
2011-06-18 00:35:46 +02:00
|
|
|
{
|
|
|
|
unsigned int p, pe, eof;
|
|
|
|
int cs;
|
2012-05-09 17:56:03 +02:00
|
|
|
hb_glyph_info_t *info = buffer->info;
|
2011-06-18 00:35:46 +02:00
|
|
|
%%{
|
|
|
|
write init;
|
2012-05-09 17:56:03 +02:00
|
|
|
getkey info[p].indic_category();
|
2011-06-18 00:35:46 +02:00
|
|
|
}%%
|
|
|
|
|
|
|
|
p = 0;
|
2011-07-08 04:25:25 +02:00
|
|
|
pe = eof = buffer->len;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2011-07-04 18:56:38 +02:00
|
|
|
unsigned int last = 0;
|
2012-05-09 17:56:03 +02:00
|
|
|
uint8_t syllable_serial = 0;
|
2011-06-18 00:35:46 +02:00
|
|
|
%%{
|
|
|
|
write exec;
|
|
|
|
}%%
|
|
|
|
}
|
|
|
|
|
|
|
|
HB_END_DECLS
|
|
|
|
|
|
|
|
#endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */
|