/* * Copyright (c) 2007, 2015, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * 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.
*/
/* * @test * @summary Check that Font constructors and methods do not throw * unexpected exceptions in headless mode * @run main/othervm -Djava.awt.headless=true HeadlessFont
*/
for (String font : Toolkit.getDefaultToolkit().getFontList()) { for (int i = 8; i < 17; i++) {
Font f1 = new Font(font, Font.PLAIN, i);
Font f2 = new Font(font, Font.BOLD, i);
Font f3 = new Font(font, Font.ITALIC, i);
Font f4 = new Font(font, Font.BOLD | Font.ITALIC, i);
int s;
s = f1.getStyle();
s = f2.getStyle();
s = f3.getStyle();
s = f4.getStyle();
s = f1.getSize();
s = f2.getSize();
s = f3.getSize();
s = f4.getSize();
s = f1.hashCode();
s = f2.hashCode();
s = f3.hashCode();
s = f4.hashCode();
s = f1.getNumGlyphs();
s = f2.getNumGlyphs();
s = f3.getNumGlyphs();
s = f4.getNumGlyphs();
s = f1.getMissingGlyphCode();
s = f2.getMissingGlyphCode();
s = f3.getMissingGlyphCode();
s = f4.getMissingGlyphCode();
float f;
f = f1.getSize2D();
f = f2.getSize2D();
f = f3.getSize2D();
f = f4.getSize2D();
byte b;
b = f1.getBaselineFor('c');
b = f2.getBaselineFor('c');
b = f3.getBaselineFor('c');
b = f4.getBaselineFor('c');
Map m = f1.getAttributes();
m = f2.getAttributes();
m = f3.getAttributes();
m = f4.getAttributes();
AttributedCharacterIterator.Attribute[] a;
a = f1.getAvailableAttributes();
a = f2.getAvailableAttributes();
a = f3.getAvailableAttributes();
a = f4.getAvailableAttributes();
if (!f1.isPlain()) thrownew RuntimeException("Plain font " + f1.getName() + " says it's not plain"); if (f2.isPlain()) thrownew RuntimeException("Bold font " + f1.getName() + " says it is plain"); if (f3.isPlain()) thrownew RuntimeException("Italic font " + f1.getName() + " says it is plain"); if (f4.isPlain()) thrownew RuntimeException("Bold|Italic font " + f1.getName() + " says it is plain");
if (f1.isBold()) thrownew RuntimeException("Plain font " + f1.getName() + " says it is bold"); if (!f2.isBold()) thrownew RuntimeException("Bold font " + f1.getName() + " says it's not bold"); if (f3.isBold()) thrownew RuntimeException("Italic font " + f1.getName() + " says it is bold"); if (!f4.isBold()) thrownew RuntimeException("Bold|Italic font " + f1.getName() + " says it's not bold");
if (f1.isItalic()) thrownew RuntimeException("Plain font " + f1.getName() + " says it is italic"); if (f2.isItalic()) thrownew RuntimeException("Bold font " + f1.getName() + " says it is italic"); if (!f3.isItalic()) thrownew RuntimeException("Italic font " + f1.getName() + " says it's not italic"); if (!f4.isItalic()) thrownew RuntimeException("Bold|Italic font " + f1.getName() + " says it's not italic");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.