comparison mupdf-source/thirdparty/harfbuzz/src/hb-ot-shaper-syllabic.cc @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /*
2 * Copyright © 2021 Behdad Esfahbod.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
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.
11 *
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
16 * DAMAGE.
17 *
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.
23 */
24
25 #include "hb.hh"
26
27 #ifndef HB_NO_OT_SHAPE
28
29 #include "hb-ot-shaper-syllabic.hh"
30
31
32 bool
33 hb_syllabic_insert_dotted_circles (hb_font_t *font,
34 hb_buffer_t *buffer,
35 unsigned int broken_syllable_type,
36 unsigned int dottedcircle_category,
37 int repha_category,
38 int dottedcircle_position)
39 {
40 if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
41 return false;
42 if (likely (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE)))
43 return false;
44
45 hb_codepoint_t dottedcircle_glyph;
46 if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph))
47 return false;
48
49 hb_glyph_info_t dottedcircle = {0};
50 dottedcircle.codepoint = 0x25CCu;
51 dottedcircle.ot_shaper_var_u8_category() = dottedcircle_category;
52 if (dottedcircle_position != -1)
53 dottedcircle.ot_shaper_var_u8_auxiliary() = dottedcircle_position;
54 dottedcircle.codepoint = dottedcircle_glyph;
55
56 buffer->clear_output ();
57
58 buffer->idx = 0;
59 unsigned int last_syllable = 0;
60 while (buffer->idx < buffer->len && buffer->successful)
61 {
62 unsigned int syllable = buffer->cur().syllable();
63 if (unlikely (last_syllable != syllable && (syllable & 0x0F) == broken_syllable_type))
64 {
65 last_syllable = syllable;
66
67 hb_glyph_info_t ginfo = dottedcircle;
68 ginfo.cluster = buffer->cur().cluster;
69 ginfo.mask = buffer->cur().mask;
70 ginfo.syllable() = buffer->cur().syllable();
71
72 /* Insert dottedcircle after possible Repha. */
73 if (repha_category != -1)
74 {
75 while (buffer->idx < buffer->len && buffer->successful &&
76 last_syllable == buffer->cur().syllable() &&
77 buffer->cur().ot_shaper_var_u8_category() == (unsigned) repha_category)
78 (void) buffer->next_glyph ();
79 }
80
81 (void) buffer->output_info (ginfo);
82 }
83 else
84 (void) buffer->next_glyph ();
85 }
86 buffer->sync ();
87 return true;
88 }
89
90 HB_INTERNAL bool
91 hb_syllabic_clear_var (const hb_ot_shape_plan_t *plan,
92 hb_font_t *font,
93 hb_buffer_t *buffer)
94 {
95 HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
96 return false;
97 }
98
99
100 #endif