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 }