private Font2D getFont2D() { FontManager fm = FontManagerFactory.getInstance(); if (fm.usingPerAppContextComposites() && font2DHandle != null && font2DHandle.font2D instanceof CompositeFont && ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) { return fm.findFont2D(name, style, FontManager.LOGICAL_FALLBACK); } else if (font2DHandle == null) { font2DHandle = fm.findFont2D(name, style, FontManager.LOGICAL_FALLBACK).handle; } /* Do not cache the de-referenced font2D. It must be explicitly * de-referenced to pick up a valid font in the event that the * original one is marked invalid */ return font2DHandle.font2D; }
private Font(String name, int style, float sizePts, boolean created, Font2DHandle handle) { this(name, style, sizePts); this.createdFont = created; /* Fonts created from a stream will use the same font2D instance * as the parent. * One exception is that if the derived font is requested to be * in a different style, then also check if its a CompositeFont * and if so build a new CompositeFont from components of that style. * CompositeFonts can only be marked as "created" if they are used * to add fall backs to a physical font. And non-composites are * always from "Font.createFont()" and shouldn't get this treatment. */ if (created) { if (handle.font2D instanceof CompositeFont && handle.font2D.getStyle() != style) { FontManager fm = FontManagerFactory.getInstance(); this.font2DHandle = fm.getNewComposite(null, style, handle); } else { this.font2DHandle = handle; } } }
private Font(File fontFile, int fontFormat, boolean isCopy, CreatedFontTracker tracker) throws FontFormatException { this.createdFont = true; /* Font2D instances created by this method track their font file * so that when the Font2D is GC'd it can also remove the file. */ FontManager fm = FontManagerFactory.getInstance(); Font2D[] fonts = fm.createFont2D(fontFile, fontFormat, false, isCopy, tracker); this.font2DHandle = fonts[0].handle; this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault()); this.style = Font.PLAIN; this.size = 1; this.pointSize = 1f; }
private Font2D getFont2D() { if (FontManager.usingPerAppContextComposites && font2DHandle != null && font2DHandle.font2D instanceof CompositeFont && ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) { return FontManager.findFont2D(name, style, FontManager.LOGICAL_FALLBACK); } else if (font2DHandle == null) { font2DHandle = FontManager.findFont2D(name, style, FontManager.LOGICAL_FALLBACK).handle; } /* Do not cache the de-referenced font2D. It must be explicitly * de-referenced to pick up a valid font in the event that the * original one is marked invalid */ return font2DHandle.font2D; }
private Font(String name, int style, float sizePts, boolean created, Font2DHandle handle) { this(name, style, sizePts); this.createdFont = created; /* Fonts created from a stream will use the same font2D instance * as the parent. * One exception is that if the derived font is requested to be * in a different style, then also check if its a CompositeFont * and if so build a new CompositeFont from components of that style. * CompositeFonts can only be marked as "created" if they are used * to add fall backs to a physical font. And non-composites are * always from "Font.createFont()" and shouldn't get this treatment. */ if (created) { if (handle.font2D instanceof CompositeFont && handle.font2D.getStyle() != style) { this.font2DHandle = FontManager.getNewComposite(null, style, handle); } else { this.font2DHandle = handle; } } }
private Font(File fontFile, int fontFormat, boolean isCopy, CreatedFontTracker tracker) throws FontFormatException { this.createdFont = true; /* Font2D instances created by this method track their font file * so that when the Font2D is GC'd it can also remove the file. */ FontManager fm = FontManagerFactory.getInstance(); this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy, tracker).handle; this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault()); this.style = Font.PLAIN; this.size = 1; this.pointSize = 1f; }
private Font(AttributeValues values, String oldName, int oldStyle, boolean created, Font2DHandle handle) { this.createdFont = created; if (created) { this.font2DHandle = handle; String newName = null; if (oldName != null) { newName = values.getFamily(); if (oldName.equals(newName)) newName = null; } int newStyle = 0; if (oldStyle == -1) { newStyle = -1; } else { if (values.getWeight() >= 2f) newStyle = BOLD; if (values.getPosture() >= .2f) newStyle |= ITALIC; if (oldStyle == newStyle) newStyle = -1; } if (handle.font2D instanceof CompositeFont) { if (newStyle != -1 || newName != null) { FontManager fm = FontManagerFactory.getInstance(); this.font2DHandle = fm.getNewComposite(newName, newStyle, handle); } } else if (newName != null) { this.createdFont = false; this.font2DHandle = null; } } initFromValues(values); }
@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); }