1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @summary verify rendering of MORX fonts on OS X. 26 * @bug 8031462 27 */ 28 29 import javax.swing.*; 30 import javax.swing.border.LineBorder; 31 import java.awt.*; 32 import java.awt.event.ActionEvent; 33 34 public class TestAATMorxFont extends JComponent { 35 public static void main(String[] args) { 36 String osName = System.getProperty("os.name"); 37 System.out.println("OS is " + osName); 38 osName = osName.toLowerCase(); 39 if (!osName.startsWith("mac")) { 40 return; 41 } 42 SwingUtilities.invokeLater(new Runnable() { 43 public void run() { 44 JFrame frame = new JFrame("Test Morx"); 45 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 46 TestAATMorxFont panel = new TestAATMorxFont(); 47 frame.add(panel); 48 frame.pack(); 49 frame.setVisible(true); 50 } 51 }); 52 } 53 54 public Dimension getPreferredSize() { 55 return new Dimension(1200, 400); 56 } 57 58 public void paintComponent(Graphics g) { 59 Graphics2D g2d = (Graphics2D)g; 60 g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 61 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 62 int y = 50; 63 g.setFont(new Font("Gujarati MT", Font.PLAIN, 40)); 64 System.out.println(g.getFont()); 65 g.drawString("\u0A95\u0ACD \u0A95\u0A95\u0A95 \u0A95\u0ACD\u0A95\u0ACD\u0A95", 20, y); 66 y += 50; 67 g.setFont(new Font("Tamil Sangam MN", Font.PLAIN, 40)); 68 System.out.println(g.getFont()); 69 g.drawString("\u0b95\u0bCD \u0b95\u0b95\u0b95 \u0b95\u0bCD\u0b95\u0bCD\u0b95", 20, y); 70 y += 50; 71 g.setFont(new Font("Telugu Sangam MN", Font.PLAIN, 40)); 72 System.out.println(g.getFont()); 73 g.drawString("\u0c15\u0c4D \u0c15\u0c15\u0c15 \u0c15\u0c4D\u0c15\u0c4D\u0c15", 20, y); 74 y += 50; 75 g.setFont(new Font("Devanagari Sangam MN", Font.PLAIN, 40)); 76 System.out.println(g.getFont()); 77 g.drawString("\u0915\u0940 \u0915\u0947 \u0915\u0942", 20, y); 78 y += 50; 79 g.drawString("\u0907\u0930\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915", 20, y); 80 y += 50; 81 g.drawString("\u0930\u093F\u0935\u094D\u092F\u0942 \u0915\u0947 \u092C\u093E\u0926 \u0935\u093F\u0915\u093E\u0938 \u0913\u0932\u0902\u092A\u093F\u0915 \u0938\u0947 \u092C\u093E\u0939\u0930 (\u0926\u0947\u0935\u0928\u093E\u0917\u0930\u0940) (\u0939\u093F\u0928\u094D\u0926\u0940) \u0907\u0930\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915\u094D\u0915", 20, y); 82 83 } 84 } 85