< prev index next >

test/jdk/java/awt/font/WindowsIndicFonts.java

Print this page


   1 /*
   2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 /*
  24  * @test
  25  * @bug 8208179
  26  * @summary Verifies logical fonts support Indic + other Asian code points
  27  * @requires (os.family == "windows")
  28  */
  29 
  30 /*
  31  * This isn't just testing Indic fonts, a few other Asian scripts are
  32  * also being verified.
  33  * Oracle JDK for Windows had supported Devanagari and Thai in the logical
  34  * fonts using a proprietary font, since Windows did not have such fonts.
  35  * Since that was first added Microsoft added into Windows 7 a
  36  * number of fonts to support Indic + other Asian scripts.
  37  * By referencing these in the fontconfig.properties files we can enure that
  38  * these scripts are supported by the logical fonts when using OpenJDK for
  39  * Windows.
  40  * The test here just verifies that at least one required code point from each
  41  * of these scripts is available to make sure we don't regress, or to catch
  42  * and understand cases where those fonts may not be installed.
  43  */
  44 import java.awt.Font;

  45 
  46 public class WindowsIndicFonts {
  47 
  48   static boolean failed = false;
  49   static Font dialog = new Font(Font.DIALOG, Font.PLAIN, 12);

  50 
  51   public static void main(String args[]) {
  52 
  53      if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
  54          return;
  55      }
  56 
  57      test("\u0905", "Devanagari"); // from Mangal font
  58      test("\u0985", "Bengali");    // from Vrinda font
  59      test("\u0a05", "Gurmukhi");   // from Raavi font
  60      test("\u0a85", "Gujurati");   // from Shruti font
  61      test("\u0b05", "Oriya");      // from Kalinga font
  62      test("\u0b85", "Tamil");      // from Latha font
  63      test("\u0c05", "Telugu");     // from Gautami font
  64      test("\u0c85", "Kannada");    // from Tunga font
  65      test("\u0d05", "Malayalam");  // from Kartika font
  66      test("\u0c05", "Sinhala");    // from Iskoola Pota font
  67      test("\u0e05", "Thai");       // from DokChampa font
  68      test("\u0e87", "Lao");        // from DokChampa font
  69      test("\u0e05", "Khmer");      // from Khmer UI font
  70      test("\u1820", "Mongolian");  // from Mongolian Baiti font
  71 
  72      if (failed) {
  73          throw new RuntimeException("Missing support for a script");
  74      }
  75   }
  76 
  77   static void test(String text, String script) {





  78      if (dialog.canDisplayUpTo(text) != -1) {
  79          failed = true;
  80          System.out.println("No codepoint for " + script);
  81      }
  82   }
  83 
  84 }
   1 /*
   2  * Copyright (c) 2019,2020 Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 /*
  24  * @test
  25  * @bug 8208179 8223935
  26  * @summary Verifies logical fonts support Indic + other Asian code points
  27  * @requires (os.family == "windows")
  28  */
  29 
  30 /*
  31  * This isn't just testing Indic fonts, a few other Asian scripts are
  32  * also being verified.
  33  * Oracle JDK for Windows had supported Devanagari and Thai in the logical
  34  * fonts using a proprietary font, since Windows did not have such fonts.
  35  * Since that was first added Microsoft added into Windows 7 a
  36  * number of fonts to support Indic + other Asian scripts.
  37  * By referencing these in the fontconfig.properties files we can enure that
  38  * these scripts are supported by the logical fonts when using OpenJDK for
  39  * Windows.
  40  * The test here just verifies that at least one required code point from each
  41  * of these scripts is available to make sure we don't regress, or to catch
  42  * and understand cases where those fonts may not be installed.
  43  */
  44 import java.awt.Font;
  45 import java.io.File;
  46 
  47 public class WindowsIndicFonts {
  48 
  49   static boolean failed = false;
  50   static Font dialog = new Font(Font.DIALOG, Font.PLAIN, 12);
  51   static final String WINDOWS_FONT_DIR = "c:\\windows\\fonts";
  52 
  53   public static void main(String args[]) {
  54 
  55      if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
  56          return;
  57      }
  58 
  59      test("\u0905", "Devanagari", "mangal.ttf"); // from Mangal font
  60      test("\u0985", "Bengali", "vrinda.ttf");    // from Vrinda font
  61      test("\u0a05", "Gurmukhi", "raavi.ttf");   // from Raavi font
  62      test("\u0a85", "Gujurati", "shruti.ttf");   // from Shruti font
  63      test("\u0b05", "Oriya", "kalinga.ttf");      // from Kalinga font
  64      test("\u0b85", "Tamil", "latha.ttf");      // from Latha font
  65      test("\u0c05", "Telugu", "gautami.ttf");     // from Gautami font
  66      test("\u0c85", "Kannada", "tunga.ttf");    // from Tunga font
  67      test("\u0d05", "Malayalam", "kartika.ttf");  // from Kartika font
  68      test("\u0c05", "Sinhala", "iskpota.ttf");    // from Iskoola Pota font
  69      test("\u0e05", "Thai", "dokchamp.ttf");       // from DokChampa font
  70      test("\u0e87", "Lao", "dokchamp.ttf");        // from DokChampa font
  71      test("\u0e05", "Khmer", "khmerui.ttf");      // from Khmer UI font
  72      test("\u1820", "Mongolian", "monbaiti.ttf");  // from Mongolian Baiti font
  73 
  74      if (failed) {
  75          throw new RuntimeException("Missing support for a script");
  76      }
  77   }
  78 
  79   static void test(String text, String script, String filename) {
  80      File f = new File(WINDOWS_FONT_DIR, filename);
  81      if (!f.exists()) {
  82           System.out.println("Can't find required font file: " + filename);
  83           return;
  84      }
  85      if (dialog.canDisplayUpTo(text) != -1) {
  86          failed = true;
  87          System.out.println("No codepoint for " + script);
  88      }
  89   }
  90 
  91 }
< prev index next >