3349N/A/*
3909N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
3349N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3349N/A *
3349N/A * This code is free software; you can redistribute it and/or modify it
3349N/A * under the terms of the GNU General Public License version 2 only, as
3349N/A * published by the Free Software Foundation.
3349N/A *
3349N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3349N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3349N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3349N/A * version 2 for more details (a copy is included in the LICENSE file that
3349N/A * accompanied this code).
3349N/A *
3349N/A * You should have received a copy of the GNU General Public License version
3349N/A * 2 along with this work; if not, write to the Free Software Foundation,
3349N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3349N/A *
3349N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3349N/A * or visit www.oracle.com if you need additional information or have any
3349N/A * questions.
3349N/A */
3349N/A
3349N/A/*
3349N/A *
3349N/A * @bug 6925760
3349N/A * @summary Scaled graphics causes overlapped LCD glyphs on Windows
3349N/A */
3349N/A
3349N/Aimport java.awt.*;
3349N/Aimport java.awt.font.*;
3349N/Aimport java.awt.geom.*;
3349N/A
3349N/Apublic class LCDScale extends Component {
3349N/A
3349N/A public static void main(String args[]) {
3349N/A Frame f = new Frame("TL TEST");
3349N/A LCDScale td = new LCDScale();
3349N/A f.add("Center", td);
3349N/A f.pack(); f.setVisible(true);
3349N/A }
3349N/A
3349N/A
3349N/A public LCDScale() {
3349N/A super();
3349N/A }
3349N/A
3349N/A public Dimension getPreferredSize() {
3349N/A return new Dimension(500,500);
3349N/A }
3349N/A
3349N/A public void paint(Graphics g) {
3349N/A Graphics2D g2d = (Graphics2D)g;
3349N/A g2d.setRenderingHint(
3349N/A RenderingHints.KEY_TEXT_ANTIALIASING,
3349N/A RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
3349N/A
3349N/A Font f = new Font("Dialog", Font.PLAIN, 40);
3349N/A g.setFont(f);
3349N/A FontRenderContext frc = g2d.getFontRenderContext();
3349N/A GlyphVector gv = f.createGlyphVector(frc, "Help");
3349N/A g2d.drawGlyphVector(gv, 10f, 50f);
3349N/A Rectangle2D bds1 = gv.getLogicalBounds();
3349N/A
3349N/A f = new Font("Arial", Font.PLAIN, 25);
3349N/A g.setFont(f);
3349N/A double s = 2.0;
3349N/A AffineTransform tx = AffineTransform.getScaleInstance(s,s);
3349N/A g2d.transform(tx);
3349N/A frc = g2d.getFontRenderContext();
3349N/A gv = f.createGlyphVector(frc, "Help");
3349N/A g2d.drawGlyphVector(gv, 10f, 100f);
3349N/A Rectangle2D bds2 = gv.getLogicalBounds();
3349N/A
3349N/A System.out.println(bds1);
3349N/A System.out.println(bds2);
3349N/A if (bds2.getWidth()*s < bds1.getWidth()) {
3349N/A throw new RuntimeException("Bounds too small");
3349N/A }
3349N/A }
3349N/A}
3349N/A
3349N/A