AwtPaint: font kerning improvements, #92

This commit is contained in:
Emux 2016-07-28 13:29:55 +03:00
parent 49a81cbe04
commit 8dce91b035

View File

@ -92,14 +92,12 @@ public class AwtPaint implements Paint {
} }
static final Font defaultFont; static final Font defaultFont;
private static final Map<Attribute, Object> textAttributes = new HashMap<>();
static { static {
Map<Attribute, Object> textAttributes = new HashMap<>();
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
textAttributes.put(TextAttribute.FAMILY, "Arial");
textAttributes.put(TextAttribute.SIZE, 14);
defaultFont = Font.getFont(textAttributes); defaultFont = new Font("Arial", Font.PLAIN, 14).deriveFont(textAttributes);
} }
Color color = new Color(0.1f, 0.1f, 0.1f, 1); Color color = new Color(0.1f, 0.1f, 0.1f, 1);
@ -171,9 +169,7 @@ public class AwtPaint implements Paint {
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) { public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
this.fontName = getFontName(fontFamily); this.fontName = getFontName(fontFamily);
this.fontStyle = getFontStyle(fontStyle); this.fontStyle = getFontStyle(fontStyle);
Map<Attribute, Object> textAttributes = new HashMap<>(); this.font = new Font(this.fontName, this.fontStyle, (int) this.textSize).deriveFont(this.textAttributes);
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
this.font = new Font(this.fontName, this.fontStyle, (int) this.textSize).deriveFont(textAttributes);
} }
@Override @Override