[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Carbon / reported font width wrong?
From: |
YAMAMOTO Mitsuharu |
Subject: |
Re: Carbon / reported font width wrong? |
Date: |
Sat, 12 Nov 2005 14:33:32 +0900 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) |
>>>>> On Fri, 11 Nov 2005 15:50:14 +0000, David Reitter <address@hidden> said:
> In the Carbon port (current CVS), fontset-info or frame-char-width
> report wrong pixel widths for fonts. In the example below, two
> fontsets are created. The I set the frame font (to load the font)
> and compare reported character width with (frame-char-width).
> From my understanding of the documentation, the two should be the
> same - but they differ.
They are not necessarily the same: the former is the maximum width,
and the latter is the average width.
The reason why they are not the same even in a fixed-width font is
that the maximum metrics are confused by characters missing in the
font. One way to avoid this is to define maximum/minimum metrics as
those among ASCII characters. This is what ATSUI support code is
doing.
YAMAMOTO Mitsuharu
address@hidden
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.142
diff -c -r1.142 macterm.c
*** src/macterm.c 11 Nov 2005 16:33:44 -0000 1.142
--- src/macterm.c 12 Nov 2005 05:31:57 -0000
***************
*** 7572,7577 ****
--- 7572,7584 ----
SetRect (&max_bounds, 0, 0, 0, 0);
for (c = 0x20; c <= 0xff; c++)
{
+ if (c == 0x7f)
+ {
+ STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
+ STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
+ continue;
+ }
+
ch = c;
char_width = CharWidth (ch);
QDTextBounds (1, &ch, &char_bounds);
***************
*** 7594,7601 ****
UnionRect (&max_bounds, &char_bounds, &max_bounds);
}
}
- STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
- STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
if (min_width == max_width
&& max_bounds.left >= 0 && max_bounds.right <= max_width)
{
--- 7601,7606 ----