1
1
/*
2
- * Copyright (c) 2010, 2016 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2010, 2022 , 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
23
23
24
24
/**
25
25
* @test
26
- * @key headful
27
- * @bug 6996867
26
+ * @bug 6996867 8223543
27
+ * @requires (os.family == "windows")
28
28
* @summary Render as LCD Text in SrcEa composite mode.
29
29
*/
30
30
31
- import java .awt .*;
32
- import java .awt .event .*;
33
- import java .awt .image .*;
31
+ import java .awt .AlphaComposite ;
32
+ import java .awt .Color ;
33
+ import java .awt .Graphics2D ;
34
+ import java .awt .RenderingHints ;
35
+ import java .awt .image .BufferedImage ;
34
36
35
- public class LCDTextSrcEa extends Component {
36
-
37
- static int SZ =150 ;
38
- BufferedImage target =
39
- new BufferedImage (SZ , SZ , BufferedImage .TYPE_INT_RGB );
40
-
41
- public static void main (String args []) {
42
- Frame f = new Frame ("LCD Text SrcEa Test" );
43
- f .addWindowListener (new WindowAdapter () {
44
- @ Override
45
- public void windowClosing (WindowEvent e ) {
46
- System .exit (0 );
47
- }
48
- });
49
- LCDTextSrcEa td = new LCDTextSrcEa ();
50
- f .add ("Center" , td );
51
- f .pack ();
52
- f .setVisible (true );
53
- }
54
-
55
- public Dimension getPreferredSize () {
56
- return new Dimension (SZ ,SZ );
57
- }
58
-
59
- public void paint (Graphics gx ) {
37
+ public class LCDTextSrcEa {
60
38
39
+ public static void main (String [] args ) {
40
+ String os = System .getProperty ("os.name" );
41
+ if (os .toLowerCase ().startsWith ("mac" )) {
42
+ System .out .println ("macOS doesn't support LCD any more. Skipping" );
43
+ return ;
44
+ }
45
+ /* Sometimes freetype on Linux is built without LCD support, so
46
+ * it can't be relied upon to test there.
47
+ */
48
+ if (os .toLowerCase ().startsWith ("linux" )) {
49
+ System .out .println ("Linux freetype may not do LCD. Skipping" );
50
+ return ;
51
+ }
52
+ int SZ =200 ;
53
+ BufferedImage target =
54
+ new BufferedImage (SZ , SZ , BufferedImage .TYPE_INT_RGB );
61
55
Graphics2D g2d = (Graphics2D ) target .getGraphics ();
62
56
g2d .setColor (Color .white );
63
- g2d .fillRect (0 , 0 , getWidth (), getHeight () );
57
+ g2d .fillRect (0 , 0 , SZ , SZ );
64
58
65
59
g2d .setComposite (AlphaComposite .getInstance (AlphaComposite .SRC , 0.01f ));
66
60
g2d .setRenderingHint (
@@ -72,7 +66,6 @@ public void paint(Graphics gx) {
72
66
73
67
g2d .setColor (Color .black );
74
68
g2d .drawString ("Some sample text." , 10 , 20 );
75
- gx .drawImage (target , 0 , 0 , null );
76
69
boolean nongrey = false ;
77
70
//Test BI: should be some non-greyscale color
78
71
for (int px =0 ;px <SZ ;px ++) {
0 commit comments