QtBase  v6.3.1
hb-ot-shape-complex-syllabic.cc
Go to the documentation of this file.
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 
30 
31 
32 void
35  unsigned int broken_syllable_type,
36  unsigned int dottedcircle_category,
37  int repha_category,
38  int dottedcircle_position)
39 {
41  return;
42 
43  /* Note: This loop is extra overhead, but should not be measurable.
44  * TODO Use a buffer scratch flag to remove the loop. */
45  bool has_broken_syllables = false;
46  unsigned int count = buffer->len;
47  hb_glyph_info_t *info = buffer->info;
48  for (unsigned int i = 0; i < count; i++)
49  if ((info[i].syllable() & 0x0F) == broken_syllable_type)
50  {
51  has_broken_syllables = true;
52  break;
53  }
54  if (likely (!has_broken_syllables))
55  return;
56 
57 
58  hb_codepoint_t dottedcircle_glyph;
59  if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph))
60  return;
61 
62  hb_glyph_info_t dottedcircle = {0};
63  dottedcircle.codepoint = 0x25CCu;
64  dottedcircle.complex_var_u8_category() = dottedcircle_category;
65  if (dottedcircle_position != -1)
66  dottedcircle.complex_var_u8_auxiliary() = dottedcircle_position;
67  dottedcircle.codepoint = dottedcircle_glyph;
68 
69  buffer->clear_output ();
70 
71  buffer->idx = 0;
72  unsigned int last_syllable = 0;
73  while (buffer->idx < buffer->len && buffer->successful)
74  {
75  unsigned int syllable = buffer->cur().syllable();
76  if (unlikely (last_syllable != syllable && (syllable & 0x0F) == broken_syllable_type))
77  {
78  last_syllable = syllable;
79 
80  hb_glyph_info_t ginfo = dottedcircle;
81  ginfo.cluster = buffer->cur().cluster;
82  ginfo.mask = buffer->cur().mask;
83  ginfo.syllable() = buffer->cur().syllable();
84 
85  /* Insert dottedcircle after possible Repha. */
86  if (repha_category != -1)
87  {
88  while (buffer->idx < buffer->len && buffer->successful &&
89  last_syllable == buffer->cur().syllable() &&
90  buffer->cur().complex_var_u8_category() == (unsigned) repha_category)
91  (void) buffer->next_glyph ();
92  }
93 
94  (void) buffer->output_info (ginfo);
95  }
96  else
97  (void) buffer->next_glyph ();
98  }
99  buffer->sync ();
100 }
101 
102 
103 #endif
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
#define syllable()
void hb_syllabic_insert_dotted_circles(hb_font_t *font, hb_buffer_t *buffer, unsigned int broken_syllable_type, unsigned int dottedcircle_category, int repha_category, int dottedcircle_position)
#define likely(expr)
Definition: hb.hh:250
#define unlikely(expr)
Definition: hb.hh:251
backing_store_ptr info
[4]
Definition: jmemsys.h:161
void
Definition: png.h:1080
GLenum GLenum GLsizei count
GLenum GLuint buffer
@ HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE
Definition: hb-buffer.h:387
uint32_t hb_codepoint_t
Definition: hb-common.h:106
hb_codepoint_t codepoint
Definition: hb-buffer.h:63
hb_mask_t mask
Definition: hb-buffer.h:65
uint32_t cluster
Definition: hb-buffer.h:67