47 |
tab = malloc(n * sizeof(unsigned short)); |
tab = malloc(n * sizeof(unsigned short)); |
48 |
if (!tab) |
if (!tab) |
49 |
return NULL; |
return NULL; |
50 |
for(i=0;i<n;i++) { |
for (i = 0; i < n; i++) { |
51 |
tab[i] = uni_get_be16(f); |
tab[i] = uni_get_be16(f); |
52 |
} |
} |
53 |
return tab; |
return tab; |
56 |
void load_ligatures(void) |
void load_ligatures(void) |
57 |
{ |
{ |
58 |
FILE *f; |
FILE *f; |
59 |
|
char filename[MAX_FILENAME_SIZE]; |
60 |
unsigned char buf[1024]; |
unsigned char buf[1024]; |
61 |
int long_count; |
int long_count; |
62 |
|
|
63 |
if (find_resource_file(buf, sizeof(buf), "ligatures") < 0) |
if (find_resource_file(filename, sizeof(filename), "ligatures") < 0) |
64 |
return; |
return; |
65 |
|
|
66 |
f = fopen(buf, "r"); |
f = fopen(filename, "r"); |
67 |
if (!f) |
if (!f) |
68 |
return; |
return; |
69 |
if (fread(buf, 1, 4, f) != 4 || |
if (fread(buf, 1, 4, f) != 4 || |
129 |
memcpy(buf, buf_out, len * sizeof(int)); |
memcpy(buf, buf_out, len * sizeof(int)); |
130 |
|
|
131 |
q = buf_out; |
q = buf_out; |
132 |
for(i=0;i<len;) { |
for (i = 0; i < len;) { |
133 |
l1 = buf[i]; |
l1 = buf[i]; |
134 |
/* eliminate invisible chars */ |
/* eliminate invisible chars */ |
135 |
if (l1 >= 0x202a && l1 <= 0x202e) { |
if (l1 >= 0x202a && l1 <= 0x202e) { |
156 |
} else { |
} else { |
157 |
/* generic case : use ligature_long[] table */ |
/* generic case : use ligature_long[] table */ |
158 |
lig = ligature_long; |
lig = ligature_long; |
159 |
for(;;) { |
for (;;) { |
160 |
len1 = *lig++; |
len1 = *lig++; |
161 |
if (len1 == 0) |
if (len1 == 0) |
162 |
break; |
break; |
163 |
len2 = *lig++; |
len2 = *lig++; |
164 |
if (i + len1 <= len) { |
if (i + len1 <= len) { |
165 |
for(j=0;j<len1;j++) { |
for (j = 0; j < len1; j++) { |
166 |
if (buf[i+j] != lig[j]) |
if (buf[i+j] != lig[j]) |
167 |
goto notfound; |
goto notfound; |
168 |
} |
} |
169 |
for(j=0;j<len1;j++) |
for (j = 0; j < len1; j++) |
170 |
pos_L_to_V[i + j] = q - buf_out; |
pos_L_to_V[i + j] = q - buf_out; |
171 |
for(j=0;j<len2;j++) { |
for (j = 0; j < len2; j++) { |
172 |
*q++ = lig[len1 + j]; |
*q++ = lig[len1 + j]; |
173 |
} |
} |
174 |
i += len1; |
i += len1; |
199 |
int i, mask, c; |
int i, mask, c; |
200 |
|
|
201 |
mask = 0; |
mask = 0; |
202 |
for(i=0;i<len;i++) { |
for (i = 0; i < len; i++) { |
203 |
c = buf[i]; |
c = buf[i]; |
204 |
if (c <= 0x7f) /* latin1 fast handling */ |
if (c <= 0x7f) /* latin1 fast handling */ |
205 |
continue; |
continue; |
217 |
static void compose_char_to_glyph(unsigned int *ctog, int len, unsigned *ctog1) |
static void compose_char_to_glyph(unsigned int *ctog, int len, unsigned *ctog1) |
218 |
{ |
{ |
219 |
int i; |
int i; |
220 |
for(i=0;i<len;i++) |
for (i = 0; i < len; i++) |
221 |
ctog[i] = ctog1[ctog[i]]; |
ctog[i] = ctog1[ctog[i]]; |
222 |
} |
} |
223 |
|
|
226 |
int i, len2 = len / 2; |
int i, len2 = len / 2; |
227 |
|
|
228 |
for (i = 0; i < len2; i++) { |
for (i = 0; i < len2; i++) { |
229 |
unsigned int tmp = str[i]; |
unsigned int tmp = str[i]; |
230 |
str[i] = fribidi_get_mirror_char(str[len - 1 - i]); |
str[i] = fribidi_get_mirror_char(str[len - 1 - i]); |
231 |
str[len - 1 - i] = fribidi_get_mirror_char(tmp); |
str[len - 1 - i] = fribidi_get_mirror_char(tmp); |
232 |
} |
} |
233 |
/* do not forget central char ! */ |
/* do not forget central char ! */ |
234 |
if (len & 1) { |
if (len & 1) { |
244 |
buffer. */ |
buffer. */ |
245 |
int unicode_to_glyphs(unsigned int *dst, unsigned int *char_to_glyph_pos, |
int unicode_to_glyphs(unsigned int *dst, unsigned int *char_to_glyph_pos, |
246 |
int dst_size, unsigned int *src, int src_size, |
int dst_size, unsigned int *src, int src_size, |
247 |
int reverse) |
int reverse) |
248 |
{ |
{ |
249 |
int len, i; |
int len, i; |
250 |
unsigned int ctog[src_size]; |
unsigned int ctog[src_size]; |
291 |
|
|
292 |
if (reverse) { |
if (reverse) { |
293 |
bidi_reverse_buf(buf, len); |
bidi_reverse_buf(buf, len); |
294 |
for(i=0;i<src_size;i++) { |
for (i = 0; i < src_size; i++) { |
295 |
ctog[i] = len - 1 - ctog[i]; |
ctog[i] = len - 1 - ctog[i]; |
296 |
} |
} |
297 |
} |
} |
326 |
len = dst_size; |
len = dst_size; |
327 |
memcpy(dst, src, len * sizeof(unsigned int)); |
memcpy(dst, src, len * sizeof(unsigned int)); |
328 |
if (char_to_glyph_pos) { |
if (char_to_glyph_pos) { |
329 |
for(i=0;i<len;i++) |
for (i = 0; i < len; i++) |
330 |
char_to_glyph_pos[i] = i; |
char_to_glyph_pos[i] = i; |
331 |
} |
} |
332 |
return len; |
return len; |