This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: xlib fix FontMetrics problems


The attached patch fixes problems with xlib FontMetrics.  There was an
out-and-out bug (getDescent returned the ascent) and some more subtle
problems.  The attached program draws lines to mark the ascent and descent,
as well as maxAscent and maxDescent.  It now looks pretty reasonable,
although not the same as with the Sun JRE (which is grossly different on
Win32 vs. linux!).  The getMaxAdvance and getLeading methods are still
wrong, even with the patch, but I'm not entirely sure what to do about that,
since unless I'm missing something the X font structure doesn't include
leading.  The fix for that would be in a different file anyway
(gnu/gcj/xlib/Font.java), so I may submit it as a separate patch.

The Sun javadoc says the getAscent and getDescent functions apply to "most
alphanumeric characters" and "most alphanumeric characters with descenders",
respectively.  I chose "O" and "y" as representative of these sets, and used
them to determine the values for ascent and descent, with a default value if
those characters aren't in the font.

Index: libjava/ChangeLog
from  Scott Gilbertson  <scottg@mantatest.com>

* gnu/gcj/xlib/natFont.cc (getMaxAscent): adjusted return value.
(getMaxDescent): adjusted return value.
(getAscent): modified to use metrics for 'O'.
(getDescent): modified to use metrics for 'y'.

patch is attached

Attachment: TestFontMetrics.java
Description: Binary data

Attachment: 20030606_XlibFontMetrics.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]