22 package com.realtime.crossfire.jxclient.skin.io;
26 import java.awt.FontFormatException;
27 import java.io.IOException;
28 import java.io.InputStream;
29 import org.jetbrains.annotations.NotNull;
58 public Font
getFont(@NotNull
final String name)
throws IOException {
59 final String filename =
"fonts/"+name+
".ttf";
63 try (
final InputStream ttf = skinSource.
getInputStream(filename)) {
65 font = Font.createFont(Font.TRUETYPE_FONT, ttf);
66 }
catch (
final FontFormatException ex) {
67 throw new IOException(filename+
": invalid font format: "+ex.getMessage(), ex);
70 }
catch (
final IOException ex) {
71 throw new IOException(skinSource.
getURI(filename)+
": i/o error: "+ex.getMessage(), ex);
FontParser(@NotNull final JXCSkinSource skinSource)
Creates a new instance.
String getURI(@NotNull String name)
Returns a description of the location of a resource name.
InputStream getInputStream(@NotNull String name)
Returns an InputStream for a resource name.
Creates Font instances from string representations.
Font getFont(@NotNull final String name)
Returns a font by font file base name.
Interface for providers of JXCSkin sources.
final JXCSkinSource skinSource
The JXCSkinSource for loading resources.