2 * Copyright © 2021 Behdad Esfahbod.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
27 #ifndef HB_NO_OT_SHAPE
29 #include "hb-ot-shaper-syllabic.hh"
33 hb_syllabic_insert_dotted_circles (hb_font_t
*font
,
35 unsigned int broken_syllable_type
,
36 unsigned int dottedcircle_category
,
38 int dottedcircle_position
)
40 if (unlikely (buffer
->flags
& HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE
))
42 if (likely (!(buffer
->scratch_flags
& HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE
)))
44 if (buffer
->messaging ())
45 (void) buffer
->message (font
, "skipped inserting dotted-circles because there is no broken syllables");
49 if (buffer
->messaging () &&
50 !buffer
->message (font
, "start inserting dotted-circles"))
53 hb_codepoint_t dottedcircle_glyph
;
54 if (!font
->get_nominal_glyph (0x25CCu
, &dottedcircle_glyph
))
57 hb_glyph_info_t dottedcircle
= {0};
58 dottedcircle
.codepoint
= 0x25CCu
;
59 dottedcircle
.ot_shaper_var_u8_category() = dottedcircle_category
;
60 if (dottedcircle_position
!= -1)
61 dottedcircle
.ot_shaper_var_u8_auxiliary() = dottedcircle_position
;
62 dottedcircle
.codepoint
= dottedcircle_glyph
;
64 buffer
->clear_output ();
67 unsigned int last_syllable
= 0;
68 while (buffer
->idx
< buffer
->len
&& buffer
->successful
)
70 unsigned int syllable
= buffer
->cur().syllable();
71 if (unlikely (last_syllable
!= syllable
&& (syllable
& 0x0F) == broken_syllable_type
))
73 last_syllable
= syllable
;
75 hb_glyph_info_t ginfo
= dottedcircle
;
76 ginfo
.cluster
= buffer
->cur().cluster
;
77 ginfo
.mask
= buffer
->cur().mask
;
78 ginfo
.syllable() = buffer
->cur().syllable();
80 /* Insert dottedcircle after possible Repha. */
81 if (repha_category
!= -1)
83 while (buffer
->idx
< buffer
->len
&& buffer
->successful
&&
84 last_syllable
== buffer
->cur().syllable() &&
85 buffer
->cur().ot_shaper_var_u8_category() == (unsigned) repha_category
)
86 (void) buffer
->next_glyph ();
89 (void) buffer
->output_info (ginfo
);
92 (void) buffer
->next_glyph ();
96 if (buffer
->messaging ())
97 (void) buffer
->message (font
, "end inserting dotted-circles");
103 hb_syllabic_clear_var (const hb_ot_shape_plan_t
*plan
,
107 HB_BUFFER_DEALLOCATE_VAR (buffer
, syllable
);