[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] Bug with stringWidth on Retina
From:       Sergey Bylokhov <Sergey.Bylokhov () oracle ! com>
Date:       2013-09-13 9:43:34
Message-ID: 5232DE46.3060102 () oracle ! com
[Download RAW message or body]

Hi. Konstantin.
I guess this is a duplicate of
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8013569
which was fixed in jdk8. can you try and confirm this?
Thanks.
On 13.09.2013 5:14, Konstantin Bulenkov wrote:
> Hi everyone,
> 
> I've got a problem with the latest release of JDK7 (1.7.0_40-b43). Sometimes, \
> method FontMetrics.stringWidth(String) returns wrong values on Retina devices. I \
> wrote a small test demonstrating the problem: 
> import javax.swing.*;
> import java.awt.*;
> 
> public class TextWidthTest extends JFrame {
> public TextWidthTest() throws HeadlessException {
> super("Text Width Test in JDK 1.7.0_40");
> setDefaultCloseOperation(EXIT_ON_CLOSE);
> setSize(280, 40);
> final String str = "nnnnnnnnnnnnnnnnnnnn.txt";
> JComponent customComp = new JComponent() {
> @Override
> protected void paintComponent(Graphics g) {
> super.paintComponent(g);
> FontMetrics fm = getFontMetrics(getFont());
> g.setColor(Color.orange);
> g.fillRect(0, 0, fm.stringWidth(str), fm.getHeight());
> g.setColor(Color.blue);
> g.drawString(str, 0, fm.getHeight());
> }
> };
> Font font = new Font("Lucida Grande", Font.PLAIN, 12);
> customComp.setFont(font);
> getContentPane().add(customComp);
> setVisible(true);
> }
> 
> public static void main(String[] args) {
> new TextWidthTest();
> }
> }
> 
> I've attached some pictures here \
> http://bulenkov.com/2013/09/13/bug-with-stringwidth-in-jdk-1-7-0_40/ 
> Does anybody know any workaround or a fix for the problem?
> 
> Thanks
> 
> --
> Konstantin Bulenkov
> IntelliJ Platform Front-end Lead
> JetBrains
> http://twitter.com/bulenkov
> 


-- 
Best regards, Sergey.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic