aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c65
1 files changed, 34 insertions, 31 deletions
diff --git a/src/font.c b/src/font.c
index 1a4742ba959..30c39771fd6 100644
--- a/src/font.c
+++ b/src/font.c
@@ -238,7 +238,7 @@ font_intern_prop (const char *str, ptrdiff_t len, int force_symbol)
238 ptrdiff_t i; 238 ptrdiff_t i;
239 Lisp_Object tem; 239 Lisp_Object tem;
240 Lisp_Object obarray; 240 Lisp_Object obarray;
241 EMACS_INT nbytes, nchars; 241 ptrdiff_t nbytes, nchars;
242 242
243 if (len == 1 && *str == '*') 243 if (len == 1 && *str == '*')
244 return Qnil; 244 return Qnil;
@@ -364,7 +364,7 @@ font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror
364 else 364 else
365 { 365 {
366 int i, last_n; 366 int i, last_n;
367 int numeric = XINT (val); 367 EMACS_INT numeric = XINT (val);
368 368
369 for (i = 0, last_n = -1; i < len; i++) 369 for (i = 0, last_n = -1; i < len; i++)
370 { 370 {
@@ -518,7 +518,7 @@ font_prop_validate_style (Lisp_Object style, Lisp_Object val)
518 : FONT_WIDTH_INDEX); 518 : FONT_WIDTH_INDEX);
519 if (INTEGERP (val)) 519 if (INTEGERP (val))
520 { 520 {
521 int n = XINT (val); 521 EMACS_INT n = XINT (val);
522 if (((n >> 4) & 0xF) 522 if (((n >> 4) & 0xF)
523 >= ASIZE (AREF (font_style_table, prop - FONT_WEIGHT_INDEX))) 523 >= ASIZE (AREF (font_style_table, prop - FONT_WEIGHT_INDEX)))
524 val = Qerror; 524 val = Qerror;
@@ -848,7 +848,7 @@ font_expand_wildcards (Lisp_Object *field, int n)
848 848
849 if (INTEGERP (val)) 849 if (INTEGERP (val))
850 { 850 {
851 int numeric = XINT (val); 851 EMACS_INT numeric = XINT (val);
852 852
853 if (i + 1 == n) 853 if (i + 1 == n)
854 from = to = XLFD_ENCODING_INDEX, 854 from = to = XLFD_ENCODING_INDEX,
@@ -1740,7 +1740,8 @@ static int
1740check_gstring (Lisp_Object gstring) 1740check_gstring (Lisp_Object gstring)
1741{ 1741{
1742 Lisp_Object val; 1742 Lisp_Object val;
1743 int i, j; 1743 ptrdiff_t i;
1744 int j;
1744 1745
1745 CHECK_VECTOR (gstring); 1746 CHECK_VECTOR (gstring);
1746 val = AREF (gstring, 0); 1747 val = AREF (gstring, 0);
@@ -2433,7 +2434,7 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
2433 /* All characters in the list must be supported. */ 2434 /* All characters in the list must be supported. */
2434 for (; CONSP (val2); val2 = XCDR (val2)) 2435 for (; CONSP (val2); val2 = XCDR (val2))
2435 { 2436 {
2436 if (! NATNUMP (XCAR (val2))) 2437 if (! CHARACTERP (XCAR (val2)))
2437 continue; 2438 continue;
2438 if (font_encode_char (font, XFASTINT (XCAR (val2))) 2439 if (font_encode_char (font, XFASTINT (XCAR (val2)))
2439 == FONT_INVALID_CODE) 2440 == FONT_INVALID_CODE)
@@ -2445,7 +2446,7 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
2445 /* At most one character in the vector must be supported. */ 2446 /* At most one character in the vector must be supported. */
2446 for (i = 0; i < ASIZE (val2); i++) 2447 for (i = 0; i < ASIZE (val2); i++)
2447 { 2448 {
2448 if (! NATNUMP (AREF (val2, i))) 2449 if (! CHARACTERP (AREF (val2, i)))
2449 continue; 2450 continue;
2450 if (font_encode_char (font, XFASTINT (AREF (val2, i))) 2451 if (font_encode_char (font, XFASTINT (AREF (val2, i)))
2451 != FONT_INVALID_CODE) 2452 != FONT_INVALID_CODE)
@@ -3076,6 +3077,7 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c)
3076 Lisp_Object foundry[3], *family, registry[3], adstyle[3]; 3077 Lisp_Object foundry[3], *family, registry[3], adstyle[3];
3077 int pixel_size; 3078 int pixel_size;
3078 int i, j, k, l; 3079 int i, j, k, l;
3080 USE_SAFE_ALLOCA;
3079 3081
3080 registry[0] = AREF (spec, FONT_REGISTRY_INDEX); 3082 registry[0] = AREF (spec, FONT_REGISTRY_INDEX);
3081 if (NILP (registry[0])) 3083 if (NILP (registry[0]))
@@ -3171,7 +3173,8 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c)
3171 3173
3172 if (! NILP (alters)) 3174 if (! NILP (alters))
3173 { 3175 {
3174 family = alloca ((sizeof family[0]) * (XINT (Flength (alters)) + 2)); 3176 EMACS_INT alterslen = XFASTINT (Flength (alters));
3177 SAFE_ALLOCA_LISP (family, alterslen + 2);
3175 for (i = 0; CONSP (alters); i++, alters = XCDR (alters)) 3178 for (i = 0; CONSP (alters); i++, alters = XCDR (alters))
3176 family[i] = XCAR (alters); 3179 family[i] = XCAR (alters);
3177 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) 3180 if (NILP (AREF (spec, FONT_FAMILY_INDEX)))
@@ -3213,6 +3216,8 @@ font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c)
3213 } 3216 }
3214 } 3217 }
3215 } 3218 }
3219
3220 SAFE_FREE ();
3216 return Qnil; 3221 return Qnil;
3217} 3222}
3218 3223
@@ -3611,7 +3616,7 @@ font_filter_properties (Lisp_Object font,
3611 STRING. */ 3616 STRING. */
3612 3617
3613static Lisp_Object 3618static Lisp_Object
3614font_at (int c, EMACS_INT pos, struct face *face, struct window *w, 3619font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3615 Lisp_Object string) 3620 Lisp_Object string)
3616{ 3621{
3617 FRAME_PTR f; 3622 FRAME_PTR f;
@@ -3627,7 +3632,7 @@ font_at (int c, EMACS_INT pos, struct face *face, struct window *w,
3627 { 3632 {
3628 if (multibyte) 3633 if (multibyte)
3629 { 3634 {
3630 EMACS_INT pos_byte = CHAR_TO_BYTE (pos); 3635 ptrdiff_t pos_byte = CHAR_TO_BYTE (pos);
3631 3636
3632 c = FETCH_CHAR (pos_byte); 3637 c = FETCH_CHAR (pos_byte);
3633 } 3638 }
@@ -3641,7 +3646,7 @@ font_at (int c, EMACS_INT pos, struct face *face, struct window *w,
3641 multibyte = STRING_MULTIBYTE (string); 3646 multibyte = STRING_MULTIBYTE (string);
3642 if (multibyte) 3647 if (multibyte)
3643 { 3648 {
3644 EMACS_INT pos_byte = string_char_to_byte (string, pos); 3649 ptrdiff_t pos_byte = string_char_to_byte (string, pos);
3645 3650
3646 str = SDATA (string) + pos_byte; 3651 str = SDATA (string) + pos_byte;
3647 c = STRING_CHAR (str); 3652 c = STRING_CHAR (str);
@@ -3657,7 +3662,7 @@ font_at (int c, EMACS_INT pos, struct face *face, struct window *w,
3657 if (! face) 3662 if (! face)
3658 { 3663 {
3659 int face_id; 3664 int face_id;
3660 EMACS_INT endptr; 3665 ptrdiff_t endptr;
3661 3666
3662 if (STRINGP (string)) 3667 if (STRINGP (string))
3663 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr, 3668 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr,
@@ -3694,9 +3699,9 @@ font_at (int c, EMACS_INT pos, struct face *face, struct window *w,
3694 It is assured that the current buffer (or STRING) is multibyte. */ 3699 It is assured that the current buffer (or STRING) is multibyte. */
3695 3700
3696Lisp_Object 3701Lisp_Object
3697font_range (EMACS_INT pos, EMACS_INT *limit, struct window *w, struct face *face, Lisp_Object string) 3702font_range (ptrdiff_t pos, ptrdiff_t *limit, struct window *w, struct face *face, Lisp_Object string)
3698{ 3703{
3699 EMACS_INT pos_byte, ignore; 3704 ptrdiff_t pos_byte, ignore;
3700 int c; 3705 int c;
3701 Lisp_Object font_object = Qnil; 3706 Lisp_Object font_object = Qnil;
3702 3707
@@ -4102,7 +4107,7 @@ how close they are to PREFER. */)
4102 (Lisp_Object font_spec, Lisp_Object frame, Lisp_Object num, Lisp_Object prefer) 4107 (Lisp_Object font_spec, Lisp_Object frame, Lisp_Object num, Lisp_Object prefer)
4103{ 4108{
4104 Lisp_Object vec, list; 4109 Lisp_Object vec, list;
4105 int n = 0; 4110 EMACS_INT n = 0;
4106 4111
4107 if (NILP (frame)) 4112 if (NILP (frame))
4108 frame = selected_frame; 4113 frame = selected_frame;
@@ -4269,13 +4274,10 @@ void
4269font_fill_lglyph_metrics (Lisp_Object glyph, Lisp_Object font_object) 4274font_fill_lglyph_metrics (Lisp_Object glyph, Lisp_Object font_object)
4270{ 4275{
4271 struct font *font = XFONT_OBJECT (font_object); 4276 struct font *font = XFONT_OBJECT (font_object);
4272 unsigned code; 4277 unsigned code = font->driver->encode_char (font, LGLYPH_CHAR (glyph));
4273 /* ecode used in LGLYPH_SET_CODE to avoid compiler warnings. */
4274 EMACS_INT ecode = font->driver->encode_char (font, LGLYPH_CHAR (glyph));
4275 struct font_metrics metrics; 4278 struct font_metrics metrics;
4276 4279
4277 LGLYPH_SET_CODE (glyph, ecode); 4280 LGLYPH_SET_CODE (glyph, code);
4278 code = ecode;
4279 font->driver->text_extents (font, &code, 1, &metrics); 4281 font->driver->text_extents (font, &code, 1, &metrics);
4280 LGLYPH_SET_LBEARING (glyph, metrics.lbearing); 4282 LGLYPH_SET_LBEARING (glyph, metrics.lbearing);
4281 LGLYPH_SET_RBEARING (glyph, metrics.rbearing); 4283 LGLYPH_SET_RBEARING (glyph, metrics.rbearing);
@@ -4297,7 +4299,7 @@ created glyph-string. Otherwise, the value is nil. */)
4297{ 4299{
4298 struct font *font; 4300 struct font *font;
4299 Lisp_Object font_object, n, glyph; 4301 Lisp_Object font_object, n, glyph;
4300 EMACS_INT i, j, from, to; 4302 ptrdiff_t i, j, from, to;
4301 4303
4302 if (! composition_gstring_p (gstring)) 4304 if (! composition_gstring_p (gstring))
4303 signal_error ("Invalid glyph-string: ", gstring); 4305 signal_error ("Invalid glyph-string: ", gstring);
@@ -4316,8 +4318,7 @@ created glyph-string. Otherwise, the value is nil. */)
4316 if (INTEGERP (n)) 4318 if (INTEGERP (n))
4317 break; 4319 break;
4318 gstring = larger_vector (gstring, 4320 gstring = larger_vector (gstring,
4319 ASIZE (gstring) + LGSTRING_GLYPH_LEN (gstring), 4321 LGSTRING_GLYPH_LEN (gstring), -1);
4320 Qnil);
4321 } 4322 }
4322 if (i == 3 || XINT (n) == 0) 4323 if (i == 3 || XINT (n) == 0)
4323 return Qnil; 4324 return Qnil;
@@ -4525,7 +4526,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4525 doc: /* Open FONT-ENTITY. */) 4526 doc: /* Open FONT-ENTITY. */)
4526 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame) 4527 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame)
4527{ 4528{
4528 int isize; 4529 EMACS_INT isize;
4529 4530
4530 CHECK_FONT_ENTITY (font_entity); 4531 CHECK_FONT_ENTITY (font_entity);
4531 if (NILP (frame)) 4532 if (NILP (frame))
@@ -4541,6 +4542,8 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4541 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), XFRAME (frame)->resy); 4542 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), XFRAME (frame)->resy);
4542 else 4543 else
4543 isize = XINT (size); 4544 isize = XINT (size);
4545 if (! (INT_MIN <= isize && isize <= INT_MAX))
4546 args_out_of_range (font_entity, size);
4544 if (isize == 0) 4547 if (isize == 0)
4545 isize = 120; 4548 isize = 120;
4546 } 4549 }
@@ -4644,14 +4647,14 @@ the corresponding element is nil. */)
4644 Lisp_Object object) 4647 Lisp_Object object)
4645{ 4648{
4646 struct font *font; 4649 struct font *font;
4647 int i, len; 4650 ptrdiff_t i, len;
4648 Lisp_Object *chars, vec; 4651 Lisp_Object *chars, vec;
4649 USE_SAFE_ALLOCA; 4652 USE_SAFE_ALLOCA;
4650 4653
4651 CHECK_FONT_GET_OBJECT (font_object, font); 4654 CHECK_FONT_GET_OBJECT (font_object, font);
4652 if (NILP (object)) 4655 if (NILP (object))
4653 { 4656 {
4654 EMACS_INT charpos, bytepos; 4657 ptrdiff_t charpos, bytepos;
4655 4658
4656 validate_region (&from, &to); 4659 validate_region (&from, &to);
4657 if (EQ (from, to)) 4660 if (EQ (from, to))
@@ -4757,22 +4760,22 @@ the current buffer. It defaults to the currently selected window. */)
4757 (Lisp_Object position, Lisp_Object window, Lisp_Object string) 4760 (Lisp_Object position, Lisp_Object window, Lisp_Object string)
4758{ 4761{
4759 struct window *w; 4762 struct window *w;
4760 EMACS_INT pos; 4763 ptrdiff_t pos;
4761 4764
4762 if (NILP (string)) 4765 if (NILP (string))
4763 { 4766 {
4764 CHECK_NUMBER_COERCE_MARKER (position); 4767 CHECK_NUMBER_COERCE_MARKER (position);
4765 pos = XINT (position); 4768 if (! (BEGV <= XINT (position) && XINT (position) < ZV))
4766 if (pos < BEGV || pos >= ZV)
4767 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); 4769 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
4770 pos = XINT (position);
4768 } 4771 }
4769 else 4772 else
4770 { 4773 {
4771 CHECK_NUMBER (position); 4774 CHECK_NUMBER (position);
4772 CHECK_STRING (string); 4775 CHECK_STRING (string);
4773 pos = XINT (position); 4776 if (! (0 < XINT (position) && XINT (position) < SCHARS (string)))
4774 if (pos < 0 || pos >= SCHARS (string))
4775 args_out_of_range (string, position); 4777 args_out_of_range (string, position);
4778 pos = XINT (position);
4776 } 4779 }
4777 if (NILP (window)) 4780 if (NILP (window))
4778 window = selected_window; 4781 window = selected_window;