3361N/A/*
3909N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
3361N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3361N/A *
3361N/A * This code is free software; you can redistribute it and/or modify it
3361N/A * under the terms of the GNU General Public License version 2 only, as
3361N/A * published by the Free Software Foundation.
3361N/A *
3361N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3361N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3361N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3361N/A * version 2 for more details (a copy is included in the LICENSE file that
3361N/A * accompanied this code).
3361N/A *
3361N/A * You should have received a copy of the GNU General Public License version
3361N/A * 2 along with this work; if not, write to the Free Software Foundation,
3361N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3361N/A *
3361N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3361N/A * or visit www.oracle.com if you need additional information or have any
3361N/A * questions.
3361N/A */
3361N/A
3361N/A/*
3361N/A * @test
3361N/A * @bug 4935798 6521210 6901159
3361N/A * @summary Tests that all family names that are reported in all locales
3361N/A * correspond to some font returned from getAllFonts().
3361N/A * @run main LocaleFamilyNames
3361N/A */
3361N/Aimport java.awt.*;
3361N/Aimport java.util.*;
3361N/A
3361N/Apublic class LocaleFamilyNames {
3361N/A public static void main(String[] args) throws Exception {
3361N/A
3361N/A GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
3361N/A
3361N/A Font[] all_fonts = ge.getAllFonts();
3361N/A
3361N/A Locale[] all_locales = Locale.getAvailableLocales();
3361N/A
3361N/A HashSet all_families = new HashSet();
3361N/A for (int i=0; i<all_fonts.length; i++) {
3361N/A all_families.add(all_fonts[i].getFamily());
3361N/A for (int j=0; j<all_locales.length;j++) {
3361N/A all_families.add(all_fonts[i].getFamily(all_locales[j]));
3361N/A }
3361N/A
3361N/A }
3361N/A
3361N/A
3361N/A for (int i=0; i<all_locales.length; i++) {
3361N/A String[] families_for_locale =
3361N/A ge.getAvailableFontFamilyNames(all_locales[i]);
3361N/A for (int j=0; j<families_for_locale.length; j++) {
3361N/A if ( !all_families.contains(families_for_locale[j]) ) {
3361N/A System.out.println("LOCALE: [" + all_locales[i]+"]");
3361N/A System.out.print("NO FONT HAS " +
3361N/A "THE FOLLOWING FAMILY NAME:");
3361N/A System.out.println("["+families_for_locale[j]+"]");
3361N/A throw new Exception("test failed");
3361N/A }
3361N/A }
3361N/A }
3361N/A }
3361N/A}