emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109640: For Xft and X font backends,


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109640: For Xft and X font backends, set omitted max_width font fields.
Date: Thu, 16 Aug 2012 14:35:13 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109640
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Thu 2012-08-16 14:35:13 +0800
message:
  For Xft and X font backends, set omitted max_width font fields.
  
  * src/xfont.c (xfont_open):
  * src/xftfont.c (xftfont_open): Set the font's max_width field.
  
  * src/font.h (struct font): Update comments.
modified:
  src/ChangeLog
  src/font.h
  src/xfont.c
  src/xftfont.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-16 03:13:44 +0000
+++ b/src/ChangeLog     2012-08-16 06:35:13 +0000
@@ -1,6 +1,19 @@
+2012-08-16  Chong Yidong  <address@hidden>
+
+       * xfont.c (xfont_open):
+       * xftfont.c (xftfont_open): Set the font's max_width field.
+
+       * nsfont.m (nsfont_open): Similar to the Xft backend, set
+       min_width to space_width and average_width to the average over
+       printable ASCII characters.
+       (ns_char_width): Code cleanup.
+       (ns_ascii_average_width): New utility function.
+
+       * font.h (struct font): Update comments.
+
 2012-08-16  Dmitry Antipov  <address@hidden>
 
-       Simple interface to set Lisp_Object fields of chararcter tables.
+       Simple interface to set Lisp_Object fields of character tables.
        * lisp.h (CSET): New macro.
        (char_table_set_extras, char_table_set_contents)
        (sub_char_table_set_contents): New function.

=== modified file 'src/font.h'
--- a/src/font.h        2012-08-15 14:20:16 +0000
+++ b/src/font.h        2012-08-16 06:35:13 +0000
@@ -284,8 +284,11 @@
 
   /* Beyond here, there should be no more Lisp_Object components.  */
 
-  /* Maximum bound width over all existing characters of the font.  On
-     X window, this is same as (font->max_bounds.width).  */
+  /* Minimum and maximum glyph widths, in pixels.  Some font backends,
+     such as xft, lack the information to easily compute minimum and
+     maximum widths over all characters; in that case, these values
+     are approximate.  */
+  int min_width;
   int max_width;
 
   /* By which pixel size the font is opened.  */
@@ -301,13 +304,10 @@
 
   /* Average width of glyphs in the font.  If the font itself doesn't
      have that information but has glyphs of ASCII characters, the
-     value is the average with of those glyphs.  Otherwise, the value
+     value is the average width of those glyphs.  Otherwise, the value
      is 0.  */
   int average_width;
 
-  /* Minimum glyph width (in pixels).  */
-  int min_width;
-
   /* Ascent and descent of the font (in pixels).  */
   int ascent, descent;
 

=== modified file 'src/xfont.c'
--- a/src/xfont.c       2012-08-15 14:20:16 +0000
+++ b/src/xfont.c       2012-08-16 06:35:13 +0000
@@ -823,6 +823,7 @@
   font->descent = xfont->descent;
   font->height = font->ascent + font->descent;
   font->min_width = xfont->min_bounds.width;
+  font->max_width = xfont->max_bounds.width;
   if (xfont->min_bounds.width == xfont->max_bounds.width)
     {
       /* Fixed width font.  */

=== modified file 'src/xftfont.c'
--- a/src/xftfont.c     2012-08-15 14:20:16 +0000
+++ b/src/xftfont.c     2012-08-16 06:35:13 +0000
@@ -414,20 +414,25 @@
        ascii_printable[ch] = ' ' + ch;
     }
   BLOCK_INPUT;
+
+  /* Unfortunately Xft doesn't provide a way to get minimum char
+     width.  So, we set min_width to space_width.  */
+
   if (spacing != FC_PROPORTIONAL
 #ifdef FC_DUAL
       && spacing != FC_DUAL
 #endif /* FC_DUAL */
       )
     {
-      font->min_width = font->average_width = font->space_width
-       = xftfont->max_advance_width;
+      font->min_width = font->max_width = font->average_width
+       = font->space_width = xftfont->max_advance_width;
       XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents);
     }
   else
     {
       XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents);
-      font->space_width = extents.xOff;
+      font->min_width = font->max_width = font->space_width
+       = extents.xOff;
       if (font->space_width <= 0)
        /* dirty workaround */
        font->space_width = pixel_size;
@@ -470,10 +475,6 @@
 #endif /* HAVE_LIBOTF */
   xftfont_info->ft_size = ft_face->size;
 
-  /* Unfortunately Xft doesn't provide a way to get minimum char
-     width.  So, we use space_width instead.  */
-  font->min_width = font->space_width;
-
   font->baseline_offset = 0;
   font->relative_compose = 0;
   font->default_ascent = 0;
@@ -764,6 +765,8 @@
   DEFSYM (QCembolden, ":embolden");
   DEFSYM (QClcdfilter, ":lcdfilter");
 
+  ascii_printable[0] = 0;
+
   xftfont_driver = ftfont_driver;
   xftfont_driver.type = Qxft;
   xftfont_driver.get_cache = xfont_driver.get_cache;


reply via email to

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