public FontPeer createPhysicalFontPeer(String name, int style, int size) { LinuxFont peer; int familyIndex = getFamilyIndex(name); if (familyIndex != -1){ // !! we use family names from the list with cached families because // they are differ from the family names in xlfd structure, in xlfd // family names mostly in lower case. peer = new LinuxFont(getFamily(familyIndex), style, size); peer.setFamily(getFamily(familyIndex)); return peer; } int faceIndex = getFaceIndex(name); if (faceIndex != -1){ style |= LinuxNativeFont.getFontStyle(faceIndex); name = LinuxNativeFont.getFamilyFromFaceIndex(faceIndex); peer = new LinuxFont(name, style, size); return peer; } return null; }
@Override public FontPeer createPhysicalFontPeer(String name, int style, int size) { WindowsFont peer; if (isFamilyExist(name)){ peer = new WindowsFont(name, style, size); peer.setFamily(name); return peer; } int faceIndex = getFaceIndex(name); if (faceIndex != -1){ style |= NativeFont.fontStyles[faceIndex]; name = NativeFont.getFamily(faceIndex); peer = new WindowsFont(name, style, size); return peer; } return null; }
/** * Returns default font peer class with "Default" name that is usually * used when font with specified font names and style doesn't exsist * on a system. * * @param style style of the font * @param size size of the font */ public FontPeer getDefaultFont(int style, int size){ updateFontsTable(); FontPeer peer = null; String key = DEFAULT_NAME.concat(String.valueOf(style)). concat(String.valueOf(size)); HashMapReference hmr = fontsTable.get(key); if (hmr != null) { peer = hmr.get(); } if (peer == null) { peer = createDefaultFont(style, size); ((FontPeerImpl)peer).setFamily(DEFAULT_NAME); ((FontPeerImpl)peer).setPSName(DEFAULT_NAME); ((FontPeerImpl)peer).setFontName(DEFAULT_NAME); fontsTable.put(key, new HashMapReference(key, peer, queue)); } return peer; }
@Override public FontPeer createPhysicalFontPeer(String name, int style, int size) { FontPeerImpl peer = null; if (isFontExistInList(name, style)){ try { peer = new FLFontPeer(name, style, size); peer.setFamily(name); } catch(NullPointerException e) { peer = new FLFontPeer(DEFAULT_NAME, style, size); peer.setFamily(DEFAULT_NAME); } } else { peer = new FLFontPeer(DEFAULT_NAME, style, size); peer.setFamily(DEFAULT_NAME); } return peer; }
/** * Returns default font peer class with "Default" name that is usually * used when font with specified font names and style doesn't exsist * on a system. * * @param style style of the font * @param size size of the font */ @Override public FontPeer getDefaultFont(int style, int size){ FontPeer peer = null; String key = DEFAULT_NAME.concat(String.valueOf(style)). concat(String.valueOf(size)); HashMapReference hmr = fontsTable.get(key); if (hmr != null) { peer = hmr.get(); } if (peer == null) { peer = createDefaultFont(style, size); ((FontPeerImpl)peer).setFamily(DEFAULT_NAME); ((FontPeerImpl)peer).setPSName(DEFAULT_NAME); ((FontPeerImpl)peer).setFontName(DEFAULT_NAME); fontsTable.put(key, new HashMapReference(key, peer, queue)); } return peer; }
@SuppressWarnings("deprecation") final FontPeer getPeer_NoClientCode() { if(peer == null) { Toolkit tk = Toolkit.getDefaultToolkit(); this.peer = tk.getFontPeer(name, style); } return peer; }
/** * Gets the peer of this {@code Font}. * * @return the peer of the {@code Font}. */ private FontPeer getFontPeer() { if(peer == null) { Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof ComponentFactory) { peer = ((ComponentFactory) tk).getFontPeer(name, style); } } return peer; }
@Override public FontPeer getFontPeer(String name, int style) { if (componentFactory != null) { return componentFactory.getFontPeer(name, style); } return null; }
public void setFont(Font f) { super.setFont(f); FontPeer p = getFont().getPeer(); if (p instanceof XFontPeer) { XFontPeer xFontPeer = (XFontPeer) p; xgc.set_font(xFontPeer.getXFont()); } }
public void drawString(String s, int x, int y) { FontPeer p = getFont().getPeer(); if (p instanceof XFontPeer) { int tx = (int) transform.getTranslateX(); int ty = (int) transform.getTranslateY(); xdrawable.text(xgc, x + tx, y + ty, s); } else { super.drawString(s, x, y); } }
/** * Private method that allows size to be set at initialization time. */ private FontPeer getFontPeer (String name, int style, int size) { Map<TextAttribute,Object> attrs = new HashMap<TextAttribute,Object>(); ClasspathFontPeer.copyStyleToAttrs (style, attrs); ClasspathFontPeer.copySizeToAttrs (size, attrs); return getClasspathFontPeer (name, attrs); }
protected FontPeer getFontPeer(String name, int style) { Map attrs = new HashMap (); ClasspathFontPeer.copyStyleToAttrs(style, attrs); ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12. return getClasspathFontPeer (name, attrs); }
final FontPeer getPeer_NoClientCode() { if(peer == null) { Toolkit tk = Toolkit.getDefaultToolkit(); this.peer = tk.getFontPeer(name, style); } return peer; }
/** * Returns platform-dependent Font peer created from the specified * Font object from the table with cached FontPeers instances. * * Note, this method checks whether FontPeer with specified parameters * exists in the table with cached FontPeers' instances. If there is no needed * instance - it is created and cached. * * @param fontName name of the font * @param _fontStyle style of the font * @param size font size * * @return platform dependent FontPeer implementation created from * the specified parameters */ public FontPeer getFontPeer(String fontName, int _fontStyle, int size) { updateFontsTable(); FontPeer peer = null; String key; String name; int fontStyle = _fontStyle; int logicalIndex = getLogicalFaceIndex(fontName); if (logicalIndex != -1){ name = getLogicalFaceFromFont(fontStyle, logicalIndex); fontStyle = getStyleFromLogicalFace(name); key = name.concat(String.valueOf(size)); } else { name = fontName; key = name.concat(String.valueOf(fontStyle)). concat(String.valueOf(size)); } HashMapReference hmr = fontsTable.get(key); if (hmr != null) { peer = hmr.get(); } if (peer == null) { peer = createFontPeer(name, fontStyle, size, logicalIndex); if (peer == null){ peer = getFontPeer(DIALOG_NAME, fontStyle, size); } fontsTable.put(key, new HashMapReference(key, peer, queue)); } return peer; }
/** * Returns instance of font peer (logical or physical) according to the * specified parameters. * * @param name font face name * @param style style of the font * @param size size of the font * @param logicalIndex index of the logical face name in LOGICAL_FONT_FACES * array or -1 if desired font peer is not logical. */ protected FontPeer createFontPeer(String name, int style, int size, int logicalIndex){ FontPeer peer; if (logicalIndex != -1){ peer = createLogicalFontPeer(name, style, size); }else { peer = createPhysicalFontPeer(name, style, size); } return peer; }