]> git.eshelyaron.com Git - emacs.git/commitdiff
(w32_native_per_char_metric): Don't trust the metrics
authorJason Rumney <jasonr@gnu.org>
Sun, 20 Jan 2002 16:21:15 +0000 (16:21 +0000)
committerJason Rumney <jasonr@gnu.org>
Sun, 20 Jan 2002 16:21:15 +0000 (16:21 +0000)
that Windows returns.  If a double check fails, try to guess how
ExtTextOut is going to act.

src/w32term.c

index 028c722b3b9b385fdf95fbdff40d981e523902ca..19c1d07853e72c8ad2b8495897d0159d2fe44851 100644 (file)
@@ -1238,7 +1238,18 @@ w32_native_per_char_metric (font, char2b, font_type, pcm)
 
       if (retval)
        {
+         /* Don't trust the ABC widths.  For synthesized fonts they are
+            wrong, and so is the result of GetCharWidth()!  */
+         int real_width;
+         GetCharWidth (hdc, *char2b, *char2b, &real_width);
+
          pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC;
+
+         /* As far as I can tell, this is the best way to determine what
+            ExtTextOut will do with the broken font.  */
+         if (pcm->width != real_width)
+           pcm->width = (pcm->width + real_width) / 2;
+
          pcm->lbearing = char_widths.abcA;
          pcm->rbearing = pcm->width - char_widths.abcC;
          pcm->ascent = FONT_BASE (font);