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