super/subscript offset : platform parity

NEW
Assigned to

Status

()

Core
Layout: Text
14 years ago
5 years ago

People

(Reporter: Jungshik Shin, Assigned: Jungshik Shin)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

14 years ago
Different Gfx ports use different (fallback) values for the superscript offset 
and the subscript offset. 

1. Win32 : try to get the value via Win32 API. if not available, 
          use mXHeight for both offsets
2. Gtk-Xft: try to get the value from the OS/2 table if available.
            guarantee that it's at least a pixel.
            if not, use mXHeight for both offsets
3. Gtk-X11(Xlib/Xprint included) : 
           try to get the value via X11 API (XA_*) if available.
           guarantee that it's at least a pixel.
            if not, use mXHeight for both offsets
4. Gtk-FT2(including PS printing with FT2)
             would be the same as Gtk-Xft with my patch for bug 226288.
             At the moment without it, it always uses mXHeight for both
             offsets
5. PS module (non-FT2, type1), BeOS, Photon :
              always uses mXHeight for both offsets

6. MacOS :   mMaxAscent / 2 - 1 pixel for both offsets
7. OS/2  :   mXHeight for the superscript offset
             mXHeight / 3 for the subscript offset

It seems to me that falling back to what OS/2 is doing after trying to get the 
values from a font is about right. Using mXHeight for the subscript offset makes 
subscripts too far away from the baseline. We need to do some experiment.
(Assignee)

Comment 1

14 years ago
Created attachment 142252 [details] [diff] [review]
proposed patch

Setting the subscript offset to a third of 'xheigh' doesn't seem to be a good
idea. In this patch, I set it to a half of 'xheight'.
(Assignee)

Comment 2

14 years ago
Created attachment 142253 [details]
screenshots with and without attachment 142252 [details] [diff] [review]

The left shot was taken with Mozilla 1.6 and the right was with firebird trunk
build with the patch. The first three rows are identical because they're
truetype fonts and Xft builds read off the subscript offset from the OS2 table.
The bottom two are postscript type1 fonts and the fallback was taken. In the
left, the fallback is to set it to xheight. With the patch, it's set to a half
of xheight.

BTW, I found that the line height depends on the subscript offset, which is
unexpected.

Comment 3

14 years ago
> --- gfx/src/xlib/nsFontMetricsXlib.cpp	5 Feb 2004 01:57:06 -0000	
> 1.162
> +++ gfx/src/xlib/nsFontMetricsXlib.cpp	25 Feb 2004 13:18:48 -0000
> @@ -1979,15 +1979,15 @@ void nsFontMetricsXlib::RealizeFont()
>       mSuperscriptOffset = mXHeight;
>     }
> 
>     if (ft->subscript_y(val)) {
>       mSubscriptOffset = nscoord(PR_MAX(f, NSToIntRound(val * f)));
>     }
>     else {
>-     mSubscriptOffset = mXHeight;
>+     mSubscriptOffset = NSToCoordRound(mXHeight / 2.0);
>     }

What happened to [3], e.g. using the XA_* attributes (see X11 FT engine fixes in
http://bugs.xfree86.org/show_bug.cgi?id=1163 , too) for that purpose ?
(Assignee)

Comment 4

14 years ago
(In reply to comment #3)

> What happened to [3], e.g. using the XA_* attributes (see X11 FT engine fixes 

What does [3] refer to? 

Comment 5

14 years ago
(In reply to comment #4)
> (In reply to comment #3)
> 
> > What happened to [3], e.g. using the XA_* attributes (see X11 FT engine fixes 
> 
> What does [3] refer to? 

-- snip --
3. Gtk-X11(Xlib/Xprint included) : 
           try to get the value via X11 API (XA_*) if available.
           guarantee that it's at least a pixel.
            if not, use mXHeight for both offsets
-- snip --
(Assignee)

Comment 6

14 years ago
The following takes care of that case.

@@ -2096,15 +2096,15 @@ void nsFontMetricsXlib::RealizeFont()
     mSubscriptOffset = nscoord(PR_MAX(f, NSToIntRound(pr * f)));
 #ifdef REALLY_NOISY_FONTS
     printf("subscriptOffset=%d\n", mSubscriptOffset);
 #endif
   }
   else
   {
-    mSubscriptOffset = mXHeight;
+    mSubscriptOffset = NSToCoordRound(mXHeight / 2.0);

Comment 7

14 years ago
Jungshik Shin wrote:
> The following takes care of that case.
>
>   else
>   {
> -    mSubscriptOffset = mXHeight;
> +    mSubscriptOffset = NSToCoordRound(mXHeight / 2.0

Yeah, you're right... the code already uses the XA_*-attributes if available...
I did only look at the patch and not at the code itself... somehow I expected
something which actually adds some (more) XA_*-attribute related code.. :)

Comment 8

13 years ago
*** Bug 301819 has been marked as a duplicate of this bug. ***
QA Contact: ian → layout.fonts-and-text
I don't know the relationship between this bug and bug 225109, but I just made a rather long comment there that might be of interest: bug 225109 comment 14.
You need to log in before you can comment on or make changes to this bug.