8231243: [TESTBUG] CustomFont.java cannot find font file
authorprr
Tue, 24 Sep 2019 09:09:15 -0700
changeset 58593 da02c2254989
parent 58592 fd7e7bb190aa
child 58594 2ddb4fc49ca6
8231243: [TESTBUG] CustomFont.java cannot find font file Reviewed-by: serb
test/jdk/java/awt/print/PrinterJob/CustomFont/CustomFont.java
--- a/test/jdk/java/awt/print/PrinterJob/CustomFont/CustomFont.java	Tue Jul 09 15:58:22 2019 +0200
+++ b/test/jdk/java/awt/print/PrinterJob/CustomFont/CustomFont.java	Tue Sep 24 09:09:15 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
   @test
-  @bug 4386025
+  @bug 4386025 8231243
   @summary fonts not in win32 font directory print incorrectly.
   @author prr: area=PrinterJob
   @run main/manual CustomFont
@@ -83,12 +83,13 @@
   Font customFont;
   public CustomFont() {
        try {
-             FileInputStream fin = new FileInputStream("A.ttf");
+             String dir = System.getProperty("test.src", ".");
+             String fileName = dir + File.separator + "A.ttf";
+             FileInputStream fin = new FileInputStream(fileName);
              Font cf = Font.createFont(Font.TRUETYPE_FONT, fin);
              customFont = cf.deriveFont(Font.PLAIN, 14);
         } catch (Exception ioe) {
-             System.err.println(ioe.getMessage());
-             customFont = new Font("serif", Font.PLAIN, 14);
+             throw new RuntimeException(ioe);
         }
   }
 
@@ -99,7 +100,7 @@
 
        g2D.setColor(Color.black);
        g2D.setFont(customFont);
-       String str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+       String str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        g.drawString(str, 100, 100);
 
        return Printable.PAGE_EXISTS;