< prev index next >

test/jdk/java/awt/FontClass/CreateFont/BigFont.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 19,34 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! import java.applet.*; ! import java.awt.*; ! import java.io.*; ! import java.net.*; ! ! public class BigFont extends Applet { static private class SizedInputStream extends InputStream { int size; int cnt = 0; --- 19,45 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! import java.awt.Font; ! import java.awt.FontFormatException; ! import java.io.BufferedInputStream; ! import java.io.IOException; ! import java.io.InputStream; ! import java.net.URL; ! import java.nio.file.Paths; ! ! /** ! * @test ! * @key headful ! * @bug 6522586 ! * @summary Enforce limits on font creation ! * @run main BigFont 1 A.ttf ! * @run main BigFont 2 A.ttf ! */ ! public class BigFont { static private class SizedInputStream extends InputStream { int size; int cnt = 0;
*** 49,64 **** public int getCurrentSize() { return cnt; } } ! String id; ! String fileName; ! public void init() { ! id = getParameter("number"); ! fileName = getParameter("font"); System.out.println("Applet " + id + " "+ Thread.currentThread().getThreadGroup()); if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); --- 60,75 ---- public int getCurrentSize() { return cnt; } } ! static String id; ! static String fileName; ! public static void main(final String[] args) { ! id = args[0]; ! fileName = args[1]; System.out.println("Applet " + id + " "+ Thread.currentThread().getThreadGroup()); if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager());
*** 100,110 **** System.out.println("Applet " + id + " finished."); } int getFileSize(String fileName) { try { ! URL url = new URL(getCodeBase(), fileName); InputStream inStream = url.openStream(); BufferedInputStream fontStream = new BufferedInputStream(inStream); int size = 0; while (fontStream.read() != -1) { size++; --- 111,124 ---- System.out.println("Applet " + id + " finished."); } int getFileSize(String fileName) { try { ! String path = Paths.get(System.getProperty("test.src", "."), ! fileName).toAbsolutePath().normalize() ! .toString(); ! URL url = new URL(path); InputStream inStream = url.openStream(); BufferedInputStream fontStream = new BufferedInputStream(inStream); int size = 0; while (fontStream.read() != -1) { size++;
*** 121,131 **** Font[] fonts = new Font[fontCnt]; int totalSize = 0; boolean gotException = false; for (int i=0; i<fontCnt; i++) { try { ! URL url = new URL(getCodeBase(), fileName); InputStream inStream = url.openStream(); BufferedInputStream fontStream = new BufferedInputStream(inStream); fonts[i] = Font.createFont(Font.TRUETYPE_FONT, fontStream); totalSize += oneFont; --- 135,148 ---- Font[] fonts = new Font[fontCnt]; int totalSize = 0; boolean gotException = false; for (int i=0; i<fontCnt; i++) { try { ! String path = Paths.get(System.getProperty("test.src", "."), ! fileName).toAbsolutePath().normalize() ! .toString(); ! URL url = new URL(path); InputStream inStream = url.openStream(); BufferedInputStream fontStream = new BufferedInputStream(inStream); fonts[i] = Font.createFont(Font.TRUETYPE_FONT, fontStream); totalSize += oneFont;
< prev index next >