6009N/A/*
6009N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
6009N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6009N/A *
6009N/A * This code is free software; you can redistribute it and/or modify it
6009N/A * under the terms of the GNU General Public License version 2 only, as
6009N/A * published by the Free Software Foundation.
6009N/A *
6009N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6009N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6009N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6009N/A * version 2 for more details (a copy is included in the LICENSE file that
6009N/A * accompanied this code).
6009N/A *
6009N/A * You should have received a copy of the GNU General Public License version
6009N/A * 2 along with this work; if not, write to the Free Software Foundation,
6009N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6009N/A *
6009N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6009N/A * or visit www.oracle.com if you need additional information or have any
6009N/A * questions.
6009N/A */
6009N/A
6009N/A/* @test
6009N/A * @summary Test Kerning is working.
6009N/A * @bug 8009530
6009N/A */
6009N/A
6009N/Aimport java.applet.*;
6009N/Aimport java.awt.*;
6009N/Aimport java.awt.event.*;
6009N/Aimport java.awt.font.*;
6009N/Aimport java.util.Map;
6009N/Aimport java.util.HashMap;
6009N/Aimport java.util.Locale;
6009N/A
6009N/Apublic class TestKerning extends Applet {
6009N/A private Panel panel;
6009N/A
6009N/A static public void main(String[] args) {
6009N/ASystem.out.println(System.getProperty("os.name"));
6009N/A
6009N/A Applet test = new TestKerning();
6009N/A test.init();
6009N/A test.start();
6009N/A
6009N/A Frame f = new Frame("Test Kerning");
6009N/A f.addWindowListener(new WindowAdapter() {
6009N/A public void windowClosing(WindowEvent e) {
6009N/A System.exit(0);
6009N/A }
6009N/A });
6009N/A f.add("Center", test);
6009N/A f.pack();
6009N/A f.setVisible(true);
6009N/A }
6009N/A
6009N/A public Dimension getPreferredSize() {
6009N/A return new Dimension(500, 200);
6009N/A }
6009N/A
6009N/A public Dimension getMaximumSize() {
6009N/A return getPreferredSize();
6009N/A }
6009N/A
6009N/A private static final String testString = "To WAVA 1,45 office glyph.";
6009N/A
6009N/A public void paint(Graphics g) {
6009N/A Graphics2D g2d = (Graphics2D)g;
6009N/A Font f = new Font("Arial", Font.PLAIN, 36);
6009N/A // testing Arial on Solaris.
6009N/A if (!("SunOS".equals(System.getProperty("os.name")))) {
6009N/A return;
6009N/A }
6009N/A if (!("Arial".equals(f.getFamily(Locale.ENGLISH)))) {
6009N/A return;
6009N/A }
6009N/A Map m = new HashMap();
6009N/A m.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
6009N/A Font kf = f.deriveFont(m);
6009N/A g.setFont(f);
6009N/A FontMetrics fm1 = g.getFontMetrics();
6009N/A int sw1 = fm1.stringWidth(testString);
6009N/A g.drawString(testString, 10, 50);
6009N/A g.setFont(kf);
6009N/A FontMetrics fm2 = g.getFontMetrics();
6009N/A int sw2 = fm2.stringWidth(testString);
6009N/A g.drawString(testString, 10, 90);
6009N/A if (sw1 == sw2) {
6009N/A System.out.println(sw1+" " + sw2);
6009N/A throw new RuntimeException("No kerning");
6009N/A }
6009N/A }
6009N/A}