unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Emacs should check font width also when spacing is dual
@ 2009-06-17 14:56 Naohiro Aota
  2009-06-17 17:16 ` Chong Yidong
  0 siblings, 1 reply; 3+ messages in thread
From: Naohiro Aota @ 2009-06-17 14:56 UTC (permalink / raw)
  To: emacs-devel

Hi,

I found that emacs check character width one by one to calculate
font->min_width, font->average_width, font->space_width only when
`spacing' is not FC_PROPORTIONAL. But fontconfig's doc (1) says
"FC_DUAL, where the font has glyphs in precisely two widths, one twice
as wide as the other". So emacs should check them one by one also when
spacing is dual. Current behavior causes tab width to be doubled and so
indent to be strange.

To solve this, I suggest a tiny patch below. 

2009-06-17  Naohiro Aota  <naota@elisp.net>

	* xftfont.c (xftfont_open): Check font width one by one also when
	spacing is dual.

	* ftfont.c (ftfont_open): Ditto.

--8<---------------cut here---------------start------------->8---
--- src/ftfont.c	17 Apr 2009 18:38:02 -0000	1.54
+++ src/ftfont.c	17 Jun 2009 14:51:37 -0000
@@ -1244,7 +1244,7 @@
     spacing = XINT (AREF (entity, FONT_SPACING_INDEX));
   else
     spacing = FC_PROPORTIONAL;
-  if (spacing != FC_PROPORTIONAL)
+  if (spacing != FC_PROPORTIONAL && spacing != FC_DUAL)
     font->min_width = font->average_width = font->space_width
       = (scalable ? ft_face->max_advance_width * size / upEM
 	 : ft_face->size->metrics.max_advance >> 6);
--- src/xftfont.c	11 May 2009 09:29:49 -0000	1.24
+++ src/xftfont.c	17 Jun 2009 14:51:37 -0000
@@ -333,7 +333,7 @@
 	ascii_printable[i] = ' ' + i;
     }
   BLOCK_INPUT;
-  if (spacing != FC_PROPORTIONAL)
+  if (spacing != FC_PROPORTIONAL && spacing != FC_DUAL)
     {
       font->min_width = font->average_width = font->space_width
 	= xftfont->max_advance_width;
--8<---------------cut here---------------end--------------->8---

(1) http://fontconfig.org/fontconfig-devel/r1283.html

Regards,




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Emacs should check font width also when spacing is dual
  2009-06-17 14:56 [PATCH] Emacs should check font width also when spacing is dual Naohiro Aota
@ 2009-06-17 17:16 ` Chong Yidong
  2009-06-18  0:57   ` Naohiro Aota
  0 siblings, 1 reply; 3+ messages in thread
From: Chong Yidong @ 2009-06-17 17:16 UTC (permalink / raw)
  To: Naohiro Aota; +Cc: emacs-devel

Naohiro Aota <naota@elisp.net> writes:

> Current behavior causes tab width to be doubled and so indent to be
> strange.

I don't see any strange behavior.  (Tabs are displayed specially in
Emacs, so I don't know how you're viewing them.)  Please provide a
reproducible test case.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Emacs should check font width also when spacing is dual
  2009-06-17 17:16 ` Chong Yidong
@ 2009-06-18  0:57   ` Naohiro Aota
  0 siblings, 0 replies; 3+ messages in thread
From: Naohiro Aota @ 2009-06-18  0:57 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

Chong Yidong <cyd@stupidchicken.com> writes:

> Naohiro Aota <naota@elisp.net> writes:
>
>> Current behavior causes tab width to be doubled and so indent to be
>> strange.
>
> I don't see any strange behavior.  (Tabs are displayed specially in
> Emacs, so I don't know how you're viewing them.)  Please provide a
> reproducible test case.

Using fonts whose spacing is DUAL cause the problem.  M+ font is one of
them. (1)

--8<---------------cut here---------------start------------->8---
12345678901234567890
	<-tab
(add-hook 'after-save-hook
	  (function (lambda ()
		      (if (string= (expand-file-name "~/.emacs.el")
				   (buffer-file-name))
			  (save-excursion
			    (byte-compile-file "~/.emacs.el"))))))
--8<---------------cut here---------------end--------------->8---

(unpatched) emacs -q -fn "M+ 1m", open <above file>


[-- Attachment #2: screenshot-20090618_0934.png --]
[-- Type: image/png, Size: 21804 bytes --]

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


same file with firefox


[-- Attachment #4: screenshot-20090618_0921.png --]
[-- Type: image/png, Size: 1496 bytes --]

[-- Attachment #5: Type: text/plain, Size: 31 bytes --]


same file with patched emacs


[-- Attachment #6: screenshot-20090618_0948.png --]
[-- Type: image/png, Size: 20822 bytes --]

[-- Attachment #7: Type: text/plain, Size: 73 bytes --]


(1) http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-06-18  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 14:56 [PATCH] Emacs should check font width also when spacing is dual Naohiro Aota
2009-06-17 17:16 ` Chong Yidong
2009-06-18  0:57   ` Naohiro Aota

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).