1 /* 2 * Copyright (c) 2018, 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 * @bug 8202696 26 * @summary Verifies if Phonetic extensions are getting displayed. 27 */ 28 29 import java.awt.Font; 30 import java.awt.GraphicsEnvironment; 31 import java.util.Locale; 32 33 public class PhoneticExtensionsGlyphTest { 34 private static final String[] logicalFonts = {"dialog", "dialoginput", "serif", "sansserif", "monospaced"}; 35 36 private static final String phoneticExtnChars = "\u1D00 \u1D01 \u1D02 \u1D03 \u1D04 \u1D05 \u1D06 \u1D07 \u1D08 \u1D09\n" 37 +"\u1D0A \u1D0B \u1D0C \u1D0D \u1D0E \u1D0F \u1D10 \u1D11 \u1D12 \u1D13\n" 38 +"\u1D14 \u1D15 \u1D16 \u1D17 \u1D18 \u1D19 \u1D1A \u1D1B \u1D1C \u1D1D\n" 39 +"\u1D1E \u1D1F \u1D20 \u1D21 \u1D22 \u1D23 \u1D24 \u1D25 \u1D26 \u1D27\n" 40 +"\u1D28 \u1D29 \u1D2A \u1D2B \u1D2C \u1D2D \u1D2E \u1D2F \u1D30 \u1D31\n" 41 +"\u1D32 \u1D33 \u1D34 \u1D35 \u1D36 \u1D37 \u1D38 \u1D39 \u1D3A \u1D3B\n" 42 +"\u1D3C \u1D3D \u1D3E \u1D3F \u1D40 \u1D41 \u1D42 \u1D43 \u1D44 \u1D45\n" 43 +"\u1D46 \u1D47 \u1D48 \u1D49 \u1D4A \u1D4B \u1D4C \u1D4D \u1D4E \u1D4F\n" 44 +"\u1D50 \u1D51 \u1D52 \u1D53 \u1D54 \u1D55 \u1D56 \u1D57 \u1D58 \u1D59\n" 45 +"\u1D5A \u1D5B \u1D5C \u1D5D \u1D5E \u1D5F \u1D60 \u1D61 \u1D62 \u1D63\n" 46 +"\u1D64 \u1D65 \u1D66 \u1D67 \u1D68 \u1D69 \u1D6A \u1D6B \u1D6C \u1D6D\n" 47 +"\u1D6E \u1D6F \u1D70 \u1D71 \u1D72 \u1D73 \u1D74 \u1D75 \u1D76 \u1D77\n" 48 +"\u1D78 \u1D79 \u1D7A \u1D7B \u1D7C \u1D7D \u1D7E \u1D7F"; 49 50 public static void main(String[] args) throws Exception { 51 if (!System.getProperty("os.name").startsWith("Win")) { 52 return; 53 } 54 55 if(!canDisplayPhoneticChars()) { 56 throw new RuntimeException("Phonetic extensions failed to display."); 57 } 58 } 59 60 private static boolean isLogicalFont(Font f) { 61 String fontName = f.getFamily().toLowerCase(Locale.ROOT); 62 for (int i = 0; i < logicalFonts.length; i++) { 63 if (logicalFonts[i].equals(fontName)) { 64 return true; 65 } 66 } 67 return false; 68 } 69 70 private static boolean canDisplayPhoneticChars() { 71 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 72 Font[] fonts = ge.getAllFonts(); 73 boolean ret = false; 74 for (Font font : fonts) { 75 if (isLogicalFont(font) && font.canDisplayUpTo(phoneticExtnChars) == -1) { 76 ret = true; 77 break; 78 } 79 } 80 return ret; 81 } 82 }