|
1 /* |
|
2 * Copyright (c) 2003, 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 4935798 6521210 6901159 |
|
27 * @summary Tests that all family names that are reported in all locales |
|
28 * correspond to some font returned from getAllFonts(). |
|
29 * @run main LocaleFamilyNames |
|
30 */ |
|
31 import java.awt.*; |
|
32 import java.util.*; |
|
33 |
|
34 public class LocaleFamilyNames { |
|
35 public static void main(String[] args) throws Exception { |
|
36 |
|
37 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
38 |
|
39 Font[] all_fonts = ge.getAllFonts(); |
|
40 |
|
41 Locale[] all_locales = Locale.getAvailableLocales(); |
|
42 |
|
43 HashSet all_families = new HashSet(); |
|
44 for (int i=0; i<all_fonts.length; i++) { |
|
45 all_families.add(all_fonts[i].getFamily()); |
|
46 for (int j=0; j<all_locales.length;j++) { |
|
47 all_families.add(all_fonts[i].getFamily(all_locales[j])); |
|
48 } |
|
49 |
|
50 } |
|
51 |
|
52 |
|
53 for (int i=0; i<all_locales.length; i++) { |
|
54 String[] families_for_locale = |
|
55 ge.getAvailableFontFamilyNames(all_locales[i]); |
|
56 for (int j=0; j<families_for_locale.length; j++) { |
|
57 if ( !all_families.contains(families_for_locale[j]) ) { |
|
58 System.out.println("LOCALE: [" + all_locales[i]+"]"); |
|
59 System.out.print("NO FONT HAS " + |
|
60 "THE FOLLOWING FAMILY NAME:"); |
|
61 System.out.println("["+families_for_locale[j]+"]"); |
|
62 throw new Exception("test failed"); |
|
63 } |
|
64 } |
|
65 } |
|
66 } |
|
67 } |