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 * @bug 8043509 27 * @summary Test locale famlly falls back to same language before English 28 * @run main/othervm TrueTypeFontLocaleNameTest 29 */ 30 31 import java.awt.Font; 32 import java.util.Locale; 33 34 public class TrueTypeFontLocaleNameTest { 35 36 public static void main(String[] args) { 37 38 String os = System.getProperty("os.name", ""); 39 if (!os.toLowerCase().startsWith("win")) { 40 return; 41 } 42 System.setProperty("user.language", "de"); 43 System.setProperty("user.country", "AT"); 44 Locale de_atLocale = new Locale("de", "AT"); 45 Locale.setDefault(de_atLocale); 46 47 String family = "Verdana"; 48 Font font = new Font(family, Font.BOLD, 12); 49 if (!font.getFamily(Locale.ENGLISH).equals(family)) { 50 System.out.println(family + " not found - skipping test."); 51 return; 52 } 53 54 String atFontName = font.getFontName(); 55 Locale deGELocale = new Locale("de", "GE"); 56 String deFontName = font.getFontName(deGELocale); 57 System.out.println("Austrian font name: " + atFontName); 58 System.out.println("German font name: " + deFontName); 59 60 String deLangFullName = "Verdana Fett"; 61 // We expect "Fett" for "Bold" when the language is German. 62 // This font does have that so these should both be equal and 63 // say "Verdana Fett" 64 if (!deFontName.equals(atFontName)) { 65 throw new RuntimeException("Font names differ " + 66 deFontName + " " + atFontName); 67 } 68 if (!deLangFullName.equals(deFontName)) { 69 throw new RuntimeException("Font name is not " + deLangFullName + 70 " instead got " + deFontName); 71 } 72 } 73 }