aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZajcev Evgeny2024-03-21 17:47:29 +0300
committerEli Zaretskii2024-04-01 14:18:05 +0300
commit61d70186a4a80d0ffc0aaef224e514ff9cac0372 (patch)
treed7708de41cd1ed05d6ea04bea5db1117f99b04b3 /src
parent7f377407b4b7d6ac9994ed983d7516bc42139885 (diff)
downloademacs-61d70186a4a80d0ffc0aaef224e514ff9cac0372.tar.gz
emacs-61d70186a4a80d0ffc0aaef224e514ff9cac0372.zip
Add support for `ch' and `cw' dimension specifiers for images
* src/image.c (image_get_dimension, lookup_image): Handle `ch' and `cw' dimension specifiers in addition to `em'. * src/dispextern.h: Add new members `face_font_height' and `face_font_width' to `struct image'. * doc/lispref/display.texi (Image Descriptors): Document `ch' and `cw'.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h5
-rw-r--r--src/image.c19
2 files changed, 22 insertions, 2 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 1c3232fae3d..f29377f3596 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3186,6 +3186,11 @@ struct image
3186 int face_font_size; 3186 int face_font_size;
3187 char *face_font_family; 3187 char *face_font_family;
3188 3188
3189 /* Details of the font used to calculate image size relative to the
3190 canonical character size, with `ch' and `cw' specifiers. */
3191 int face_font_height;
3192 int face_font_width;
3193
3189 /* True if this image has a `transparent' background -- that is, is 3194 /* True if this image has a `transparent' background -- that is, is
3190 uses an image mask. The accessor macro for this is 3195 uses an image mask. The accessor macro for this is
3191 `IMAGE_BACKGROUND_TRANSPARENT'. */ 3196 `IMAGE_BACKGROUND_TRANSPARENT'. */
diff --git a/src/image.c b/src/image.c
index 41d72964631..216bdc1ee66 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2558,9 +2558,20 @@ image_get_dimension (struct image *img, Lisp_Object symbol)
2558 2558
2559 if (FIXNATP (value)) 2559 if (FIXNATP (value))
2560 return min (XFIXNAT (value), INT_MAX); 2560 return min (XFIXNAT (value), INT_MAX);
2561 if (CONSP (value) && NUMBERP (CAR (value)) && EQ (Qem, CDR (value))) 2561 if (CONSP (value) && NUMBERP (CAR (value)))
2562 return scale_image_size (img->face_font_size, 1, XFLOATINT (CAR (value))); 2562 {
2563 Lisp_Object dim = CDR (value);
2563 2564
2565 if (EQ (Qem, dim))
2566 return scale_image_size (img->face_font_size,
2567 1, XFLOATINT (CAR (value)));
2568 if (EQ (Qch, dim))
2569 return scale_image_size (img->face_font_height,
2570 1, XFLOATINT (CAR (value)));
2571 if (EQ (Qcw, dim))
2572 return scale_image_size (img->face_font_width,
2573 1, XFLOATINT (CAR (value)));
2574 }
2564 return -1; 2575 return -1;
2565} 2576}
2566 2577
@@ -3384,6 +3395,8 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id)
3384 img->face_foreground = foreground; 3395 img->face_foreground = foreground;
3385 img->face_background = background; 3396 img->face_background = background;
3386 img->face_font_size = font_size; 3397 img->face_font_size = font_size;
3398 img->face_font_height = face->font->height;
3399 img->face_font_width = face->font->average_width;
3387 img->face_font_family = xmalloc (strlen (font_family) + 1); 3400 img->face_font_family = xmalloc (strlen (font_family) + 1);
3388 strcpy (img->face_font_family, font_family); 3401 strcpy (img->face_font_family, font_family);
3389 img->load_failed_p = ! img->type->load_img (f, img); 3402 img->load_failed_p = ! img->type->load_img (f, img);
@@ -12794,6 +12807,8 @@ non-numeric, there is no explicit limit on the size of images. */);
12794 DEFSYM (QCmax_height, ":max-height"); 12807 DEFSYM (QCmax_height, ":max-height");
12795 12808
12796 DEFSYM (Qem, "em"); 12809 DEFSYM (Qem, "em");
12810 DEFSYM (Qch, "ch");
12811 DEFSYM (Qcw, "cw");
12797 12812
12798#ifdef HAVE_NATIVE_TRANSFORMS 12813#ifdef HAVE_NATIVE_TRANSFORMS
12799 DEFSYM (Qscale, "scale"); 12814 DEFSYM (Qscale, "scale");