Line | Source Code | Coverage |
---|
1 | /* | - |
2 | * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies) | - |
3 | * | - |
4 | * This is part of HarfBuzz, an OpenType Layout engine 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 "harfbuzz-shaper.h" | - |
26 | #include "harfbuzz-shaper-private.h" | - |
27 | #include <assert.h> | - |
28 | | - |
29 | /* | - |
30 | // Uniscribe also defines dlig for Hebrew, but we leave this out for now, as it's mostly | - |
31 | // ligatures one does not want in modern Hebrew (as lam-alef ligatures). | - |
32 | */ | - |
33 | #ifndef NO_OPENTYPE | - |
34 | static const HB_OpenTypeFeature hebrew_features[] = { | - |
35 | { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty }, | - |
36 | {0, 0} | - |
37 | }; | - |
38 | #endif | - |
39 | | - |
40 | /* Hebrew shaping. In the non opentype case we try to use the | - |
41 | presentation forms specified for Hebrew. Especially for the | - |
42 | ligatures with Dagesh this gives much better results than we could | - |
43 | achieve manually. | - |
44 | */ | - |
45 | HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item) | - |
46 | { | - |
47 | enum { executed (the execution status of this line is deduced): enum { | - |
48 | Dagesh = 0x5bc, executed (the execution status of this line is deduced): Dagesh = 0x5bc, | - |
49 | ShinDot = 0x5c1, executed (the execution status of this line is deduced): ShinDot = 0x5c1, | - |
50 | SinDot = 0x5c2, executed (the execution status of this line is deduced): SinDot = 0x5c2, | - |
51 | Patah = 0x5b7, executed (the execution status of this line is deduced): Patah = 0x5b7, | - |
52 | Qamats = 0x5b8, executed (the execution status of this line is deduced): Qamats = 0x5b8, | - |
53 | Holam = 0x5b9, executed (the execution status of this line is deduced): Holam = 0x5b9, | - |
54 | Rafe = 0x5bf executed (the execution status of this line is deduced): Rafe = 0x5bf | - |
55 | }; executed (the execution status of this line is deduced): }; | - |
56 | | - |
57 | assert(shaper_item->item.script == HB_Script_Hebrew); executed (the execution status of this line is deduced): ((shaper_item->item.script == HB_Script_Hebrew) ? static_cast<void> (0) : __assert_fail ("shaper_item->item.script == HB_Script_Hebrew", "../3rdparty/harfbuzz/src/harfbuzz-hebrew.c", 57, __PRETTY_FUNCTION__)); | - |
58 | | - |
59 | #ifndef NO_OPENTYPE | - |
60 | if (HB_SelectScript(shaper_item, hebrew_features)) { partially evaluated: HB_SelectScript(shaper_item, hebrew_features) yes Evaluation Count:114 | no Evaluation Count:0 |
| 0-114 |
61 | | - |
62 | const int availableGlyphs = shaper_item->num_glyphs; executed (the execution status of this line is deduced): const int availableGlyphs = shaper_item->num_glyphs; | - |
63 | if (!HB_ConvertStringToGlyphIndices(shaper_item)) partially evaluated: !HB_ConvertStringToGlyphIndices(shaper_item) no Evaluation Count:0 | yes Evaluation Count:114 |
| 0-114 |
64 | return FALSE; never executed: return 0; | 0 |
65 | | - |
66 | HB_HeuristicSetGlyphAttributes(shaper_item); executed (the execution status of this line is deduced): HB_HeuristicSetGlyphAttributes(shaper_item); | - |
67 | HB_OpenTypeShape(shaper_item, /*properties*/0); executed (the execution status of this line is deduced): HB_OpenTypeShape(shaper_item, 0); | - |
68 | return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/TRUE); executed: return HB_OpenTypePosition(shaper_item, availableGlyphs, (!0)); Execution Count:114 | 114 |
69 | } | - |
70 | #endif | - |
71 | | - |
72 | { | - |
73 | const HB_UChar16 *uc = shaper_item->string + shaper_item->item.pos; never executed (the execution status of this line is deduced): const HB_UChar16 *uc = shaper_item->string + shaper_item->item.pos; | - |
74 | unsigned short *logClusters = shaper_item->log_clusters; never executed (the execution status of this line is deduced): unsigned short *logClusters = shaper_item->log_clusters; | - |
75 | HB_GlyphAttributes *attributes = shaper_item->attributes; never executed (the execution status of this line is deduced): HB_GlyphAttributes *attributes = shaper_item->attributes; | - |
76 | | - |
77 | HB_Bool haveGlyphs; never executed (the execution status of this line is deduced): HB_Bool haveGlyphs; | - |
78 | int slen = 1; never executed (the execution status of this line is deduced): int slen = 1; | - |
79 | int cluster_start = 0; never executed (the execution status of this line is deduced): int cluster_start = 0; | - |
80 | hb_uint32 i; never executed (the execution status of this line is deduced): hb_uint32 i; | - |
81 | | - |
82 | HB_STACKARRAY(HB_UChar16, shapedChars, 2 * shaper_item->item.length); never executed: shapedChars = (HB_UChar16 *)malloc((2 * shaper_item->item.length) * sizeof(HB_UChar16)); never evaluated: (2 * shaper_item->item.length) >= 512 | 0 |
83 | *shapedChars = *uc; never executed (the execution status of this line is deduced): *shapedChars = *uc; | - |
84 | logClusters[0] = 0; never executed (the execution status of this line is deduced): logClusters[0] = 0; | - |
85 | | - |
86 | for (i = 1; i < shaper_item->item.length; ++i) { never evaluated: i < shaper_item->item.length | 0 |
87 | hb_uint16 base = shapedChars[cluster_start]; never executed (the execution status of this line is deduced): hb_uint16 base = shapedChars[cluster_start]; | - |
88 | hb_uint16 shaped = 0; never executed (the execution status of this line is deduced): hb_uint16 shaped = 0; | - |
89 | HB_Bool invalid = FALSE; never executed (the execution status of this line is deduced): HB_Bool invalid = 0; | - |
90 | if (uc[i] == Dagesh) { never evaluated: uc[i] == Dagesh | 0 |
91 | if (base >= 0x5d0 never evaluated: base >= 0x5d0 | 0 |
92 | && base <= 0x5ea never evaluated: base <= 0x5ea | 0 |
93 | && base != 0x5d7 never evaluated: base != 0x5d7 | 0 |
94 | && base != 0x5dd never evaluated: base != 0x5dd | 0 |
95 | && base != 0x5df never evaluated: base != 0x5df | 0 |
96 | && base != 0x5e2 never evaluated: base != 0x5e2 | 0 |
97 | && base != 0x5e5) { never evaluated: base != 0x5e5 | 0 |
98 | shaped = base - 0x5d0 + 0xfb30; never executed (the execution status of this line is deduced): shaped = base - 0x5d0 + 0xfb30; | - |
99 | } else if (base == 0xfb2a || base == 0xfb2b /* Shin with Shin or Sin dot */) { never executed: } never evaluated: base == 0xfb2a never evaluated: base == 0xfb2b | 0 |
100 | shaped = base + 2; never executed (the execution status of this line is deduced): shaped = base + 2; | - |
101 | } else { | 0 |
102 | invalid = TRUE; never executed (the execution status of this line is deduced): invalid = (!0); | - |
103 | } | 0 |
104 | } else if (uc[i] == ShinDot) { never evaluated: uc[i] == ShinDot | 0 |
105 | if (base == 0x05e9) never evaluated: base == 0x05e9 | 0 |
106 | shaped = 0xfb2a; never executed: shaped = 0xfb2a; | 0 |
107 | else if (base == 0xfb49) never evaluated: base == 0xfb49 | 0 |
108 | shaped = 0xfb2c; never executed: shaped = 0xfb2c; | 0 |
109 | else | - |
110 | invalid = TRUE; never executed: invalid = (!0); | 0 |
111 | } else if (uc[i] == SinDot) { never evaluated: uc[i] == SinDot | 0 |
112 | if (base == 0x05e9) never evaluated: base == 0x05e9 | 0 |
113 | shaped = 0xfb2b; never executed: shaped = 0xfb2b; | 0 |
114 | else if (base == 0xfb49) never evaluated: base == 0xfb49 | 0 |
115 | shaped = 0xfb2d; never executed: shaped = 0xfb2d; | 0 |
116 | else | - |
117 | invalid = TRUE; never executed: invalid = (!0); | 0 |
118 | } else if (uc[i] == Patah) { never evaluated: uc[i] == Patah | 0 |
119 | if (base == 0x5d0) never evaluated: base == 0x5d0 | 0 |
120 | shaped = 0xfb2e; never executed: shaped = 0xfb2e; | 0 |
121 | } else if (uc[i] == Qamats) { never executed: } never evaluated: uc[i] == Qamats | 0 |
122 | if (base == 0x5d0) never evaluated: base == 0x5d0 | 0 |
123 | shaped = 0xfb2f; never executed: shaped = 0xfb2f; | 0 |
124 | } else if (uc[i] == Holam) { never executed: } never evaluated: uc[i] == Holam | 0 |
125 | if (base == 0x5d5) never evaluated: base == 0x5d5 | 0 |
126 | shaped = 0xfb4b; never executed: shaped = 0xfb4b; | 0 |
127 | } else if (uc[i] == Rafe) { never executed: } never evaluated: uc[i] == Rafe | 0 |
128 | if (base == 0x5d1) never evaluated: base == 0x5d1 | 0 |
129 | shaped = 0xfb4c; never executed: shaped = 0xfb4c; | 0 |
130 | else if (base == 0x5db) never evaluated: base == 0x5db | 0 |
131 | shaped = 0xfb4d; never executed: shaped = 0xfb4d; | 0 |
132 | else if (base == 0x5e4) never evaluated: base == 0x5e4 | 0 |
133 | shaped = 0xfb4e; never executed: shaped = 0xfb4e; | 0 |
134 | } | - |
135 | | - |
136 | if (invalid) { | 0 |
137 | shapedChars[slen] = 0x25cc; never executed (the execution status of this line is deduced): shapedChars[slen] = 0x25cc; | - |
138 | attributes[slen].clusterStart = TRUE; never executed (the execution status of this line is deduced): attributes[slen].clusterStart = (!0); | - |
139 | attributes[slen].mark = FALSE; never executed (the execution status of this line is deduced): attributes[slen].mark = 0; | - |
140 | attributes[slen].combiningClass = 0; never executed (the execution status of this line is deduced): attributes[slen].combiningClass = 0; | - |
141 | cluster_start = slen; never executed (the execution status of this line is deduced): cluster_start = slen; | - |
142 | ++slen; never executed (the execution status of this line is deduced): ++slen; | - |
143 | } | 0 |
144 | if (shaped) { | 0 |
145 | if (shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1)) { never evaluated: shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1) | 0 |
146 | shapedChars[cluster_start] = shaped; never executed (the execution status of this line is deduced): shapedChars[cluster_start] = shaped; | - |
147 | } else | 0 |
148 | shaped = 0; never executed: shaped = 0; | 0 |
149 | } | - |
150 | if (!shaped) { | 0 |
151 | HB_CharCategory category; never executed (the execution status of this line is deduced): HB_CharCategory category; | - |
152 | int cmb; never executed (the execution status of this line is deduced): int cmb; | - |
153 | shapedChars[slen] = uc[i]; never executed (the execution status of this line is deduced): shapedChars[slen] = uc[i]; | - |
154 | HB_GetUnicodeCharProperties(uc[i], &category, &cmb); never executed (the execution status of this line is deduced): HB_GetUnicodeCharProperties(uc[i], &category, &cmb); | - |
155 | if (category != HB_Mark_NonSpacing) { never evaluated: category != HB_Mark_NonSpacing | 0 |
156 | attributes[slen].clusterStart = TRUE; never executed (the execution status of this line is deduced): attributes[slen].clusterStart = (!0); | - |
157 | attributes[slen].mark = FALSE; never executed (the execution status of this line is deduced): attributes[slen].mark = 0; | - |
158 | attributes[slen].combiningClass = 0; never executed (the execution status of this line is deduced): attributes[slen].combiningClass = 0; | - |
159 | attributes[slen].dontPrint = HB_IsControlChar(uc[i]); never evaluated: uc[i] >= 0x200b never evaluated: uc[i] <= 0x200f never evaluated: uc[i] >= 0x2028 never evaluated: uc[i] <= 0x202f never evaluated: uc[i] >= 0x206a never evaluated: uc[i] <= 0x206f | 0 |
160 | cluster_start = slen; never executed (the execution status of this line is deduced): cluster_start = slen; | - |
161 | } else { | 0 |
162 | attributes[slen].clusterStart = FALSE; never executed (the execution status of this line is deduced): attributes[slen].clusterStart = 0; | - |
163 | attributes[slen].mark = TRUE; never executed (the execution status of this line is deduced): attributes[slen].mark = (!0); | - |
164 | attributes[slen].combiningClass = cmb; never executed (the execution status of this line is deduced): attributes[slen].combiningClass = cmb; | - |
165 | } | 0 |
166 | ++slen; never executed (the execution status of this line is deduced): ++slen; | - |
167 | } | 0 |
168 | logClusters[i] = cluster_start; never executed (the execution status of this line is deduced): logClusters[i] = cluster_start; | - |
169 | } | 0 |
170 | | - |
171 | haveGlyphs = shaper_item->font->klass never executed (the execution status of this line is deduced): haveGlyphs = shaper_item->font->klass | - |
172 | ->convertStringToGlyphIndices(shaper_item->font, never executed (the execution status of this line is deduced): ->convertStringToGlyphIndices(shaper_item->font, | - |
173 | shapedChars, slen, never executed (the execution status of this line is deduced): shapedChars, slen, | - |
174 | shaper_item->glyphs, &shaper_item->num_glyphs, never executed (the execution status of this line is deduced): shaper_item->glyphs, &shaper_item->num_glyphs, | - |
175 | shaper_item->item.bidiLevel % 2); never executed (the execution status of this line is deduced): shaper_item->item.bidiLevel % 2); | - |
176 | | - |
177 | HB_FREE_STACKARRAY(shapedChars); never executed: free(shapedChars); never evaluated: stackshapedChars != shapedChars | 0 |
178 | | - |
179 | if (!haveGlyphs) never evaluated: !haveGlyphs | 0 |
180 | return FALSE; never executed: return 0; | 0 |
181 | | - |
182 | HB_HeuristicPosition(shaper_item); never executed (the execution status of this line is deduced): HB_HeuristicPosition(shaper_item); | - |
183 | } | - |
184 | | - |
185 | return TRUE; never executed: return (!0); | 0 |
186 | } | - |
187 | | - |
188 | | - |
| | |