(app: Application)
| 41 | */ |
| 42 | export class TextScreen extends Stage { |
| 43 | onResetEvent(app: Application) { |
| 44 | const w = app.viewport.width; |
| 45 | |
| 46 | app.world.addChild(new ColorLayer("background", "#202020"), 0); |
| 47 | app.world.addChild(new BaselineOverlay(w, app.viewport.height), 2); |
| 48 | |
| 49 | // ---- Font size test (left side) ---- |
| 50 | let yPos = 0; |
| 51 | for (let i = 8; i < 56; i += 8) { |
| 52 | const t = new Text(5, yPos, { |
| 53 | font: "Arial", |
| 54 | size: i, |
| 55 | fillStyle: "white", |
| 56 | strokeStyle: "red", |
| 57 | lineWidth: 1, |
| 58 | textBaseline: "top", |
| 59 | textAlign: "left", |
| 60 | text: `Arial Text ${i}px !`, |
| 61 | }); |
| 62 | t.setOpacity(0.5); |
| 63 | app.world.addChild(t, 1); |
| 64 | yPos += t.getBounds().height; |
| 65 | } |
| 66 | |
| 67 | // ---- BitmapText size test (right side) ---- |
| 68 | yPos = 0; |
| 69 | for (let i = 1; i < 5; i++) { |
| 70 | const b = new BitmapText(w, yPos, { |
| 71 | font: "xolo12", |
| 72 | size: i * 0.75, |
| 73 | textAlign: "right", |
| 74 | textBaseline: "top", |
| 75 | text: "BITMAP TEST", |
| 76 | }); |
| 77 | b.fillStyle.parseCSS("indigo"); |
| 78 | for (let j = 0; j < i; j++) { |
| 79 | b.fillStyle.lighten(0.25); |
| 80 | } |
| 81 | app.world.addChild(b, 1); |
| 82 | yPos += b.getBounds().height * 1.5; |
| 83 | } |
| 84 | |
| 85 | // ---- Font baseline test (y=200) ---- |
| 86 | const baselines = [ |
| 87 | "bottom", |
| 88 | "ideographic", |
| 89 | "alphabetic", |
| 90 | "middle", |
| 91 | "hanging", |
| 92 | "top", |
| 93 | ]; |
| 94 | let xPos = 0; |
| 95 | |
| 96 | // we need a temp Text to measure widths for spacing |
| 97 | const tmpFont = new Text(0, 0, { |
| 98 | font: "Arial", |
| 99 | size: 16, |
| 100 | fillStyle: "white", |
nothing calls this directly
no test coverage detected