2011-06-18 00:35:46 +02:00
|
|
|
/*
|
2012-05-24 21:00:01 +02:00
|
|
|
* Copyright © 2011,2012 Google, Inc.
|
2011-06-18 00:35:46 +02:00
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
%%{
|
|
|
|
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;
|
2012-07-18 00:17:30 +02:00
|
|
|
V = 2;
|
|
|
|
N = 3;
|
|
|
|
H = 4;
|
|
|
|
ZWNJ = 5;
|
|
|
|
ZWJ = 6;
|
|
|
|
M = 7;
|
|
|
|
SM = 8;
|
|
|
|
VD = 9;
|
|
|
|
A = 10;
|
|
|
|
NBSP = 11;
|
|
|
|
DOTTEDCIRCLE = 12;
|
|
|
|
RS = 13;
|
|
|
|
Coeng = 14;
|
|
|
|
Repha = 15;
|
|
|
|
Ra = 16;
|
2012-11-13 03:41:22 +01:00
|
|
|
CM = 17;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2012-11-13 03:41:22 +01:00
|
|
|
c = (C | Ra)CM*; # is_consonant
|
2012-07-18 22:00:49 +02:00
|
|
|
n = ((ZWNJ?.RS)? (N.N?)?); # is_consonant_modifier
|
2012-07-17 23:53:03 +02:00
|
|
|
z = ZWJ|ZWNJ; # is_joiner
|
|
|
|
h = H | Coeng; # is_halant_or_coeng
|
2012-07-18 00:17:30 +02:00
|
|
|
reph = (Ra H | Repha); # possible reph
|
2012-07-18 20:23:55 +02:00
|
|
|
|
2012-09-05 23:21:17 +02:00
|
|
|
cn = c.ZWJ?.n?;
|
2012-07-19 05:25:58 +02:00
|
|
|
forced_rakar = ZWJ H ZWJ Ra;
|
2012-07-24 08:30:38 +02:00
|
|
|
matra_group = z{0,3}.M.N?.(H | forced_rakar)?;
|
2012-09-05 21:54:21 +02:00
|
|
|
syllable_tail = (Coeng (cn|V))? (SM.ZWNJ?)? (VD VD?)?;
|
2012-05-11 20:02:14 +02:00
|
|
|
place_holder = NBSP | DOTTEDCIRCLE;
|
2012-09-05 23:21:17 +02:00
|
|
|
halant_group = (z?.h.(ZWJ.N?)?);
|
2012-07-20 19:48:03 +02:00
|
|
|
final_halant_group = halant_group | h.ZWNJ;
|
2012-09-05 23:32:57 +02:00
|
|
|
halant_or_matra_group = (final_halant_group | (h.ZWJ)? matra_group{0,4});
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
|
2012-07-24 00:19:17 +02:00
|
|
|
consonant_syllable = Repha? (cn.halant_group){0,4} cn A? halant_or_matra_group? syllable_tail;
|
2012-07-24 06:09:12 +02:00
|
|
|
vowel_syllable = reph? V.n? (ZWJ | (halant_group.cn){0,4} halant_or_matra_group? syllable_tail);
|
2012-07-24 00:19:17 +02:00
|
|
|
standalone_cluster = reph? place_holder.n? (halant_group.cn){0,4} halant_or_matra_group? syllable_tail;
|
2012-12-22 01:41:04 +01:00
|
|
|
broken_cluster = reph? n? (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
|
2012-05-11 14:39:01 +02:00
|
|
|
other = any;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2012-05-11 14:39:01 +02:00
|
|
|
main := |*
|
2012-08-31 22:49:34 +02:00
|
|
|
consonant_syllable => { found_syllable (consonant_syllable); };
|
|
|
|
vowel_syllable => { found_syllable (vowel_syllable); };
|
|
|
|
standalone_cluster => { found_syllable (standalone_cluster); };
|
2012-09-07 20:55:07 +02:00
|
|
|
broken_cluster => { found_syllable (broken_cluster); };
|
2012-08-31 22:49:34 +02:00
|
|
|
other => { found_syllable (non_indic_cluster); };
|
2012-05-11 14:39:01 +02:00
|
|
|
*|;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
}%%
|
|
|
|
|
2012-08-31 22:49:34 +02:00
|
|
|
#define found_syllable(syllable_type) \
|
2012-05-11 14:39:01 +02:00
|
|
|
HB_STMT_START { \
|
2012-08-31 22:49:34 +02:00
|
|
|
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
|
2012-05-11 14:39:01 +02:00
|
|
|
for (unsigned int i = last; i < p+1; i++) \
|
2012-08-31 22:49:34 +02:00
|
|
|
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
|
2012-05-11 14:39:01 +02:00
|
|
|
last = p+1; \
|
|
|
|
syllable_serial++; \
|
2012-08-31 22:49:34 +02:00
|
|
|
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
|
2012-05-11 14:39:01 +02:00
|
|
|
} HB_STMT_END
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
static void
|
2012-09-07 20:55:07 +02:00
|
|
|
find_syllables (hb_buffer_t *buffer)
|
2011-06-18 00:35:46 +02:00
|
|
|
{
|
2012-12-06 00:46:04 +01:00
|
|
|
unsigned int p, pe, eof, ts HB_UNUSED, te, act;
|
2011-06-18 00:35:46 +02:00
|
|
|
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-08-31 22:49:34 +02:00
|
|
|
unsigned int syllable_serial = 1;
|
2011-06-18 00:35:46 +02:00
|
|
|
%%{
|
|
|
|
write exec;
|
|
|
|
}%%
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HB_OT_SHAPE_COMPLEX_INDIC_MACHINE_HH */
|