6371N/A/*
6371N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6371N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6371N/A *
6371N/A * This code is free software; you can redistribute it and/or modify it
6371N/A * under the terms of the GNU General Public License version 2 only, as
6371N/A * published by the Free Software Foundation.
6371N/A *
6371N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6371N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6371N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6371N/A * version 2 for more details (a copy is included in the LICENSE file that
6371N/A * accompanied this code).
6371N/A *
6371N/A * You should have received a copy of the GNU General Public License version
6371N/A * 2 along with this work; if not, write to the Free Software Foundation,
6371N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6371N/A *
6371N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6371N/A * or visit www.oracle.com if you need additional information or have any
6371N/A * questions.
6371N/A */
6371N/A
6371N/A/*
6371N/A * @test
6371N/A * @bug 8012617
6371N/A * @summary ArrayIndexOutOfBoundsException in LineBreakMeasurer
6371N/A */
6371N/A
6371N/Aimport java.awt.*;
6371N/Aimport java.awt.image.*;
6371N/Aimport java.awt.font.*;
6371N/Aimport java.awt.geom.*;
6371N/Aimport java.text.*;
6371N/Aimport java.util.Hashtable;
6371N/A
6371N/Apublic class AllFontsLBM {
6371N/A
6371N/A public static void main(String[] args) {
6371N/A Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
6371N/A for (int i=0;i<allFonts.length; i++) {
6371N/A try {
6371N/A Font f = allFonts[i].deriveFont(Font.PLAIN, 20);
6371N/A
6371N/A if ( f.getFontName().startsWith("HiraKaku") ) {
6371N/A continue;
6371N/A }
6371N/A
6371N/A System.out.println("Try : " + f.getFontName());
6371N/A System.out.flush();
6371N/A breakLines(f);
6371N/A } catch (Exception e) {
6371N/A System.out.println(allFonts[i]);
6371N/A }
6371N/A }
6371N/A }
6371N/A
6371N/A static void breakLines(Font font) {
6371N/A AttributedString vanGogh = new AttributedString(
6371N/A "Many people believe that Vincent van Gogh painted his best works " +
6371N/A "during the two-year period he spent in Provence. Here is where he " +
6371N/A "painted The Starry Night--which some consider to be his greatest " +
6371N/A "work of all. However, as his artistic brilliance reached new " +
6371N/A "heights in Provence, his physical and mental health plummeted. ",
6371N/A new Hashtable());
6371N/A vanGogh.addAttribute(TextAttribute.FONT, font);
6371N/A BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
6371N/A Graphics2D g2d = bi.createGraphics();
6371N/A AttributedCharacterIterator aci = vanGogh.getIterator();
6371N/A FontRenderContext frc = new FontRenderContext(null, false, false);
6371N/A LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
6371N/A lbm.setPosition(aci.getBeginIndex());
6371N/A while (lbm.getPosition() < aci.getEndIndex()) {
6371N/A lbm.nextLayout(100f);
6371N/A }
6371N/A
6371N/A }
6371N/A}