Closed Bug 227452 Opened 21 years ago Closed 6 months ago

super/subscript offset : platform parity

Categories

(Core :: Layout: Text and Fonts, defect)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jshin1987, Unassigned)

References

Details

Attachments

(2 files)

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.
Attached patch proposed patchSplinter Review
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'.
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.
> --- 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 ?
(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? 
(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 --
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);
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.. :)
*** 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.

The bug assignee didn't login in Bugzilla in the last 7 months.
:jfkthame, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: jshin1987 → nobody
Flags: needinfo?(jfkthame)
Severity: normal → S3

Sub- and superscripts are now handled by gfxFontStyle::AdjustForSubSuperscript using constant factors that are uniform across platforms, so I think we can close this as WFM.

Status: NEW → RESOLVED
Closed: 6 months ago
Flags: needinfo?(jfkthame)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: