List of usage examples for java.awt Font getPSName
public String getPSName()
From source file:org.apache.pdfbox.pdmodel.font.FontManager.java
/** * Load all available fonts from the environment. *///from ww w .j a va 2 s.c o m private static void loadFonts() { for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) { String family = normalizeFontname(font.getFamily()); String psname = normalizeFontname(font.getPSName()); if (isBoldItalic(font)) { envFonts.put(family + "bolditalic", font); } else if (isBold(font)) { envFonts.put(family + "bold", font); } else if (isItalic(font)) { envFonts.put(family + "italic", font); } else { envFonts.put(family, font); } if (!family.equals(psname)) { envFonts.put(normalizeFontname(font.getPSName()), font); } } }
From source file:org.apache.pdfbox.pdmodel.font.FontManager.java
/** * Try to determine if the font has a BOLD-type. * * @param name The font./*from ww w. j av a2 s . c om*/ * * @return font has BOLD-type or not */ private static boolean isBold(java.awt.Font font) { String name = font.getName().toLowerCase(); if (name.indexOf("bold") > -1) { return true; } String psname = font.getPSName().toLowerCase(); if (psname.indexOf("bold") > -1) { return true; } return false; }
From source file:org.apache.pdfbox.pdmodel.font.FontManager.java
/** * Try to determine if the font has an ITALIC-type. * * @param name The font./*from w ww . j a va 2 s . c o m*/ * * @return font has ITALIC-type or not */ private static boolean isItalic(java.awt.Font font) { String name = font.getName().toLowerCase(); // oblique is the same as italic if (name.indexOf("italic") > -1 || name.indexOf("oblique") > -1) { return true; } String psname = font.getPSName().toLowerCase(); if (psname.indexOf("italic") > -1 || psname.indexOf("oblique") > -1) { return true; } return false; }
From source file:org.docx4all.ui.main.WordMLEditor.java
private JEditorPane createSourceView(WordMLTextPane editorView) { //Create the Source View JEditorPane sourceView = new JEditorPane(); MutableAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setFontFamily(attrs, FontManager.getInstance().getSourceViewFontFamilyName()); StyleConstants.setFontSize(attrs, FontManager.getInstance().getSourceViewFontSize()); // TODO - only do this if the font is available. Font font = new Font("Arial Unicode MS", Font.PLAIN, 12); System.out.println(font.getFamily()); System.out.println(font.getFontName()); System.out.println(font.getPSName()); sourceView.setFont(font);/* w w w . j a va 2s.co m*/ //sourceView.setFont(FontManager.getInstance().getFontInAction(attrs)); sourceView.setContentType("text/xml; charset=UTF-16"); // Instantiate a XMLEditorKit with wrapping enabled. XMLEditorKit kit = new XMLEditorKit(true); // Set the wrapping style. kit.setWrapStyleWord(true); sourceView.setEditorKit(kit); WordMLDocument editorViewDoc = (WordMLDocument) editorView.getDocument(); try { editorViewDoc.readLock(); editorView.getWordMLEditorKit().saveCaretText(); DocumentElement elem = (DocumentElement) editorViewDoc.getDefaultRootElement(); WordprocessingMLPackage wmlPackage = ((DocumentML) elem.getElementML()).getWordprocessingMLPackage(); String filePath = (String) editorView.getDocument().getProperty(WordMLDocument.FILE_PATH_PROPERTY); //Do not include the last paragraph which is an extra paragraph. elem = (DocumentElement) elem.getElement(elem.getElementCount() - 1); ElementML paraML = elem.getElementML(); ElementML bodyML = paraML.getParent(); paraML.delete(); Document doc = DocUtil.read(sourceView, wmlPackage); doc.putProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath); doc.putProperty(WordMLDocument.WML_PACKAGE_PROPERTY, wmlPackage); doc.addDocumentListener(getToolbarStates()); //Below are the properties used by bounce.jar library //See http://www.edankert.com/bounce/xmleditorkit.html doc.putProperty(PlainDocument.tabSizeAttribute, new Integer(4)); doc.putProperty(XMLDocument.AUTO_INDENTATION_ATTRIBUTE, Boolean.TRUE); doc.putProperty(XMLDocument.TAG_COMPLETION_ATTRIBUTE, Boolean.TRUE); //Remember to put 'paraML' as last paragraph bodyML.addChild(paraML); } finally { editorViewDoc.readUnlock(); } kit.setStyle(XMLStyleConstants.ATTRIBUTE_NAME, new Color(255, 0, 0), Font.PLAIN); sourceView.addFocusListener(getToolbarStates()); //sourceView.setDocument(doc); sourceView.putClientProperty(Constants.LOCAL_VIEWS_SYNCHRONIZED_FLAG, Boolean.TRUE); return sourceView; }