本文整理汇总了Java中sun.font.SunFontManager类的典型用法代码示例。如果您正苦于以下问题:Java SunFontManager类的具体用法?Java SunFontManager怎么用?Java SunFontManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SunFontManager类属于sun.font包,在下文中一共展示了SunFontManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FontConfiguration
import sun.font.SunFontManager; //导入依赖的package包/类
public FontConfiguration(SunFontManager fm) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("Creating standard Font Configuration");
}
if (FontUtilities.debugFonts() && logger == null) {
logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
}
fontManager = fm;
setOsNameAndVersion(); /* static initialization */
setEncoding(); /* static initialization */
/* Separating out the file location from the rest of the
* initialisation, so the caller has the option of doing
* something else if a suitable file isn't found.
*/
findFontConfigFile();
}
示例2: drawGlyphList
import sun.font.SunFontManager; //导入依赖的package包/类
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl,
int aaHint) {
int prevBorder = 0;
boolean isColor = false;
int len = gl.getNumGlyphs();
gl.startGlyphIteration();
if (SunFontManager.getInstance().areColorGlyphsSupported()) {
for (int i = 0; i < len; i++) {
boolean newIsColor = gl.isColorGlyph(i);
if (newIsColor != isColor) {
drawGlyphListSegment(sg2d, gl, prevBorder, i, aaHint, isColor);
prevBorder = i;
isColor = newIsColor;
}
}
}
drawGlyphListSegment(sg2d, gl, prevBorder, len, aaHint, isColor);
}
示例3: PlatformFont
import sun.font.SunFontManager; //导入依赖的package包/类
public PlatformFont(String name, int style){
SunFontManager sfm = SunFontManager.getInstance();
if (sfm instanceof FontSupport) {
fontConfig = ((FontSupport)sfm).getFontConfiguration();
}
if (fontConfig == null) {
return;
}
// map given font name to a valid logical font family name
familyName = name.toLowerCase(Locale.ENGLISH);
if (!FontConfiguration.isLogicalFontFamilyName(familyName)) {
familyName = fontConfig.getFallbackFamilyName(familyName, "sansserif");
}
componentFonts = fontConfig.getFontDescriptors(familyName, style);
// search default character
//
char missingGlyphCharacter = getMissingGlyphCharacter();
defaultChar = '?';
if (componentFonts.length > 0)
defaultFont = componentFonts[0];
for (int i = 0; i < componentFonts.length; i++){
if (componentFonts[i].isExcluded(missingGlyphCharacter)) {
continue;
}
if (componentFonts[i].encoder.canEncode(missingGlyphCharacter)) {
defaultFont = componentFonts[i];
defaultChar = missingGlyphCharacter;
break;
}
}
}
示例4: getFontMetrics
import sun.font.SunFontManager; //导入依赖的package包/类
@Override
public FontMetrics getFontMetrics(Font font) {
// This is an unsupported hack, but left in for a customer.
// Do not remove.
FontManager fm = FontManagerFactory.getInstance();
if (fm instanceof SunFontManager
&& ((SunFontManager) fm).usePlatformFontMetrics()) {
return WFontMetrics.getFontMetrics(font);
}
return super.getFontMetrics(font);
}
示例5: registerJREFontsForPrinting
import sun.font.SunFontManager; //导入依赖的package包/类
public static void registerJREFontsForPrinting() {
final String pathName;
synchronized (Win32GraphicsEnvironment.class) {
GraphicsEnvironment.getLocalGraphicsEnvironment();
if (fontsForPrinting == null) {
return;
}
pathName = fontsForPrinting;
fontsForPrinting = null;
}
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
File f1 = new File(pathName);
String[] ls = f1.list(SunFontManager.getInstance().
getTrueTypeFilter());
if (ls == null) {
return null;
}
for (int i=0; i <ls.length; i++ ) {
File fontFile = new File(f1, ls[i]);
registerFontWithPlatform(fontFile.getAbsolutePath());
}
return null;
}
});
}
示例6: MFontConfiguration
import sun.font.SunFontManager; //导入依赖的package包/类
public MFontConfiguration(SunFontManager fm) {
super(fm);
if (FontUtilities.debugFonts()) {
logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
}
initTables();
}
示例7: mapFileName
import sun.font.SunFontManager; //导入依赖的package包/类
protected String mapFileName(String fileName) {
if (fileName != null && fileName.startsWith(fontsDirPrefix)) {
return SunFontManager.jreFontDirName
+ fileName.substring(fontsDirPrefix.length());
}
return fileName;
}
示例8: createFont
import sun.font.SunFontManager; //导入依赖的package包/类
/**
* Returns a new <code>Font</code> using the specified font type
* and the specified font file. The new <code>Font</code> is
* created with a point size of 1 and style {@link #PLAIN PLAIN}.
* This base font can then be used with the <code>deriveFont</code>
* methods in this class to derive new <code>Font</code> objects with
* varying sizes, styles, transforms and font features.
* @param fontFormat the type of the <code>Font</code>, which is
* {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is
* specified or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is
* specified.
* So long as the returned font, or its derived fonts are referenced
* the implementation may continue to access <code>fontFile</code>
* to retrieve font data. Thus the results are undefined if the file
* is changed, or becomes inaccessible.
* <p>
* To make the <code>Font</code> available to Font constructors the
* returned <code>Font</code> must be registered in the
* <code>GraphicsEnviroment</code> by calling
* {@link GraphicsEnvironment#registerFont(Font) registerFont(Font)}.
* @param fontFile a <code>File</code> object representing the
* input data for the font.
* @return a new <code>Font</code> created with the specified font type.
* @throws IllegalArgumentException if <code>fontFormat</code> is not
* <code>TRUETYPE_FONT</code>or<code>TYPE1_FONT</code>.
* @throws NullPointerException if <code>fontFile</code> is null.
* @throws IOException if the <code>fontFile</code> cannot be read.
* @throws FontFormatException if <code>fontFile</code> does
* not contain the required font tables for the specified format.
* @throws SecurityException if the executing code does not have
* permission to read from the file.
* @see GraphicsEnvironment#registerFont(Font)
* @since 1.5
*/
public static Font createFont(int fontFormat, File fontFile)
throws java.awt.FontFormatException, java.io.IOException {
fontFile = new File(fontFile.getPath());
if (fontFormat != Font.TRUETYPE_FONT &&
fontFormat != Font.TYPE1_FONT) {
throw new IllegalArgumentException ("font format not recognized");
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
FilePermission filePermission =
new FilePermission(fontFile.getPath(), "read");
sm.checkPermission(filePermission);
}
if (!fontFile.canRead()) {
throw new IOException("Can't read " + fontFile);
}
// create a private Font Collection and add the font data
PrivateFontCollection pfc = new PrivateFontCollection();
try {
String fileName = fontFile.getPath();
pfc.AddFontFile( fileName );
RemoveFontResourceEx( fileName );// hack for bug http://stackoverflow.com/questions/26671026/how-to-delete-the-file-of-a-privatefontcollection-addfontfile
if (false) throw new cli.System.IO.FileNotFoundException();
} catch( cli.System.IO.FileNotFoundException fnfe ) {
FileNotFoundException ex = new FileNotFoundException(fnfe.getMessage());
ex.initCause( fnfe );
throw ex;
}
// create the font object
Font2D font2D = SunFontManager.createFont2D( pfc.get_Families()[0], 0 );
Font2DHandle font2DHandle = font2D.handle;
Font font = new Font( font2D.getFontName( Locale.getDefault() ), PLAIN, 1, true, font2DHandle );
return font;
}