Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added BOLD examples

  • Loading branch information...
commit 3be78708a420be830f352630628b6b46a7d465a7 1 parent a760b66
@jamie-threerings jamie-threerings authored
Showing with 17 additions and 3 deletions.
  1. +17 −3 tests/core/src/main/java/playn/tests/core/TextTest.java
View
20 tests/core/src/main/java/playn/tests/core/TextTest.java
@@ -19,7 +19,6 @@
import playn.core.Keyboard.TextType;
import playn.core.Pointer;
import playn.core.Pointer.Event;
-import playn.core.PlayN;
import playn.core.TextFormat;
import playn.core.Canvas;
import playn.core.CanvasImage;
@@ -33,8 +32,6 @@
public class TextTest extends Test {
- private TextFormat baseFormat = new TextFormat().
- withFont(graphics().createFont("Times New Roman", Font.Style.PLAIN, 24));
private final float COL_WIDTH = 120;
@Override
@@ -51,11 +48,14 @@ public String getDescription() {
public void init() {
float x = 0;
x += addExamples("Filled", FILL, x);
+ x += addExamples("Bold", BOLD, x);
x += addExamples("Stroked", STROKE, x);
x += addExamples("Vector otln", OUTLINE_VEC, x);
x += addExamples("Shadow UL", SHADOW_UL, x);
x += addExamples("Shadow LR", SHADOW_LR, x);
+ final TextFormat baseFormat = STROKE.format();
+
// test laying out the empty string
TextLayout layout = graphics().layoutText("", new TextFormat());
ImageLayer layer = makeTextLayer(
@@ -83,6 +83,7 @@ public void onFailure(Throwable cause) {}
protected float addExamples(String name, TextRenderer renderer, float x) {
GroupLayer root = graphics().rootLayer();
+ TextFormat baseFormat = renderer.format();
ImageLayer[] layers = {
makeTextLayer(name, renderer, baseFormat),
makeTextLayer("The quick brown fox", renderer,
@@ -117,6 +118,10 @@ protected Image makeTextImage(String text, TextRenderer renderer, TextFormat for
}
protected static abstract class TextRenderer {
+ public Font.Style style () { return Font.Style.PLAIN; }
+ public TextFormat format () {
+ return new TextFormat().withFont(graphics().createFont("Times New Roman", style(), 24));
+ }
public float adjustWidth(float width) { return width; }
public float adjustHeight(float height) { return height; }
public abstract void render(Canvas canvas, TextLayout text);
@@ -134,6 +139,15 @@ public void render(Canvas canvas, TextLayout text) {
canvas.fillText(text, 0, 0);
}
};
+ protected static TextRenderer BOLD = new TextRenderer() {
+ public Font.Style style () {
+ return Font.Style.BOLD;
+ }
+ public void render(Canvas canvas, TextLayout text) {
+ canvas.setFillColor(0xFF6699CC);
+ canvas.fillText(text, 0, 0);
+ }
+ };
protected static TextRenderer SHADOW_UL = new TextRenderer() {
public float adjustWidth(float width) { return width + 2; }
public float adjustHeight(float height) { return height + 2; }
Please sign in to comment.
Something went wrong with that request. Please try again.