changeset 92394:7701acfc2ec5

(w32font_full_name): Report point size for scalable fonts.
author Jason Rumney <jasonr@gnu.org>
date Sat, 01 Mar 2008 23:03:57 +0000
parents 26aa5e50effb
children 0038cf6ddf6a
files src/w32font.c
diffstat 1 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32font.c	Sat Mar 01 22:30:51 2008 +0000
+++ b/src/w32font.c	Sat Mar 01 23:03:57 2008 +0000
@@ -1553,11 +1553,20 @@
   char *name;
   int nbytes;
 {
-  int len;
+  int len, height, outline;
   char *p;
   Lisp_Object antialiasing, weight = Qnil;
 
-  len = strlen (font->lfFaceName) + 21; /* :pixelsize=SIZE */
+  len = strlen (font->lfFaceName);
+
+  outline = EQ (AREF (font_obj, FONT_FOUNDRY_INDEX), Qoutline);
+
+  /* Represent size of scalable fonts by point size. But use pixelsize for
+     raster fonts to indicate that they are exactly that size.  */
+  if (outline)
+    len += 11; /* -SIZE */
+  else
+    len = strlen (font->lfFaceName) + 21;
 
   if (font->lfItalic)
     len += 7; /* :italic */
@@ -1579,10 +1588,20 @@
   p = name;
   p += sprintf (p, "%s", font->lfFaceName);
 
-  if (font->lfHeight)
-    p += sprintf (p, ":pixelsize=%d", eabs (font->lfHeight));
-  else if (pixel_size > 0)
-    p += sprintf (p, ":pixelsize=%d", pixel_size);
+  height = font->lfHeight ? eabs (font->lfHeight) : pixel_size;
+
+  if (height > 0)
+    {
+      if (outline)
+        {
+          float pointsize = height * 72.0 / one_w32_display_info.resy;
+          /* Round to nearest half point.  */
+          pointsize = round (pointsize * 2) / 2;
+          p += sprintf (p, "-%1.1f", pointsize);
+        }
+      else
+        p += sprintf (p, ":pixelsize=%d", height);
+    }
 
   if (font->lfItalic)
     p += sprintf (p, ":italic");