diff options
| author | Daniel Colascione | 2012-09-17 04:07:36 -0800 |
|---|---|---|
| committer | Daniel Colascione | 2012-09-17 04:07:36 -0800 |
| commit | 2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch) | |
| tree | 6dd6784d63e54cb18071df8e28fbdbc27d418728 /src/font.c | |
| parent | f701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff) | |
| parent | bb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff) | |
| download | emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.zip | |
Merge from trunk
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/src/font.c b/src/font.c index c775b56caa9..629e8bb977a 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 23 | #include <config.h> | 23 | #include <config.h> |
| 24 | #include <float.h> | 24 | #include <float.h> |
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <setjmp.h> | ||
| 27 | 26 | ||
| 28 | #include <c-ctype.h> | 27 | #include <c-ctype.h> |
| 29 | 28 | ||
| @@ -216,13 +215,12 @@ static int num_font_drivers; | |||
| 216 | 215 | ||
| 217 | 216 | ||
| 218 | /* Return a Lispy value of a font property value at STR and LEN bytes. | 217 | /* Return a Lispy value of a font property value at STR and LEN bytes. |
| 219 | If STR is "*", return nil. | 218 | If STR is "*", return nil. If FORCE_SYMBOL, or if STR does not |
| 220 | If FORCE_SYMBOL is zero and all characters in STR are digits, | 219 | consist entirely of one or more digits, return a symbol interned |
| 221 | return an integer. Otherwise, return a symbol interned from | 220 | from STR. Otherwise, return an integer. */ |
| 222 | STR. */ | ||
| 223 | 221 | ||
| 224 | Lisp_Object | 222 | Lisp_Object |
| 225 | font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) | 223 | font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol) |
| 226 | { | 224 | { |
| 227 | ptrdiff_t i; | 225 | ptrdiff_t i; |
| 228 | Lisp_Object tem; | 226 | Lisp_Object tem; |
| @@ -306,7 +304,8 @@ font_pixel_size (FRAME_PTR f, Lisp_Object spec) | |||
| 306 | VAL is an integer. */ | 304 | VAL is an integer. */ |
| 307 | 305 | ||
| 308 | int | 306 | int |
| 309 | font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror) | 307 | font_style_to_value (enum font_property_index prop, Lisp_Object val, |
| 308 | bool noerror) | ||
| 310 | { | 309 | { |
| 311 | Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); | 310 | Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); |
| 312 | int len; | 311 | int len; |
| @@ -385,7 +384,8 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror | |||
| 385 | } | 384 | } |
| 386 | 385 | ||
| 387 | Lisp_Object | 386 | Lisp_Object |
| 388 | font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face) | 387 | font_style_symbolic (Lisp_Object font, enum font_property_index prop, |
| 388 | bool for_face) | ||
| 389 | { | 389 | { |
| 390 | Lisp_Object val = AREF (font, prop); | 390 | Lisp_Object val = AREF (font, prop); |
| 391 | Lisp_Object table, elt; | 391 | Lisp_Object table, elt; |
| @@ -1101,7 +1101,7 @@ font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font) | |||
| 1101 | } | 1101 | } |
| 1102 | else | 1102 | else |
| 1103 | { | 1103 | { |
| 1104 | int wild_card_found = 0; | 1104 | bool wild_card_found = 0; |
| 1105 | Lisp_Object prop[XLFD_LAST_INDEX]; | 1105 | Lisp_Object prop[XLFD_LAST_INDEX]; |
| 1106 | 1106 | ||
| 1107 | if (FONT_ENTITY_P (font)) | 1107 | if (FONT_ENTITY_P (font)) |
| @@ -1337,7 +1337,7 @@ font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font) | |||
| 1337 | } | 1337 | } |
| 1338 | else if (*p == '-') | 1338 | else if (*p == '-') |
| 1339 | { | 1339 | { |
| 1340 | int decimal = 0, size_found = 1; | 1340 | bool decimal = 0, size_found = 1; |
| 1341 | for (q = p + 1; *q && *q != ':'; q++) | 1341 | for (q = p + 1; *q && *q != ':'; q++) |
| 1342 | if (! c_isdigit (*q)) | 1342 | if (! c_isdigit (*q)) |
| 1343 | { | 1343 | { |
| @@ -1938,7 +1938,7 @@ generate_otf_features (Lisp_Object spec, char *features) | |||
| 1938 | { | 1938 | { |
| 1939 | Lisp_Object val; | 1939 | Lisp_Object val; |
| 1940 | char *p; | 1940 | char *p; |
| 1941 | int asterisk; | 1941 | bool asterisk; |
| 1942 | 1942 | ||
| 1943 | p = features; | 1943 | p = features; |
| 1944 | *p = '\0'; | 1944 | *p = '\0'; |
| @@ -2302,11 +2302,12 @@ font_update_sort_order (int *order) | |||
| 2302 | } | 2302 | } |
| 2303 | } | 2303 | } |
| 2304 | 2304 | ||
| 2305 | static int | 2305 | static bool |
| 2306 | font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table) | 2306 | font_check_otf_features (Lisp_Object script, Lisp_Object langsys, |
| 2307 | Lisp_Object features, Lisp_Object table) | ||
| 2307 | { | 2308 | { |
| 2308 | Lisp_Object val; | 2309 | Lisp_Object val; |
| 2309 | int negative; | 2310 | bool negative; |
| 2310 | 2311 | ||
| 2311 | table = assq_no_quit (script, table); | 2312 | table = assq_no_quit (script, table); |
| 2312 | if (NILP (table)) | 2313 | if (NILP (table)) |
| @@ -2342,7 +2343,7 @@ font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object fe | |||
| 2342 | 2343 | ||
| 2343 | /* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */ | 2344 | /* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */ |
| 2344 | 2345 | ||
| 2345 | static int | 2346 | static bool |
| 2346 | font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) | 2347 | font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) |
| 2347 | { | 2348 | { |
| 2348 | Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil; | 2349 | Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil; |
| @@ -2376,7 +2377,7 @@ font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) | |||
| 2376 | /* Check if FONT (font-entity or font-object) matches with the font | 2377 | /* Check if FONT (font-entity or font-object) matches with the font |
| 2377 | specification SPEC. */ | 2378 | specification SPEC. */ |
| 2378 | 2379 | ||
| 2379 | int | 2380 | bool |
| 2380 | font_match_p (Lisp_Object spec, Lisp_Object font) | 2381 | font_match_p (Lisp_Object spec, Lisp_Object font) |
| 2381 | { | 2382 | { |
| 2382 | Lisp_Object prop[FONT_SPEC_MAX], *props; | 2383 | Lisp_Object prop[FONT_SPEC_MAX], *props; |
| @@ -2694,7 +2695,7 @@ font_list_entities (Lisp_Object frame, Lisp_Object spec) | |||
| 2694 | Lisp_Object ftype, val; | 2695 | Lisp_Object ftype, val; |
| 2695 | Lisp_Object list = Qnil; | 2696 | Lisp_Object list = Qnil; |
| 2696 | int size; | 2697 | int size; |
| 2697 | int need_filtering = 0; | 2698 | bool need_filtering = 0; |
| 2698 | int i; | 2699 | int i; |
| 2699 | 2700 | ||
| 2700 | eassert (FONT_SPEC_P (spec)); | 2701 | eassert (FONT_SPEC_P (spec)); |
| @@ -3036,15 +3037,14 @@ font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs, | |||
| 3036 | { | 3037 | { |
| 3037 | Lisp_Object font_entity; | 3038 | Lisp_Object font_entity; |
| 3038 | Lisp_Object prefer; | 3039 | Lisp_Object prefer; |
| 3039 | int result, i; | 3040 | int i; |
| 3040 | FRAME_PTR f = XFRAME (frame); | 3041 | FRAME_PTR f = XFRAME (frame); |
| 3041 | 3042 | ||
| 3042 | if (NILP (XCDR (entities)) | 3043 | if (NILP (XCDR (entities)) |
| 3043 | && ASIZE (XCAR (entities)) == 1) | 3044 | && ASIZE (XCAR (entities)) == 1) |
| 3044 | { | 3045 | { |
| 3045 | font_entity = AREF (XCAR (entities), 0); | 3046 | font_entity = AREF (XCAR (entities), 0); |
| 3046 | if (c < 0 | 3047 | if (c < 0 || font_has_char (f, font_entity, c) > 0) |
| 3047 | || (result = font_has_char (f, font_entity, c)) > 0) | ||
| 3048 | return font_entity; | 3048 | return font_entity; |
| 3049 | return Qnil; | 3049 | return Qnil; |
| 3050 | } | 3050 | } |
| @@ -3618,7 +3618,7 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w, | |||
| 3618 | Lisp_Object string) | 3618 | Lisp_Object string) |
| 3619 | { | 3619 | { |
| 3620 | FRAME_PTR f; | 3620 | FRAME_PTR f; |
| 3621 | int multibyte; | 3621 | bool multibyte; |
| 3622 | Lisp_Object font_object; | 3622 | Lisp_Object font_object; |
| 3623 | 3623 | ||
| 3624 | multibyte = (NILP (string) | 3624 | multibyte = (NILP (string) |
| @@ -4295,12 +4295,15 @@ to get the correct visual image of character sequences set in the | |||
| 4295 | header of the glyph-string. | 4295 | header of the glyph-string. |
| 4296 | 4296 | ||
| 4297 | If the shaping was successful, the value is GSTRING itself or a newly | 4297 | If the shaping was successful, the value is GSTRING itself or a newly |
| 4298 | created glyph-string. Otherwise, the value is nil. */) | 4298 | created glyph-string. Otherwise, the value is nil. |
| 4299 | |||
| 4300 | See the documentation of `composition-get-gstring' for the format of | ||
| 4301 | GSTRING. */) | ||
| 4299 | (Lisp_Object gstring) | 4302 | (Lisp_Object gstring) |
| 4300 | { | 4303 | { |
| 4301 | struct font *font; | 4304 | struct font *font; |
| 4302 | Lisp_Object font_object, n, glyph; | 4305 | Lisp_Object font_object, n, glyph; |
| 4303 | ptrdiff_t i, j, from, to; | 4306 | ptrdiff_t i, from, to; |
| 4304 | 4307 | ||
| 4305 | if (! composition_gstring_p (gstring)) | 4308 | if (! composition_gstring_p (gstring)) |
| 4306 | signal_error ("Invalid glyph-string: ", gstring); | 4309 | signal_error ("Invalid glyph-string: ", gstring); |
| @@ -4326,44 +4329,42 @@ created glyph-string. Otherwise, the value is nil. */) | |||
| 4326 | if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) | 4329 | if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) |
| 4327 | LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); | 4330 | LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); |
| 4328 | 4331 | ||
| 4332 | /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that | ||
| 4333 | GLYPHS covers all characters (except for the last few ones) in | ||
| 4334 | GSTRING. More formally, provided that NCHARS is the number of | ||
| 4335 | characters in GSTRING and GLYPHS[i] is the ith glyph, FROM_IDX | ||
| 4336 | and TO_IDX of each glyph must satisfy these conditions: | ||
| 4337 | |||
| 4338 | GLYPHS[0].FROM_IDX == 0 | ||
| 4339 | GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX | ||
| 4340 | if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX) | ||
| 4341 | ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster | ||
| 4342 | GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX | ||
| 4343 | else | ||
| 4344 | ;; Be sure to cover all characters. | ||
| 4345 | GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1 */ | ||
| 4329 | glyph = LGSTRING_GLYPH (gstring, 0); | 4346 | glyph = LGSTRING_GLYPH (gstring, 0); |
| 4330 | from = LGLYPH_FROM (glyph); | 4347 | from = LGLYPH_FROM (glyph); |
| 4331 | to = LGLYPH_TO (glyph); | 4348 | to = LGLYPH_TO (glyph); |
| 4332 | for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++) | 4349 | if (from != 0 || to < from) |
| 4350 | goto shaper_error; | ||
| 4351 | for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++) | ||
| 4333 | { | 4352 | { |
| 4334 | Lisp_Object this = LGSTRING_GLYPH (gstring, i); | 4353 | glyph = LGSTRING_GLYPH (gstring, i); |
| 4335 | 4354 | if (NILP (glyph)) | |
| 4336 | if (NILP (this)) | ||
| 4337 | break; | 4355 | break; |
| 4338 | if (NILP (LGLYPH_ADJUSTMENT (this))) | 4356 | if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph) |
| 4339 | { | 4357 | && (LGLYPH_FROM (glyph) == from |
| 4340 | if (j < i - 1) | 4358 | ? LGLYPH_TO (glyph) == to |
| 4341 | for (; j < i; j++) | 4359 | : LGLYPH_FROM (glyph) == to + 1))) |
| 4342 | { | 4360 | goto shaper_error; |
| 4343 | glyph = LGSTRING_GLYPH (gstring, j); | 4361 | from = LGLYPH_FROM (glyph); |
| 4344 | LGLYPH_SET_FROM (glyph, from); | 4362 | to = LGLYPH_TO (glyph); |
| 4345 | LGLYPH_SET_TO (glyph, to); | ||
| 4346 | } | ||
| 4347 | from = LGLYPH_FROM (this); | ||
| 4348 | to = LGLYPH_TO (this); | ||
| 4349 | j = i; | ||
| 4350 | } | ||
| 4351 | else | ||
| 4352 | { | ||
| 4353 | if (from > LGLYPH_FROM (this)) | ||
| 4354 | from = LGLYPH_FROM (this); | ||
| 4355 | if (to < LGLYPH_TO (this)) | ||
| 4356 | to = LGLYPH_TO (this); | ||
| 4357 | } | ||
| 4358 | } | 4363 | } |
| 4359 | if (j < i - 1) | ||
| 4360 | for (; j < i; j++) | ||
| 4361 | { | ||
| 4362 | glyph = LGSTRING_GLYPH (gstring, j); | ||
| 4363 | LGLYPH_SET_FROM (glyph, from); | ||
| 4364 | LGLYPH_SET_TO (glyph, to); | ||
| 4365 | } | ||
| 4366 | return composition_gstring_put_cache (gstring, XINT (n)); | 4364 | return composition_gstring_put_cache (gstring, XINT (n)); |
| 4365 | |||
| 4366 | shaper_error: | ||
| 4367 | return Qnil; | ||
| 4367 | } | 4368 | } |
| 4368 | 4369 | ||
| 4369 | DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, | 4370 | DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs, |