jdk/test/java/awt/FontClass/CreateFont/CreateFontArrayTest.java
author prr
Fri, 01 Apr 2016 09:52:13 -0700
changeset 37547 440b85d574c8
parent 36899 e766024a0873
permissions -rw-r--r--
8153272: [pit] Tag @run requires "main" in java/awt/FontClass/CreateFont/CreateFontArrayTest.java Reviewed-by: yan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36899
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     1
/*
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     4
 *
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     8
 *
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    13
 * accompanied this code).
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    14
 *
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    18
 *
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    21
 * questions.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    22
 */
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    23
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    24
/*
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    25
 * @test
37547
440b85d574c8 8153272: [pit] Tag @run requires "main" in java/awt/FontClass/CreateFont/CreateFontArrayTest.java
prr
parents: 36899
diff changeset
    26
 * @bug 8055463 8153272
36899
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    27
 * @summary Test createFont APIs
37547
440b85d574c8 8153272: [pit] Tag @run requires "main" in java/awt/FontClass/CreateFont/CreateFontArrayTest.java
prr
parents: 36899
diff changeset
    28
 * @run main CreateFontArrayTest
36899
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    29
 */
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    30
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    31
import java.awt.Font;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    32
import java.io.BufferedInputStream;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    33
import java.io.File;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    34
import java.io.FileInputStream;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    35
import java.io.InputStream;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    36
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    37
/*
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    38
 * This test pokes around in platform folders/directories to try
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    39
 * to find some fonts with which to test. It will do different things
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    40
 * on different platforms and may not do anything at all if the platform
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    41
 * directories aren't where it expects. For example if /usr/share/fonts
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    42
 * is not used on a particular Linux distro or on Windows the fonts are
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    43
 * not in c:\windows\fonts (which would be the right place on 99.99% of
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    44
 * systems you will find today.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    45
 * It ought to be very reliable but it is not 100% guaranteed.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    46
 * Failure to find fonts to test is 'not a product bug'.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    47
 * Fonts on a system having different content than we expect based on
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    48
 * file extension is also 'not a product bug'.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    49
 * The former will cause silent success, the latter may cause 'noisy' failure
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    50
 * and the test would then need to be dialled back to be more cautious.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    51
 */
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    52
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    53
public class CreateFontArrayTest {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    54
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    55
    public static void main(String[] args) throws Exception {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    56
        test(".ttc", 2, -1, true);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    57
        test(".ttf", 1,  1, true);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    58
        test(".otf", 1,  1, true);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    59
        test(".pfa", 0,  0, false);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    60
        test(".pfb", 0,  0, false);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    61
    }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    62
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    63
    static File getPlatformFontFolder(String ext) throws Exception {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    64
        boolean recurse = false;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    65
        String folder = null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    66
        String os = System.getProperty("os.name");
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    67
        if (os.startsWith("Win")) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    68
            folder = "c:\\windows\\fonts";
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    69
        } else if (os.startsWith("Linux")) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    70
            folder = "/usr/share/fonts";
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    71
            recurse = true; // need to dig to find fonts.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    72
        } else if (os.startsWith("Mac")) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    73
            // Disabled until createFont can handle mac font names.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    74
            //folder = "/Library/Fonts";
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    75
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    76
        if (folder == null) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    77
            return null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    78
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    79
        File dir = new File(folder);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    80
        if (!dir.exists() || !dir.isDirectory()) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    81
            return null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    82
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    83
        // Have a root.
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    84
        if (!recurse) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    85
            return dir;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    86
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    87
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    88
        // If "recurse" is set, try to find a sub-folder which contains
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    89
        // fonts with the specified extension
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    90
        return findSubFolder(dir, ext);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    91
    }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    92
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    93
    static File findSubFolder(File folder, String ext) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    94
        File[] files =
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    95
            folder.listFiles(f -> f.getName().toLowerCase().endsWith(ext));
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    96
        if (files != null && files.length > 0) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    97
            return folder;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    98
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
    99
        File[] subdirs = folder.listFiles(f -> f.isDirectory());
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   100
        for (File f : subdirs) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   101
            File subfolder = findSubFolder(f, ext);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   102
            if (subfolder != null) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   103
                return subfolder;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   104
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   105
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   106
        return null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   107
    }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   108
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   109
    static void test(String ext, int min, int max,
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   110
                     boolean expectSuccess ) throws Exception {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   111
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   112
        File dir = getPlatformFontFolder(ext);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   113
        if (dir == null) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   114
            System.out.println("No folder to test for " + ext);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   115
            return;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   116
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   117
        File[] files =
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   118
            dir.listFiles(f -> f.getName().toLowerCase().endsWith(ext));
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   119
        if (files == null || files.length == 0) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   120
            System.out.println("No files to test for " + ext);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   121
            return;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   122
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   123
        System.out.println("Create from file " + files[0]);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   124
        Font[] fonts = null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   125
        try {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   126
            fonts = Font.createFonts(files[0]);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   127
            System.out.println("createFont from file returned " + fonts);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   128
        } catch (Exception e) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   129
            if (expectSuccess) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   130
                throw new RuntimeException("Unexpected exception", e);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   131
            } else {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   132
                System.out.println("Got expected exception " + e);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   133
                return;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   134
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   135
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   136
        for (Font f : fonts) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   137
            System.out.println(ext + " component : " + f);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   138
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   139
        if (fonts.length < min) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   140
            throw new RuntimeException("Expected at least " + min +
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   141
                                       " but got " + fonts.length);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   142
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   143
        if (max > 0 && fonts.length > max) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   144
            throw new RuntimeException("Expected no more than " + max +
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   145
                                       " but got " + fonts.length);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   146
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   147
        FileInputStream fis = null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   148
        try {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   149
            System.out.println("Create from stream " + files[0]);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   150
            fis = new FileInputStream(files[0]);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   151
            InputStream s = new BufferedInputStream(fis);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   152
            fonts = null;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   153
            try {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   154
                fonts = Font.createFonts(s);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   155
                System.out.println("createFont from stream returned " + fonts);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   156
            } catch (Exception e) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   157
                if (expectSuccess) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   158
                    throw new RuntimeException("Unexpected exception", e);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   159
                } else {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   160
                    System.out.println("Got expected exception " + e);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   161
                    return;
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   162
                }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   163
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   164
            for (Font f : fonts) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   165
                System.out.println(ext + " component : " + f);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   166
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   167
            if (fonts.length < min) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   168
                throw new RuntimeException("Expected at least " + min +
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   169
                                           " but got " + fonts.length);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   170
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   171
            if (max > 0 && fonts.length > max) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   172
                throw new RuntimeException("Expected no more than " + max +
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   173
                                           " but got " + fonts.length);
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   174
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   175
        } finally {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   176
            if (fis != null) {
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   177
                fis.close();
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   178
            }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   179
        }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   180
    }
e766024a0873 8055463: Need public API allowing full access to font collections in Font.createFont()
prr
parents:
diff changeset
   181
}