< prev index next >
modules/graphics/src/main/java/com/sun/prism/j2d/J2DFontFactory.java
Print this page
*** 93,116 ****
* stream. I don't want to have to manage the temp file deletion here,
* so although its non-optimal I will create a temp file, provide
* input streams on it to both prism and 2D, then when they are done,
* remove it.
*/
! public PGFont loadEmbeddedFont(String name, InputStream fontStream,
! float size, boolean register) {
if (!hasPermission()) {
! return createFont(DEFAULT_FULLNAME, size);
}
! PGFont font = prismFontFactory.loadEmbeddedFont(name, fontStream,
! size, register);
!
! if (font == null) return null;
! final FontResource fr = font.getFontResource();
! registerFont(font.getFontResource());
! return font;
}
/**
* Printing uses the 2D pipeline which isn't initialised until
* printing begins, so grabs a copy of the file holding an
--- 93,123 ----
* stream. I don't want to have to manage the temp file deletion here,
* so although its non-optimal I will create a temp file, provide
* input streams on it to both prism and 2D, then when they are done,
* remove it.
*/
! public PGFont[] loadEmbeddedFont(String name, InputStream fontStream,
! float size,
! boolean register,
! boolean loadAll) {
if (!hasPermission()) {
! PGFont[] fonts = new PGFont[1];
! fonts[0] = createFont(DEFAULT_FULLNAME, size);
! return fonts;
}
! PGFont[] fonts =
! prismFontFactory.loadEmbeddedFont(name, fontStream,
! size, register, loadAll);
!
! if (fonts == null || fonts.length == 0) return null;
! final FontResource fr = fonts[0].getFontResource();
! // REMIND: this needs to be upgraded to use JDK9 createFont
! // which can handle a collection.
! registerFont(fonts[0].getFontResource());
! return fonts;
}
/**
* Printing uses the 2D pipeline which isn't initialised until
* printing begins, so grabs a copy of the file holding an
*** 137,158 ****
}
return null;
});
}
! public PGFont loadEmbeddedFont(String name, String path,
! float size, boolean register) {
if (!hasPermission()) {
! return createFont(DEFAULT_FULLNAME, size);
}
! PGFont font = prismFontFactory.loadEmbeddedFont(name, path,
! size, register);
!
! if (font == null) return null;
! final FontResource fr = font.getFontResource();
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
File file = new File(fr.getFileName());
Font font = Font.createFont(Font.TRUETYPE_FONT, file);
--- 144,172 ----
}
return null;
});
}
! public PGFont[] loadEmbeddedFont(String name, String path,
! float size,
! boolean register,
! boolean loadAll) {
if (!hasPermission()) {
! PGFont[] fonts = new PGFont[1];
! fonts[0] = createFont(DEFAULT_FULLNAME, size);
! return fonts;
}
! PGFont[] fonts =
! prismFontFactory.loadEmbeddedFont(name, path,
! size, register, loadAll);
!
! if (fonts == null || fonts.length == 0) return null;
! // REMIND: this needs to be upgraded to use JDK9 createFont
! // which can handle a collection.
! final FontResource fr = fonts[0].getFontResource();
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try {
File file = new File(fr.getFileName());
Font font = Font.createFont(Font.TRUETYPE_FONT, file);
*** 161,171 ****
e.printStackTrace();
}
return null;
}
});
! return font;
}
private static boolean compositeFontMethodsInitialized = false;
private static Method getCompositeFontUIResource = null;
--- 175,185 ----
e.printStackTrace();
}
return null;
}
});
! return fonts;
}
private static boolean compositeFontMethodsInitialized = false;
private static Method getCompositeFontUIResource = null;
< prev index next >