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 25 /* @test 26 * @summary verify rendering of MORX fonts on OS X. 27 * @bug 8031462 28 */ 29 30 import javax.swing.*; 31 import javax.swing.border.LineBorder; 32 import java.awt.*; 33 import java.awt.event.ActionEvent; 34 35 public class TestAATMorxFont extends JComponent { 36 public static void main(String[] args) { 37 String osName = System.getProperty("os.name"); 38 System.out.println("OS is " + osName); 39 osName = osName.toLowerCase(); 40 if (!osName.startsWith("mac")) { 41 return; 42 } 43 SwingUtilities.invokeLater(new Runnable() { 44 public void run() { 45 JFrame frame = new JFrame("Test Morx"); 46 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 47 TestAATMorxFont panel = new TestAATMorxFont(); 48 frame.add(panel); 49 frame.pack(); 50 frame.setVisible(true); 51 } 52 }); 53 } 54 55 public Dimension getPreferredSize() { 56 return new Dimension(1200, 400); 57 } 58 59 public void paintComponent(Graphics g) { 60 Graphics2D g2d = (Graphics2D)g; 61 g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 62 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 63 int y = 50; 64 g.setFont(new Font("Gujarati MT", Font.PLAIN, 40)); 65 System.out.println(g.getFont()); 66 g.drawString("\u0A95\u0ACD \u0A95\u0A95\u0A95 \u0A95\u0ACD\u0A95\u0ACD\u0A95", 20, y); 67 y += 50; 68 g.setFont(new Font("Tamil Sangam MN", Font.PLAIN, 40)); 69 System.out.println(g.getFont()); 70 g.drawString("\u0b95\u0bCD \u0b95\u0b95\u0b95 \u0b95\u0bCD\u0b95\u0bCD\u0b95", 20, y); 71 y += 50; 72 g.setFont(new Font("Telugu Sangam MN", Font.PLAIN, 40)); 73 System.out.println(g.getFont()); 74 g.drawString("\u0c15\u0c4D \u0c15\u0c15\u0c15 \u0c15\u0c4D\u0c15\u0c4D\u0c15", 20, y); 75 y += 50; 76 g.setFont(new Font("Devanagari Sangam MN", Font.PLAIN, 40)); 77 System.out.println(g.getFont()); 78 g.drawString("\u0915\u0940 \u0915\u0947 \u0915\u0942", 20, y); 79 y += 50; 80 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); 81 y += 50; 82 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); 83 84 } 85 } 86