< prev index next >

modules/web/src/main/java/com/sun/javafx/webkit/prism/WCFontCustomPlatformDataImpl.java

Print this page




  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit.prism;
  27 
  28 import com.sun.javafx.font.FontFactory;
  29 import com.sun.javafx.font.PGFont;
  30 import com.sun.prism.GraphicsPipeline;
  31 import com.sun.webkit.graphics.WCFont;
  32 import com.sun.webkit.graphics.WCFontCustomPlatformData;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 
  36 final class WCFontCustomPlatformDataImpl extends WCFontCustomPlatformData {
  37 
  38     private final PGFont font;
  39 
  40 
  41     WCFontCustomPlatformDataImpl(InputStream inputStream) throws IOException {
  42         FontFactory factory = GraphicsPipeline.getPipeline().getFontFactory();
  43         font = factory.loadEmbeddedFont(null, inputStream, 10, false);
  44         if (font == null) {

  45             throw new IOException("Error loading font");
  46         }

  47     }
  48 
  49 
  50     @Override
  51     protected WCFont createFont(int size, boolean bold, boolean italic) {
  52         FontFactory factory = GraphicsPipeline.getPipeline().getFontFactory();
  53         return new WCFontImpl(factory.deriveFont(font, bold, italic, size));
  54     }
  55 }


  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit.prism;
  27 
  28 import com.sun.javafx.font.FontFactory;
  29 import com.sun.javafx.font.PGFont;
  30 import com.sun.prism.GraphicsPipeline;
  31 import com.sun.webkit.graphics.WCFont;
  32 import com.sun.webkit.graphics.WCFontCustomPlatformData;
  33 import java.io.IOException;
  34 import java.io.InputStream;
  35 
  36 final class WCFontCustomPlatformDataImpl extends WCFontCustomPlatformData {
  37 
  38     private final PGFont font;
  39 
  40 
  41     WCFontCustomPlatformDataImpl(InputStream inputStream) throws IOException {
  42         FontFactory factory = GraphicsPipeline.getPipeline().getFontFactory();
  43         PGFont[] fa = factory.loadEmbeddedFont(null, inputStream,
  44                                                10, false, false);
  45         if (fa == null) {
  46             throw new IOException("Error loading font");
  47         }
  48         font = fa[0];
  49     }
  50 
  51 
  52     @Override
  53     protected WCFont createFont(int size, boolean bold, boolean italic) {
  54         FontFactory factory = GraphicsPipeline.getPipeline().getFontFactory();
  55         return new WCFontImpl(factory.deriveFont(font, bold, italic, size));
  56     }
  57 }
< prev index next >