aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
authorEli Zaretskii2015-06-29 19:10:20 +0300
committerEli Zaretskii2015-06-29 19:10:20 +0300
commitea60b543f6829061b751a0a1c60309bcfe2ff7a7 (patch)
tree32f94c7ec2c82f9a1c35465e21f291ccbc8eb486 /src/font.c
parent64110eb14d33d078c8fe6d496a780e46a0019b36 (diff)
downloademacs-ea60b543f6829061b751a0a1c60309bcfe2ff7a7.tar.gz
emacs-ea60b543f6829061b751a0a1c60309bcfe2ff7a7.zip
Allow font names that end in "-NN", where NN is a number
* src/font.c (font_load_for_lface): If the font-spec didn't match any available fonts, try again without interpreting trailing "-NN" as the font size. For the description of the original problem, see http://lists.gnu.org/archive/html/help-emacs-windows/2015-06/msg00001.html
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/font.c b/src/font.c
index 564c53ae54e..575975ced73 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3337,6 +3337,38 @@ font_load_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec)
3337 /* No font is listed for SPEC, but each font-backend may have 3337 /* No font is listed for SPEC, but each font-backend may have
3338 different criteria about "font matching". So, try it. */ 3338 different criteria about "font matching". So, try it. */
3339 entity = font_matching_entity (f, attrs, spec); 3339 entity = font_matching_entity (f, attrs, spec);
3340 /* Perhaps the user asked for a font "Foobar-123", and we
3341 interpreted "-123" as the size, whereas it really is part of
3342 the name. So we reset the size to nil and the family name to
3343 the entire "Foobar-123" thing, and try again with that. */
3344 if (NILP (entity))
3345 {
3346 name = Ffont_get (spec, QCuser_spec);
3347 if (STRINGP (name))
3348 {
3349 char *p = SDATA (name), *q = strrchr (p, '-');
3350
3351 if (q != NULL && c_isdigit (q[1]))
3352 {
3353 char *tail;
3354 double font_size = strtod (q + 1, &tail);
3355
3356 if (font_size > 0 && tail != q + 1)
3357 {
3358 Lisp_Object lsize = Ffont_get (spec, QCsize);
3359
3360 if ((FLOATP (lsize) && XFLOAT_DATA (lsize) == font_size)
3361 || (INTEGERP (lsize) && XINT (lsize) == font_size))
3362 {
3363 ASET (spec, FONT_FAMILY_INDEX,
3364 font_intern_prop (p, tail - p, 1));
3365 ASET (spec, FONT_SIZE_INDEX, Qnil);
3366 entity = font_matching_entity (f, attrs, spec);
3367 }
3368 }
3369 }
3370 }
3371 }
3340 if (NILP (entity)) 3372 if (NILP (entity))
3341 return Qnil; 3373 return Qnil;
3342 } 3374 }