font style add character fix

This commit is contained in:
Jindra Petřík
2014-10-26 15:40:57 +01:00
parent 2dc6de038d
commit 9a5361e8e3
5 changed files with 12 additions and 12 deletions

View File

@@ -377,7 +377,7 @@ public class DefineFont2Tag extends FontTag {
public void addCharacter(char character, Font font) {
int fontStyle = getFontStyle();
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int) Math.round(getDivider() * 1024), character);
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), character);
int code = (int) character;
int pos = -1;

View File

@@ -376,7 +376,7 @@ public class DefineFont3Tag extends FontTag {
}
}
int fontStyle = getFontStyle();
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, fontStyle, (int) Math.round(getDivider() * 1024), character);
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), character);
int code = (int) character;
int pos = -1;
boolean exists = false;

View File

@@ -267,7 +267,7 @@ public class DefineFontTag extends FontTag {
@Override
public void addCharacter(char character, Font font) {
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, getFontStyle(), (int) Math.round(getDivider() * 1024), character);
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), character);
List<Integer> codeTable = new ArrayList<>();
ensureFontInfo();
if (fontInfoTag != null) {

View File

@@ -148,8 +148,8 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
int fontStyle = getFontStyle();
FontType font = fonts.get(0);
double d = 1; //1024/font.nominalSize;
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(cfont, fontStyle, (int) (font.nominalSize * d), character);
double d = 1;
SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(cfont, (int) (font.nominalSize * d), character);
int code = (int) character;
int pos = -1;

View File

@@ -225,26 +225,26 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
public abstract boolean isMove();
public static List<SHAPE> systemFontCharactersToSHAPES(String fontName, int fontStyle, int fontSize, String characters) {
public static List<SHAPE> systemFontCharactersToSHAPES(Font font, int fontSize, String characters) {
List<SHAPE> ret = new ArrayList<>();
for (int i = 0; i < characters.length(); i++) {
ret.add(systemFontCharacterToSHAPE(fontName, fontStyle, fontSize, characters.charAt(i)));
ret.add(systemFontCharacterToSHAPE(font, fontSize, characters.charAt(i)));
}
return ret;
}
public static SHAPE systemFontCharacterToSHAPE(final String fontName, final int fontStyle, int fontSize, char character) {
return fontCharacterToSHAPE(new Font(FontTag.getFontNameWithFallback(fontName), Font.PLAIN, 10), fontStyle, fontSize, character);
public static SHAPE systemFontCharacterToSHAPE(Font font, int fontSize, char character) {
return fontCharacterToSHAPE(font,fontSize, character);
}
public static SHAPE fontCharacterToSHAPE(final Font font, final int fontStyle, int fontSize, char character) {
public static SHAPE fontCharacterToSHAPE(final Font font, float fontSize, char character) {
int multiplier = 1;
if (fontSize > 1024) {
multiplier = fontSize / 1024;
multiplier = (int)(fontSize / 1024);
fontSize = 1024;
}
List<SHAPERECORD> retList = new ArrayList<>();
Font f = font.deriveFont(fontStyle, fontSize);
Font f = font.deriveFont(fontSize);
GlyphVector v = f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(), "" + character);
Shape shp = v.getOutline();
double[] points = new double[6];