@Test public void testGetTypeface_Null() throws Exception { TextAttributes attributes = new TextAttributes(); attributes.typeface = null; assertEquals(null, attributes.getTypeface()); }
@Test public void testGetTypeface() throws Exception { TextAttributes attributes = new TextAttributes(); Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL); attributes.typeface = typeface; assertEquals(typeface, attributes.getTypeface()); }
public TextCacheKey set(String text, TextAttributes attributes) { this.text = text; if (attributes != null) { this.textColor = (this.textColor != null) ? this.textColor.set(attributes.getTextColor()) : new Color(attributes.getTextColor()); this.textSize = attributes.getTextSize(); this.typeface = attributes.getTypeface(); this.enableOutline = attributes.isEnableOutline(); this.outlineColor = (this.outlineColor != null) ? this.outlineColor.set(attributes.getOutlineColor()) : new Color(attributes.getOutlineColor()); this.outlineWidth = attributes.getOutlineWidth(); } else { this.textColor = null; this.textSize = 0; this.typeface = null; this.enableOutline = false; this.outlineColor = null; this.outlineWidth = 0; } return this; }
public Texture renderText(String text, TextAttributes attributes) { TextCacheKey key = new TextCacheKey().set(text, attributes); Texture texture = null; if (text != null && attributes != null) { this.textRenderer.setTextColor(attributes.getTextColor()); this.textRenderer.setTextSize(attributes.getTextSize()); this.textRenderer.setTypeface(attributes.getTypeface()); this.textRenderer.setEnableOutline(attributes.isEnableOutline()); this.textRenderer.setOutlineColor(attributes.getOutlineColor()); this.textRenderer.setOutlineWidth(attributes.getOutlineWidth()); texture = this.textRenderer.renderText(text); } this.renderResourceCache.put(key, texture, (texture != null) ? texture.getByteCount() : 0); return texture; }