length in @dfn{ems}@footnote{In typography an em is a distance
equivalent to the height of the type. For example when using 12 point
type 1 em is equal to 12 points. Its use ensures distances and type
-remain proportional.}. One em is equivalent to the height of the font
-and @var{value} may be an integer or a float.
+remain proportional.}. One em is equivalent to the size of the font
+and @var{value} may be an integer or a float. Also, dimension can be
+specified in @code{(@var{value} . ch)} and @code{(@var{value} . cw)}
+forms, where @code{ch} means height of the canonical character and
+@code{cw} means width of the canonical character.
The following is a list of properties that are meaningful for all
image types (there are also properties which are meaningful only for
int face_font_size;
char *face_font_family;
+ /* Details of the font used to calculate image size relative to the
+ canonical character size, with `ch' and `cw' specifiers. */
+ int face_font_height;
+ int face_font_width;
+
/* True if this image has a `transparent' background -- that is, is
uses an image mask. The accessor macro for this is
`IMAGE_BACKGROUND_TRANSPARENT'. */
if (FIXNATP (value))
return min (XFIXNAT (value), INT_MAX);
- if (CONSP (value) && NUMBERP (CAR (value)) && EQ (Qem, CDR (value)))
- return scale_image_size (img->face_font_size, 1, XFLOATINT (CAR (value)));
+ if (CONSP (value) && NUMBERP (CAR (value)))
+ {
+ Lisp_Object dim = CDR (value);
+ if (EQ (Qem, dim))
+ return scale_image_size (img->face_font_size,
+ 1, XFLOATINT (CAR (value)));
+ if (EQ (Qch, dim))
+ return scale_image_size (img->face_font_height,
+ 1, XFLOATINT (CAR (value)));
+ if (EQ (Qcw, dim))
+ return scale_image_size (img->face_font_width,
+ 1, XFLOATINT (CAR (value)));
+ }
return -1;
}
img->face_foreground = foreground;
img->face_background = background;
img->face_font_size = font_size;
+ img->face_font_height = face->font->height;
+ img->face_font_width = face->font->average_width;
img->face_font_family = xmalloc (strlen (font_family) + 1);
strcpy (img->face_font_family, font_family);
img->load_failed_p = ! img->type->load_img (f, img);
DEFSYM (QCmax_height, ":max-height");
DEFSYM (Qem, "em");
+ DEFSYM (Qch, "ch");
+ DEFSYM (Qcw, "cw");
#ifdef HAVE_NATIVE_TRANSFORMS
DEFSYM (Qscale, "scale");