1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 /* @test @(#)TestVS.java 25 * @summary Verify Variation Selector matches an expected image 26 * @bug 8187100 27 * @ignore Requires a special font installed. 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 TestVS { 36 public static void main(String[] args) { 37 SwingUtilities.invokeLater(new Runnable() { 38 public void run() { 39 new TestVS().run(); 40 } 41 }); 42 } 43 44 private void run() { 45 Font ourFont = null; 46 final String fontName = "ipaexm.ttf"; // download from https://ipafont.ipa.go.jp/node26#en and place in {user.home}/fonts/ 47 try { 48 ourFont = Font.createFont(Font.TRUETYPE_FONT, new java.io.File(new java.io.File(System.getProperty("user.home"),"fonts"), fontName)); 49 ourFont = ourFont.deriveFont((float)48.0); 50 } catch(Throwable t) { 51 t.printStackTrace(); 52 System.err.println("Fail: " + t); 53 return; 54 } 55 JFrame frame = new JFrame(System.getProperty("java.version")); 56 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 57 JPanel panel = new JPanel(); 58 final JTextArea label = new JTextArea("empty"); 59 label.setSize(400, 300); 60 label.setBorder(new LineBorder(Color.black)); 61 label.setFont(ourFont); 62 63 final String str = "\u845b\udb40\udd00\u845b\udb40\udd01\n"; 64 65 label.setText(str); 66 67 panel.add(label); 68 panel.add(new JLabel(ourFont.getFamily())); 69 70 // Show the expected result. 71 panel.add(new JLabel(new ImageIcon("TestVS-expect.png"))); 72 73 frame.getContentPane().add(panel); 74 frame.pack(); 75 frame.setVisible(true); 76 } 77 } 78