< prev index next >

modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubFontLoader.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2015, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.com.sun.javafx.pgstub;
  27 
  28 import com.sun.javafx.font.FontResource;
  29 import com.sun.javafx.font.FontStrike;
  30 import com.sun.javafx.font.PGFont;
  31 import com.sun.javafx.geom.transform.BaseTransform;

  32 import com.sun.javafx.tk.FontLoader;
  33 import com.sun.javafx.tk.FontMetrics;
  34 import javafx.scene.text.Font;
  35 import javafx.scene.text.FontPosture;
  36 import javafx.scene.text.FontWeight;
  37 
  38 import java.io.InputStream;
  39 import java.util.Arrays;
  40 import java.util.List;
  41 import java.util.Locale;
  42 
  43 public class StubFontLoader extends FontLoader {
  44 
  45     @Override
  46     public void loadFont(Font font) {
  47         StubFont nativeFont = new StubFont();
  48         nativeFont.font = font;
  49         String name = font.getName().trim().toLowerCase(Locale.ROOT);
  50         if (name.equals("system") || name.equals("system regular")) {
  51             font.impl_setNativeFont(nativeFont, font.getName(), "System", "Regular");
  52         } else if (name.equals("amble regular")) {
  53             font.impl_setNativeFont(nativeFont, font.getName(), "Amble", "Regular");
  54         } else if (name.equals("amble bold")) {
  55             font.impl_setNativeFont(nativeFont, font.getName(), "Amble", "Bold");
  56         } else if (name.equals("amble italic")) {
  57             font.impl_setNativeFont(nativeFont, font.getName(), "Amble", "Italic");
  58         } else if (name.equals("amble bold italic")) {
  59             font.impl_setNativeFont(nativeFont, font.getName(), "Amble",
  60                     "Bold Italic");
  61         } else if (name.equals("amble condensed")) {
  62             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Cn", "Regular");
  63         } else if (name.equals("amble bold condensed")) {
  64             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Cn", "Bold");
  65         } else if (name.equals("amble condensed italic")) {
  66             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Cn", "Italic");
  67         } else if (name.equals("amble bold condensed italic")) {
  68             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Cn",
  69                     "Bold Italic");
  70         } else if (name.equals("amble light")) {
  71             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Lt", "Regular");
  72         } else if (name.equals("amble light italic")) {
  73             font.impl_setNativeFont(nativeFont, font.getName(), "Amble Lt", "Italic");
  74         } else if (name.equals("amble light condensed")) {
  75             font.impl_setNativeFont(nativeFont, font.getName(), "Amble LtCn",
  76                     "Regular");
  77         } else if (name.equals("amble light condensed italic")) {
  78             font.impl_setNativeFont(nativeFont, font.getName(), "Amble LtCn",
  79                     "Italic");
  80         }
  81     }
  82 
  83     @Override
  84     public List<String> getFamilies() {
  85         return Arrays.asList("Amble", "Amble Cn", "Amble Lt", "Amble LtCn");
  86     }
  87 
  88     @Override
  89     public List<String> getFontNames() {
  90         return Arrays.asList("Amble Regular", "Amble Bold", "Amble Italic",
  91                 "Amble Bold Italic", "Amble Condensed", "Amble Bold Condensed",
  92                 "Amble Condensed Italic", "Amble Bold Condensed Italic",
  93                 "Amble Light", "Amble Light Italic", "Amble Light Condensed",
  94                 "Amble Light Condensed Italic");
  95     }
  96 
  97     @Override
  98     public List<String> getFontNames(String family) {


   1 /*
   2  * Copyright (c) 2011, 2016, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.com.sun.javafx.pgstub;
  27 
  28 import com.sun.javafx.font.FontResource;
  29 import com.sun.javafx.font.FontStrike;
  30 import com.sun.javafx.font.PGFont;
  31 import com.sun.javafx.geom.transform.BaseTransform;
  32 import com.sun.javafx.text.FontHelper;
  33 import com.sun.javafx.tk.FontLoader;
  34 import com.sun.javafx.tk.FontMetrics;
  35 import javafx.scene.text.Font;
  36 import javafx.scene.text.FontPosture;
  37 import javafx.scene.text.FontWeight;
  38 
  39 import java.io.InputStream;
  40 import java.util.Arrays;
  41 import java.util.List;
  42 import java.util.Locale;
  43 
  44 public class StubFontLoader extends FontLoader {
  45 
  46     @Override
  47     public void loadFont(Font font) {
  48         StubFont nativeFont = new StubFont();
  49         nativeFont.font = font;
  50         String name = font.getName().trim().toLowerCase(Locale.ROOT);
  51         if (name.equals("system") || name.equals("system regular")) {
  52             FontHelper.setNativeFont(font, nativeFont, font.getName(), "System", "Regular");
  53         } else if (name.equals("amble regular")) {
  54             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble", "Regular");
  55         } else if (name.equals("amble bold")) {
  56             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble", "Bold");
  57         } else if (name.equals("amble italic")) {
  58             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble", "Italic");
  59         } else if (name.equals("amble bold italic")) {
  60             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble",
  61                     "Bold Italic");
  62         } else if (name.equals("amble condensed")) {
  63             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Cn", "Regular");
  64         } else if (name.equals("amble bold condensed")) {
  65             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Cn", "Bold");
  66         } else if (name.equals("amble condensed italic")) {
  67             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Cn", "Italic");
  68         } else if (name.equals("amble bold condensed italic")) {
  69             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Cn",
  70                     "Bold Italic");
  71         } else if (name.equals("amble light")) {
  72             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Lt", "Regular");
  73         } else if (name.equals("amble light italic")) {
  74             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble Lt", "Italic");
  75         } else if (name.equals("amble light condensed")) {
  76             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble LtCn",
  77                     "Regular");
  78         } else if (name.equals("amble light condensed italic")) {
  79             FontHelper.setNativeFont(font, nativeFont, font.getName(), "Amble LtCn",
  80                     "Italic");
  81         }
  82     }
  83 
  84     @Override
  85     public List<String> getFamilies() {
  86         return Arrays.asList("Amble", "Amble Cn", "Amble Lt", "Amble LtCn");
  87     }
  88 
  89     @Override
  90     public List<String> getFontNames() {
  91         return Arrays.asList("Amble Regular", "Amble Bold", "Amble Italic",
  92                 "Amble Bold Italic", "Amble Condensed", "Amble Bold Condensed",
  93                 "Amble Condensed Italic", "Amble Bold Condensed Italic",
  94                 "Amble Light", "Amble Light Italic", "Amble Light Condensed",
  95                 "Amble Light Condensed Italic");
  96     }
  97 
  98     @Override
  99     public List<String> getFontNames(String family) {


< prev index next >