Update CardBuilder to use MagicFont.
parent
41ee81b93c
commit
c95fd5d53b
|
@ -1,13 +1,8 @@
|
|||
package magic.cardBuilder;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import magic.ui.helpers.ImageHelper;
|
||||
|
@ -235,39 +230,12 @@ public class ResourceManager {
|
|||
public static final BufferedImage tokenImageMaskSmall = getComponent("token/imagemask2.png");
|
||||
public static final BufferedImage tokenImageMaskLarge = getComponent("token/imagemask.png");
|
||||
|
||||
//Font Map
|
||||
private static final String[] names = {};
|
||||
private static final Map<String, Font> fontCache = new ConcurrentHashMap<>(names.length);
|
||||
private static final String FRAMES_FOLDER = "/cardbuilder/frames/";
|
||||
|
||||
static {
|
||||
for (String name : names) {
|
||||
fontCache.put(name, getFont(name));
|
||||
}
|
||||
}
|
||||
|
||||
private static InputStream getJarResourceStream(String filename) {
|
||||
return instance.getClass().getResourceAsStream(filename);
|
||||
}
|
||||
|
||||
public static Font getFont(String name) {
|
||||
Font font = fontCache.get(name);
|
||||
if (font != null) {
|
||||
return font;
|
||||
}
|
||||
String fName = "/cardbuilder/fonts/" + name;
|
||||
try (final InputStream is = getJarResourceStream(fName)) {
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, is);
|
||||
Map<TextAttribute, Object> map = new Hashtable<>();
|
||||
map.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
|
||||
font = font.deriveFont(map);
|
||||
} catch (Exception ex) {
|
||||
System.err.println(fName + " not loaded. Using serif font.");
|
||||
font = new Font("serif", Font.PLAIN, 24);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
private static BufferedImage getComponent(String imageName) {
|
||||
String fName = FRAMES_FOLDER + imageName;
|
||||
try (final InputStream is = getJarResourceStream(fName)) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import magic.awt.MagicFont;
|
||||
|
||||
import magic.model.MagicColor;
|
||||
import magic.model.MagicType;
|
||||
|
@ -36,7 +37,7 @@ public class OracleText {
|
|||
private static final int maxDistance = 260100;
|
||||
private static final double transparencyTolerance = 0.001;
|
||||
private static final int padding = 1;
|
||||
private static final Font cardTextFont = ResourceManager.getFont("MPlantin.ttf").deriveFont(Font.PLAIN, 18);//scale down when long string
|
||||
private static final Font cardTextFont = MagicFont.MPlantin.get().deriveFont(Font.PLAIN, 18);//scale down when long string
|
||||
private static final int topPadding = 7;
|
||||
private static final int leftPadding = 3;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.awt.font.TextLayout;
|
|||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import magic.awt.MagicFont;
|
||||
|
||||
import magic.model.MagicAbility;
|
||||
import magic.model.MagicColor;
|
||||
|
@ -21,9 +22,9 @@ import magic.cardBuilder.ResourceManager;
|
|||
|
||||
public class PTFrame {
|
||||
|
||||
private static final Font cardPTFont = ResourceManager.getFont("Beleren-Bold.ttf").deriveFont(Font.PLAIN, 19);
|
||||
private static final Font cardPTFontSmall = ResourceManager.getFont("Beleren-Bold.ttf").deriveFont(Font.PLAIN, 15);//scale down when triple figures
|
||||
private static final Font cardLoyaltyFont = ResourceManager.getFont("Beleren-Bold.ttf").deriveFont(Font.PLAIN, 16);
|
||||
private static final Font cardPTFont = MagicFont.BelerenBold.get().deriveFont(Font.PLAIN, 19);
|
||||
private static final Font cardPTFontSmall = MagicFont.BelerenBold.get().deriveFont(Font.PLAIN, 15);//scale down when triple figures
|
||||
private static final Font cardLoyaltyFont = MagicFont.BelerenBold.get().deriveFont(Font.PLAIN, 16);
|
||||
|
||||
//draw ptPanel - The only layering requirement besides frame. Ability text must wrap around ptpanel intrusion if any.
|
||||
static void drawPTPanel(BufferedImage cardImage, IRenderableCard cardDef) {
|
||||
|
|
|
@ -15,17 +15,17 @@ import java.awt.image.BufferedImage;
|
|||
import java.text.AttributedString;
|
||||
import java.util.List;
|
||||
import javax.swing.ImageIcon;
|
||||
import magic.awt.MagicFont;
|
||||
|
||||
import magic.data.MagicIcon;
|
||||
import magic.model.MagicType;
|
||||
import magic.ui.MagicImages;
|
||||
import magic.model.IRenderableCard;
|
||||
import magic.cardBuilder.ResourceManager;
|
||||
|
||||
public class TitleFrame {
|
||||
|
||||
private static final Font cardNameFont = ResourceManager.getFont("JaceBeleren-Bold.ttf").deriveFont(Font.PLAIN, 19);
|
||||
private static final Font cardNameTokenFont = ResourceManager.getFont("Beleren Small Caps.ttf").deriveFont(Font.PLAIN, 20);
|
||||
private static final Font cardNameFont = MagicFont.JaceBelerenBold.get().deriveFont(Font.PLAIN, 19);
|
||||
private static final Font cardNameTokenFont = MagicFont.BelerenSmallCaps.get().deriveFont(Font.PLAIN, 20);
|
||||
|
||||
static void drawManaCost(BufferedImage cardImage, IRenderableCard cardDef) {
|
||||
List<MagicIcon> manaCost = getManaCost(cardDef);
|
||||
|
|
|
@ -7,16 +7,17 @@ import java.awt.FontMetrics;
|
|||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import magic.awt.MagicFont;
|
||||
|
||||
import magic.model.MagicType;
|
||||
import magic.model.IRenderableCard;
|
||||
import magic.cardBuilder.ResourceManager;
|
||||
|
||||
public class TypeLine {
|
||||
private static final Font cardTypeFont = ResourceManager.getFont("JaceBeleren-Bold.ttf").deriveFont(Font.PLAIN, 16);
|
||||
private static final Font cardTypeFontSmall = ResourceManager.getFont("JaceBeleren-Bold.ttf").deriveFont(Font.PLAIN, 15);
|
||||
private static final Font cardTypeFontVerySmall = ResourceManager.getFont("JaceBeleren-Bold.ttf").deriveFont(Font.PLAIN, 14);
|
||||
private static final Font cardTypeFontSmallest = ResourceManager.getFont("JaceBeleren-Bold.ttf").deriveFont(Font.PLAIN, 13);
|
||||
private static final Font cardTypeFont = MagicFont.JaceBelerenBold.get().deriveFont(Font.PLAIN, 16);
|
||||
private static final Font cardTypeFontSmall = MagicFont.JaceBelerenBold.get().deriveFont(Font.PLAIN, 15);
|
||||
private static final Font cardTypeFontVerySmall = MagicFont.JaceBelerenBold.get().deriveFont(Font.PLAIN, 14);
|
||||
private static final Font cardTypeFontSmallest = MagicFont.JaceBelerenBold.get().deriveFont(Font.PLAIN, 13);
|
||||
private static int padding;
|
||||
|
||||
static void drawCardTypeLine(BufferedImage cardImage, IRenderableCard cardDef) {
|
||||
|
|
Loading…
Reference in New Issue