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
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb.hh"
|
2011-06-18 00:35:46 +02:00
|
|
|
|
|
|
|
%%{
|
|
|
|
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
|
|
|
C = 1;
|
2012-07-18 00:17:30 +02:00
|
|
|
V = 2;
|
|
|
|
N = 3;
|
|
|
|
H = 4;
|
|
|
|
ZWNJ = 5;
|
|
|
|
ZWJ = 6;
|
|
|
|
M = 7;
|
|
|
|
SM = 8;
|
|
|
|
A = 10;
|
2014-05-27 23:53:37 +02:00
|
|
|
PLACEHOLDER = 11;
|
2012-07-18 00:17:30 +02:00
|
|
|
DOTTEDCIRCLE = 12;
|
2013-10-18 02:27:00 +02:00
|
|
|
RS = 13;
|
2012-07-18 00:17:30 +02:00
|
|
|
Repha = 15;
|
|
|
|
Ra = 16;
|
2014-05-23 21:33:13 +02:00
|
|
|
Symbol= 18;
|
2017-10-03 15:20:07 +02:00
|
|
|
CS = 19;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2013-10-16 19:06:29 +02:00
|
|
|
c = (C | Ra); # 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
|
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;
|
2014-05-23 21:33:13 +02:00
|
|
|
symbol = Symbol.N?;
|
2012-07-24 08:30:38 +02:00
|
|
|
matra_group = z{0,3}.M.N?.(H | forced_rakar)?;
|
2018-01-05 18:27:48 +01:00
|
|
|
syllable_tail = (z?.SM.SM?.ZWNJ?)? A{0,3}?;
|
2018-01-05 16:33:11 +01:00
|
|
|
halant_group = (z?.H.(ZWJ.N?)?);
|
|
|
|
final_halant_group = halant_group | H.ZWNJ;
|
2018-09-10 17:38:19 +02:00
|
|
|
halant_or_matra_group = (final_halant_group | matra_group{0,4});
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2018-10-02 17:49:06 +02:00
|
|
|
complex_syllable_tail = (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
|
2011-06-18 00:35:46 +02:00
|
|
|
|
2018-10-02 17:49:06 +02:00
|
|
|
|
|
|
|
consonant_syllable = (Repha|CS)? cn complex_syllable_tail;
|
|
|
|
vowel_syllable = reph? V.n? (ZWJ | complex_syllable_tail);
|
|
|
|
standalone_cluster = ((Repha|CS)? PLACEHOLDER | reph? DOTTEDCIRCLE).n? complex_syllable_tail;
|
2014-05-23 21:39:55 +02:00
|
|
|
symbol_cluster = symbol syllable_tail;
|
2018-10-02 17:49:06 +02:00
|
|
|
broken_cluster = reph? n? complex_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); };
|
2014-05-23 21:33:13 +02:00
|
|
|
symbol_cluster => { found_syllable (symbol_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 { \
|
2018-10-02 17:04:05 +02:00
|
|
|
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
|
|
|
|
for (unsigned int i = ts; i < te; 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
|
|
|
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
|
|
|
{
|
2018-10-02 17:04:05 +02:00
|
|
|
unsigned int p, pe, eof, ts, 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
|
|
|
|
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 */
|