diff options
Diffstat (limited to 'src/ftfont.c')
| -rw-r--r-- | src/ftfont.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/ftfont.c b/src/ftfont.c index db6b29421dc..ad01149106e 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -168,11 +168,11 @@ get_adstyle_property (FcPattern *p) | |||
| 168 | for (end = str; *end && *end != ' '; end++); | 168 | for (end = str; *end && *end != ' '; end++); |
| 169 | if (*end) | 169 | if (*end) |
| 170 | { | 170 | { |
| 171 | char *p = alloca (end - str + 1); | 171 | char *newstr = alloca (end - str + 1); |
| 172 | memcpy (p, str, end - str); | 172 | memcpy (newstr, str, end - str); |
| 173 | p[end - str] = '\0'; | 173 | newstr[end - str] = '\0'; |
| 174 | end = p + (end - str); | 174 | end = newstr + (end - str); |
| 175 | str = p; | 175 | str = newstr; |
| 176 | } | 176 | } |
| 177 | if (xstrcasecmp (str, "Regular") == 0 | 177 | if (xstrcasecmp (str, "Regular") == 0 |
| 178 | || xstrcasecmp (str, "Bold") == 0 | 178 | || xstrcasecmp (str, "Bold") == 0 |
| @@ -190,18 +190,18 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) | |||
| 190 | { | 190 | { |
| 191 | Lisp_Object key, cache, entity; | 191 | Lisp_Object key, cache, entity; |
| 192 | char *file, *str; | 192 | char *file, *str; |
| 193 | int index; | 193 | int idx; |
| 194 | int numeric; | 194 | int numeric; |
| 195 | double dbl; | 195 | double dbl; |
| 196 | FcBool b; | 196 | FcBool b; |
| 197 | 197 | ||
| 198 | if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) | 198 | if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) |
| 199 | return Qnil; | 199 | return Qnil; |
| 200 | if (FcPatternGetInteger (p, FC_INDEX, 0, &index) != FcResultMatch) | 200 | if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) |
| 201 | return Qnil; | 201 | return Qnil; |
| 202 | 202 | ||
| 203 | key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), | 203 | key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), |
| 204 | make_number (index)); | 204 | make_number (idx)); |
| 205 | cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); | 205 | cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); |
| 206 | entity = XCAR (cache); | 206 | entity = XCAR (cache); |
| 207 | if (! NILP (entity)) | 207 | if (! NILP (entity)) |
| @@ -265,7 +265,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) | |||
| 265 | 265 | ||
| 266 | ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p)); | 266 | ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p)); |
| 267 | if ((ft_library || FT_Init_FreeType (&ft_library) == 0) | 267 | if ((ft_library || FT_Init_FreeType (&ft_library) == 0) |
| 268 | && FT_New_Face (ft_library, file, index, &ft_face) == 0) | 268 | && FT_New_Face (ft_library, file, idx, &ft_face) == 0) |
| 269 | { | 269 | { |
| 270 | BDF_PropertyRec rec; | 270 | BDF_PropertyRec rec; |
| 271 | 271 | ||
| @@ -311,8 +311,9 @@ ftfont_resolve_generic_family (Lisp_Object family, FcPattern *pattern) | |||
| 311 | if (FcPatternGetLangSet (pattern, FC_LANG, 0, &langset) != FcResultMatch) | 311 | if (FcPatternGetLangSet (pattern, FC_LANG, 0, &langset) != FcResultMatch) |
| 312 | { | 312 | { |
| 313 | /* This is to avoid the effect of locale. */ | 313 | /* This is to avoid the effect of locale. */ |
| 314 | static const FcChar8 lang[] = "en"; | ||
| 314 | langset = FcLangSetCreate (); | 315 | langset = FcLangSetCreate (); |
| 315 | FcLangSetAdd (langset, "en"); | 316 | FcLangSetAdd (langset, lang); |
| 316 | FcPatternAddLangSet (pattern, FC_LANG, langset); | 317 | FcPatternAddLangSet (pattern, FC_LANG, langset); |
| 317 | FcLangSetDestroy (langset); | 318 | FcLangSetDestroy (langset); |
| 318 | } | 319 | } |
| @@ -393,14 +394,14 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) | |||
| 393 | ? ! cache_data->ft_face : ! cache_data->fc_charset) | 394 | ? ! cache_data->ft_face : ! cache_data->fc_charset) |
| 394 | { | 395 | { |
| 395 | char *filename = SSDATA (XCAR (key)); | 396 | char *filename = SSDATA (XCAR (key)); |
| 396 | int index = XINT (XCDR (key)); | 397 | int idx = XINT (XCDR (key)); |
| 397 | 398 | ||
| 398 | if (cache_for == FTFONT_CACHE_FOR_FACE) | 399 | if (cache_for == FTFONT_CACHE_FOR_FACE) |
| 399 | { | 400 | { |
| 400 | if (! ft_library | 401 | if (! ft_library |
| 401 | && FT_Init_FreeType (&ft_library) != 0) | 402 | && FT_Init_FreeType (&ft_library) != 0) |
| 402 | return Qnil; | 403 | return Qnil; |
| 403 | if (FT_New_Face (ft_library, filename, index, &cache_data->ft_face) | 404 | if (FT_New_Face (ft_library, filename, idx, &cache_data->ft_face) |
| 404 | != 0) | 405 | != 0) |
| 405 | return Qnil; | 406 | return Qnil; |
| 406 | } | 407 | } |
| @@ -412,7 +413,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) | |||
| 412 | FcCharSet *charset = NULL; | 413 | FcCharSet *charset = NULL; |
| 413 | 414 | ||
| 414 | pat = FcPatternBuild (0, FC_FILE, FcTypeString, (FcChar8 *) filename, | 415 | pat = FcPatternBuild (0, FC_FILE, FcTypeString, (FcChar8 *) filename, |
| 415 | FC_INDEX, FcTypeInteger, index, NULL); | 416 | FC_INDEX, FcTypeInteger, idx, NULL); |
| 416 | if (! pat) | 417 | if (! pat) |
| 417 | goto finish; | 418 | goto finish; |
| 418 | objset = FcObjectSetBuild (FC_CHARSET, FC_STYLE, NULL); | 419 | objset = FcObjectSetBuild (FC_CHARSET, FC_STYLE, NULL); |
| @@ -490,8 +491,12 @@ static int ftfont_get_bitmap (struct font *, unsigned, | |||
| 490 | struct font_bitmap *, int); | 491 | struct font_bitmap *, int); |
| 491 | static int ftfont_anchor_point (struct font *, unsigned, int, | 492 | static int ftfont_anchor_point (struct font *, unsigned, int, |
| 492 | int *, int *); | 493 | int *, int *); |
| 494 | #ifdef HAVE_LIBOTF | ||
| 493 | static Lisp_Object ftfont_otf_capability (struct font *); | 495 | static Lisp_Object ftfont_otf_capability (struct font *); |
| 496 | # ifdef HAVE_M17N_FLT | ||
| 494 | static Lisp_Object ftfont_shape (Lisp_Object); | 497 | static Lisp_Object ftfont_shape (Lisp_Object); |
| 498 | # endif | ||
| 499 | #endif | ||
| 495 | 500 | ||
| 496 | #ifdef HAVE_OTF_GET_VARIATION_GLYPHS | 501 | #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
| 497 | static int ftfont_variation_glyphs (struct font *, int c, | 502 | static int ftfont_variation_glyphs (struct font *, int c, |
| @@ -618,6 +623,7 @@ struct OpenTypeSpec | |||
| 618 | (P)[4] = '\0'; \ | 623 | (P)[4] = '\0'; \ |
| 619 | } while (0) | 624 | } while (0) |
| 620 | 625 | ||
| 626 | #ifdef HAVE_LIBOTF | ||
| 621 | #define OTF_TAG_SYM(SYM, TAG) \ | 627 | #define OTF_TAG_SYM(SYM, TAG) \ |
| 622 | do { \ | 628 | do { \ |
| 623 | char str[5]; \ | 629 | char str[5]; \ |
| @@ -625,6 +631,7 @@ struct OpenTypeSpec | |||
| 625 | OTF_TAG_STR (TAG, str); \ | 631 | OTF_TAG_STR (TAG, str); \ |
| 626 | (SYM) = font_intern_prop (str, 4, 1); \ | 632 | (SYM) = font_intern_prop (str, 4, 1); \ |
| 627 | } while (0) | 633 | } while (0) |
| 634 | #endif | ||
| 628 | 635 | ||
| 629 | 636 | ||
| 630 | static struct OpenTypeSpec * | 637 | static struct OpenTypeSpec * |
| @@ -864,7 +871,6 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |||
| 864 | FcObjectSet *objset = NULL; | 871 | FcObjectSet *objset = NULL; |
| 865 | FcCharSet *charset; | 872 | FcCharSet *charset; |
| 866 | Lisp_Object chars = Qnil; | 873 | Lisp_Object chars = Qnil; |
| 867 | FcResult result; | ||
| 868 | char otlayout[15]; /* For "otlayout:XXXX" */ | 874 | char otlayout[15]; /* For "otlayout:XXXX" */ |
| 869 | struct OpenTypeSpec *otspec = NULL; | 875 | struct OpenTypeSpec *otspec = NULL; |
| 870 | int spacing = -1; | 876 | int spacing = -1; |
| @@ -1153,7 +1159,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 1153 | FT_Face ft_face; | 1159 | FT_Face ft_face; |
| 1154 | FT_Size ft_size; | 1160 | FT_Size ft_size; |
| 1155 | FT_UInt size; | 1161 | FT_UInt size; |
| 1156 | Lisp_Object val, filename, index, cache, font_object; | 1162 | Lisp_Object val, filename, idx, cache, font_object; |
| 1157 | int scalable; | 1163 | int scalable; |
| 1158 | int spacing; | 1164 | int spacing; |
| 1159 | char name[256]; | 1165 | char name[256]; |
| @@ -1168,7 +1174,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 1168 | if (NILP (cache)) | 1174 | if (NILP (cache)) |
| 1169 | return Qnil; | 1175 | return Qnil; |
| 1170 | filename = XCAR (val); | 1176 | filename = XCAR (val); |
| 1171 | index = XCDR (val); | 1177 | idx = XCDR (val); |
| 1172 | val = XCDR (cache); | 1178 | val = XCDR (cache); |
| 1173 | cache_data = XSAVE_VALUE (XCDR (cache))->pointer; | 1179 | cache_data = XSAVE_VALUE (XCDR (cache))->pointer; |
| 1174 | ft_face = cache_data->ft_face; | 1180 | ft_face = cache_data->ft_face; |
| @@ -1210,7 +1216,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) | |||
| 1210 | font = XFONT_OBJECT (font_object); | 1216 | font = XFONT_OBJECT (font_object); |
| 1211 | ftfont_info = (struct ftfont_info *) font; | 1217 | ftfont_info = (struct ftfont_info *) font; |
| 1212 | ftfont_info->ft_size = ft_face->size; | 1218 | ftfont_info->ft_size = ft_face->size; |
| 1213 | ftfont_info->index = XINT (index); | 1219 | ftfont_info->index = XINT (idx); |
| 1214 | #ifdef HAVE_LIBOTF | 1220 | #ifdef HAVE_LIBOTF |
| 1215 | ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; | 1221 | ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; |
| 1216 | ftfont_info->otf = NULL; | 1222 | ftfont_info->otf = NULL; |
| @@ -1455,7 +1461,8 @@ ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bit | |||
| 1455 | } | 1461 | } |
| 1456 | 1462 | ||
| 1457 | static int | 1463 | static int |
| 1458 | ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, int *y) | 1464 | ftfont_anchor_point (struct font *font, unsigned int code, int idx, |
| 1465 | int *x, int *y) | ||
| 1459 | { | 1466 | { |
| 1460 | struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | 1467 | struct ftfont_info *ftfont_info = (struct ftfont_info *) font; |
| 1461 | FT_Face ft_face = ftfont_info->ft_size->face; | 1468 | FT_Face ft_face = ftfont_info->ft_size->face; |
| @@ -1466,10 +1473,10 @@ ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, in | |||
| 1466 | return -1; | 1473 | return -1; |
| 1467 | if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) | 1474 | if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) |
| 1468 | return -1; | 1475 | return -1; |
| 1469 | if (index >= ft_face->glyph->outline.n_points) | 1476 | if (idx >= ft_face->glyph->outline.n_points) |
| 1470 | return -1; | 1477 | return -1; |
| 1471 | *x = ft_face->glyph->outline.points[index].x; | 1478 | *x = ft_face->glyph->outline.points[idx].x; |
| 1472 | *y = ft_face->glyph->outline.points[index].y; | 1479 | *y = ft_face->glyph->outline.points[idx].y; |
| 1473 | return 0; | 1480 | return 0; |
| 1474 | } | 1481 | } |
| 1475 | 1482 | ||