|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
22 | 22 | */
|
23 | 23 |
|
24 | 24 | /*
|
25 |
| - * @test |
| 25 | + * @test id=dialog_double |
26 | 26 | * @bug 4269775 8341535
|
27 | 27 | * @summary Check that different text rendering APIs agree
|
| 28 | + * @run main/othervm TestDevTransform DIALOG DOUBLE |
| 29 | + */ |
| 30 | + |
| 31 | +/* |
| 32 | + * @test id=dialog_float |
| 33 | + * @bug 4269775 8341535 |
| 34 | + * @summary Check that different text rendering APIs agree |
| 35 | + * @run main/othervm TestDevTransform DIALOG FLOAT |
| 36 | + */ |
| 37 | + |
| 38 | +/* |
| 39 | + * @test id=monospaced_double |
| 40 | + * @bug 4269775 8341535 |
| 41 | + * @summary Check that different text rendering APIs agree |
| 42 | + * @run main/othervm TestDevTransform MONOSPACED DOUBLE |
| 43 | + */ |
| 44 | + |
| 45 | +/* |
| 46 | + * @test id=monospaced_float |
| 47 | + * @bug 4269775 8341535 |
| 48 | + * @summary Check that different text rendering APIs agree |
| 49 | + * @run main/othervm TestDevTransform MONOSPACED FLOAT |
28 | 50 | */
|
29 | 51 |
|
30 | 52 | /**
|
@@ -66,6 +88,8 @@ public class TestDevTransform {
|
66 | 88 | static String test = "This is only a test";
|
67 | 89 | static double angle = Math.PI / 6.0; // Rotate 30 degrees
|
68 | 90 | static final int W = 400, H = 400;
|
| 91 | + static boolean useDialog; |
| 92 | + static boolean useDouble; |
69 | 93 |
|
70 | 94 | static void draw(Graphics2D g2d, TextLayout layout,
|
71 | 95 | float x, float y, float scalex) {
|
@@ -101,9 +125,19 @@ static void init(Graphics2D g2d) {
|
101 | 125 | g2d.setColor(Color.white);
|
102 | 126 | g2d.fillRect(0, 0, W, H);
|
103 | 127 | g2d.setColor(Color.black);
|
104 |
| - g2d.scale(1.481f, 1.481); // Convert to 108 dpi |
| 128 | + if (useDouble) { |
| 129 | + g2d.scale(1.481, 1.481); // Convert to 108 dpi |
| 130 | + } else { |
| 131 | + g2d.scale(1.481f, 1.481f); // Convert to 108 dpi |
| 132 | + } |
105 | 133 | g2d.addRenderingHints(hints);
|
106 |
| - Font font = new Font(Font.DIALOG, Font.PLAIN, 12); |
| 134 | + String name; |
| 135 | + if (useDialog) { |
| 136 | + name = Font.DIALOG; |
| 137 | + } else { |
| 138 | + name = Font.MONOSPACED; |
| 139 | + } |
| 140 | + Font font = new Font(name, Font.PLAIN, 12); |
107 | 141 | g2d.setFont(font);
|
108 | 142 | }
|
109 | 143 |
|
@@ -135,6 +169,12 @@ static void compare(BufferedImage bi1, String name1, BufferedImage bi2, String n
|
135 | 169 | }
|
136 | 170 |
|
137 | 171 | public static void main(String args[]) throws Exception {
|
| 172 | + if (args[0].equals("DIALOG")) { |
| 173 | + useDialog = true; |
| 174 | + } |
| 175 | + if (args[1].equals("DOUBLE")) { |
| 176 | + useDouble = true; |
| 177 | + } |
138 | 178 |
|
139 | 179 | BufferedImage tl_Image = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB);
|
140 | 180 | {
|
|
0 commit comments