JDK-4486745 : java : win32 Java2 fontmetrics fix caused difference from 1.1.8 platform metrics
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.3.1,1.3.1_02
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2001-08-01
  • Updated: 2002-05-16
  • Resolved: 2001-08-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.3.1_02 02Fixed 1.4.0Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
There is an incompatibility issue between JDK1.1.X and Java2.(JDK1.2.X, JDK1.3.X
and JDK1.4)

The attached program(Test01.java) measures the fonts' width, height, 
max advance.You can see each different value return from java API.

Some java application uses the above return value as size of awt(swing)
components.
So the view of application based on JDK1.1.8 changes with Java2
like attached image(view)

1. Reproduce

 1) Compile the attached program, Test01.java
 2) Invoke the program.
   -> You can see a dialogue
 3) Click the button in the above dialogue
   -> You can see some messgage in MS-DOS console as follows.

FONT Name,FONT Size,FONT Style,MaxAdvance,Ascent,Descent,Leading,'m' Width,'M' W
idth,"Mm" Width,"Mm��������" Width
Serif,12,0,20,13,3,1,9,12,21,45,
Sans-serif,12,0,20,12,3,0,11,10,21,39,
Monospaced,12,0,20,13,4,0,6,6,12,36,
Dialog,12,0,20,13,3,0,11,9,20,44,
DialogInput,12,0,20,13,4,0,7,7,14,38,
Serif,12,1,20,13,3,1,10,11,21,46,
Sans-serif,12,1,20,12,3,0,12,11,23,43,
Monospaced,12,1,20,13,4,0,7,7,13,39,
Dialog,12,1,20,13,3,0,11,10,21,46,
DialogInput,12,1,20,13,4,0,7,7,14,39,
Serif,12,2,20,13,3,1,9,10,19,43,
Sans-serif,12,2,20,12,3,0,11,10,21,39,
Monospaced,12,2,20,13,4,0,6,6,12,36,
Dialog,12,2,20,13,3,0,11,9,20,44,
DialogInput,12,2,20,13,4,0,7,7,14,38,

 4) Invoke the step 1) program with 1.1.8 and 1.3.0fcs.

2. Configration 
  
  This happens on any verion of windows(98/NT/2k).

3. Attatchments

  - Test01.java      : Test program to measure fonts' information
  - Fontsize-eng.xls : Summary of the result with each jdk

  - yoko.tar         : Test program to show the different view
  - width118.bmp     : the result view witj JDK118 (Correct example)
  - width130.bmp     : the result view witj JDK130 (incorrect example)

4. Note
  
 The attached programs can not be compiled without some user libraries.
 However, that is big size library. 
 So, I do not attach the library and send that later.

================================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_02 merlin-beta2 FIXED IN: 1.3.1_02 merlin-beta2 INTEGRATED IN: 1.3.1_02 merlin-beta2
14-06-2004

WORK AROUND There is a property as workaround against this issue with Java2. Please specify when invoking java commnad as follwos. java -Djava2d.font.usePlatformFont=true testclass "-Djava2d.font.usePlatformFont=true" does not seem available for all the fonts and platforms. ============================================================================
11-06-2004

SUGGESTED FIX A composite font's maxAdvance should be calculated as the maximum from amongst its components. But in awt_Font.cpp in 1.2 & 1.3 this code :- // Get font metrics on remaining fonts (if multifont). for (int j = 1; j < awtFont->GetHFontNum(); j++) { ... env->SetIntField(fontMetrics, AwtFont::maxAdvanceID, (maxAdvance, metrics.tmMaxCharWidth)); } +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ should actually look like this :- // Get font metrics on remaining fonts (if multifont). for (int j = 1; j < awtFont->GetHFontNum(); j++) { ... env->SetIntField(fontMetrics, AwtFont::maxAdvanceID, maxAdvance = max(maxAdvance, metrics.tmMaxCharWidth)); ^^^^^^^^^^^^ } Otherwise if some intermediate component of the font was the largest the final returned value would be wrong. This fix was implemented in 1.4 beta2 phil.race@eng 2001-08-01 ========================
01-08-2001

EVALUATION 1.1.8 was fundamentally buggy. It represented the maximum width of characters in the font as being maximum advance. Java 2 (V 1.2) fixed this bug to the advantage of most applications as text can now be accurately measured. But applications which were written in a way that depended on the precise values reported on a particular platform to perform UI layout were surprised by the change. This is a bug in the application as UIs should always be constructed to be responsive to the environment in which they are displayed (platform, toolkit, locale etc.. ). Thus this is strictly "not a bug" as for example it makes no sense for a Java app written to Java APIs to be dependent on a platform font. Historically in 1.2 a unsupported workaround for such buggy applications was to enable platform fonts. This is extremely inadvisable as it uses a private implementation property which was intended for debugging purposes only and should not be used by applications. However this was still not producing exactly comparable results as 1.1.8 The reasons for this was a minor bug that meant that only the last or the first component of a composite font would be used in the calculation of the maximum advance of the font. A recent change in 1.4 (merlin) fixed that, so this bug to the extent that this behaviour is supported (its not) is now fixed. phil.race@eng 2001-07-31 ========================
31-07-2001