emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/w32font.c,v


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/src/w32font.c,v
Date: Thu, 26 Jun 2008 22:11:27 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Jason Rumney <jasonr>   08/06/26 22:11:26

Index: w32font.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32font.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- w32font.c   26 Jun 2008 10:48:27 -0000      1.42
+++ w32font.c   26 Jun 2008 22:11:25 -0000      1.43
@@ -233,8 +233,23 @@
      FRAME_PTR f;
      struct font *font;
 {
+  int i;
   struct w32font_info *w32_font = (struct w32font_info *) font;
+
+  /* Delete the GDI font object.  */
   DeleteObject (w32_font->hfont);
+
+  /* Free all the cached metrics.  */
+  if (w32_font->cached_metrics)
+    {
+      for (i = 0; i < w32_font->n_cache_blocks; i++)
+        {
+          if (w32_font->cached_metrics[i])
+            xfree (w32_font->cached_metrics[i]);
+        }
+      xfree (w32_font->cached_metrics);
+      w32_font->cached_metrics = NULL;
+    }
 }
 
 /* w32 implementation of has_char for font backend.
@@ -493,8 +508,7 @@
     {
       metrics->width = total_width;
       metrics->lbearing = 0;
-      metrics->rbearing = total_width
-        + ((struct w32font_info *) font)->metrics.tmOverhang;
+      metrics->rbearing = total_width + w32_font->metrics.tmOverhang;
     }
 
   /* Restore state and release DC.  */
@@ -831,15 +845,12 @@
     /* We don't know how much space we need for the full name, so start with
        96 bytes and go up in steps of 32.  */
     len = 96;
-    name = xmalloc (len);
+    name = alloca (len);
     while (name && w32font_full_name (&logfont, font_entity, pixel_size,
                                       name, len) < 0)
       {
-        char *new = xrealloc (name, len += 32);
-
-        if (! new)
-          xfree (name);
-        name = new;
+        len += 32;
+        name = alloca (len);
       }
     if (name)
       font->props[FONT_FULLNAME_INDEX]
@@ -2048,7 +2059,7 @@
   /* Initialize as much of the font details as we can from the current
      default font.  */
   hdc = GetDC (FRAME_W32_WINDOW (f));
-  oldobj = SelectObject (hdc, ((struct w32font_info *) FRAME_FONT (f))->hfont);
+  oldobj = SelectObject (hdc, FONT_HANDLE (FRAME_FONT (f)));
   GetTextFace (hdc, LF_FACESIZE, lf.lfFaceName);
   if (GetTextMetrics (hdc, &tm))
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]