(Canvas canvas, int width, int height, float dpi, int xpos, int ypos)
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) { |
| 40 | var variant = _variants[_variantIdx].split(" "); |
| 41 | String text = variant[0]; |
| 42 | if ("Tabs".equals(variant[0])) |
| 43 | text = " "; |
| 44 | else if ("Emoji".equals(variant[0])) |
| 45 | text = "😀 😃 😄 😁 😆 😅 😂 ☺️ 😇 😍"; |
| 46 | else if ("Greek".equals(variant[0])) |
| 47 | text = "ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι"; |
| 48 | else if ("Notdef".equals(variant[0])) |
| 49 | text = "\u20C0\u20C0\u20C0\u20C0\u20C0\u20C0\u20C0\u20C0\u20C0\u20C0"; |
| 50 | else if ("English".equals(variant[0])) |
| 51 | text = "In girum imus nocte et consumimur igni"; |
| 52 | |
| 53 | if ("Paragraph".equals(variant[1])) { |
| 54 | if (variant.length > 2) // No-Cache |
| 55 | fc.getParagraphCache().reset(); |
| 56 | for (int i = 1; true; ++i) { |
| 57 | float y = i * padding; |
| 58 | if (y > height - padding) break; |
| 59 | try (TextStyle ts = new TextStyle().setColor(0xFF000000).setFontFamilies(new String [] {"JetBrains Mono"}).setFontSize(fontSize); |
| 60 | ParagraphStyle ps = new ParagraphStyle(); |
| 61 | ParagraphBuilder pb = new ParagraphBuilder(ps, fc);) |
| 62 | { |
| 63 | pb.pushStyle(ts); |
| 64 | pb.addText(i + " [" + text + "]"); |
| 65 | try (Paragraph p = pb.build();) { |
| 66 | p.layout(Float.POSITIVE_INFINITY); |
| 67 | p.paint(canvas, padding, y); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } else { // TextLine |
| 72 | try (var shaper = Shaper.makeShapeDontWrapOrReorder();) { |
| 73 | for (int i = 1; true; ++i) { |
| 74 | float y = i * padding; |
| 75 | if (y > height - padding) break; |
| 76 | try (var line = variant.length > 2 // No-Approx |
| 77 | ? shaper.shapeLine(i + " [" + text + "]", font, ShapingOptions.DEFAULT.withApproximateSpaces(false).withApproximatePunctuation(false)) |
| 78 | : shaper.shapeLine(i + " [" + text + "]", font)) |
| 79 | { |
| 80 | canvas.drawTextLine(line, padding, y - metrics.getAscent(), blackFill); |
| 81 | canvas.drawRect(Rect.makeXYWH(padding, y, line.getWidth(), metrics.getHeight()), redStroke); |
| 82 | for (float x: TextLine._nGetRunPositions(line._ptr)) |
| 83 | canvas.drawLine(padding + x, y, padding + x, y + metrics.getHeight(), redStroke); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected