private static FontProgramDescriptor fetchDescriptorFromFontProgram(FontProgram fontProgram) { return new FontProgramDescriptor(fontProgram.getFontNames(), fontProgram.getFontMetrics()); } }
@Override public String toString() { String name = descriptor.getFontName(); if (name.length() > 0) { if (encoding != null) { return MessageFormatUtil.format("{0}+{1}", name, encoding); } else { return name; } } return super.toString(); }
/** * Search in existed fonts for PostScript name or full font name. * <p> * Note, this method has O(n) complexity. * * @param fontName PostScript or full name. * @return Collection of {@link FontInfo} from set of fonts with given PostScript or full name. */ public Collection<FontInfo> get(String fontName) { if (fontName == null || fontName.length() == 0) { return Collections.<FontInfo>emptyList(); } fontName = fontName.toLowerCase(); List<FontInfo> list = new ArrayList<>(); for (FontInfo fi : getFonts()) { if (fontName.equals(fi.getDescriptor().getFullNameLowerCase()) || fontName.equals(fi.getDescriptor().getFontNameLowerCase())) { list.add(fi); } } return list; }
boolean isFontBold = fontInfo.getDescriptor().isBold() || fontInfo.getDescriptor().getFontWeight() > 500; boolean isFontItalic = fontInfo.getDescriptor().isItalic() || fontInfo.getDescriptor().getItalicAngle() < 0; boolean isFontMonospace = fontInfo.getDescriptor().isMonospace(); int score = 0; if (!"".equals(fontFamily) && (null == fontInfo.getAlias() && fontInfo.getDescriptor().getFamilyNameLowerCase().equals(fontFamily) || (null != fontInfo.getAlias() && fontInfo.getAlias().toLowerCase().equals(fontFamily)))) { score += FONT_FAMILY_EQUALS_AWARD; } else {
boolean isFontBold = fontInfo.getDescriptor().isBold() || fontInfo.getDescriptor().getFontWeight() > 500; boolean isFontItalic = fontInfo.getDescriptor().isItalic() || fontInfo.getDescriptor().getItalicAngle() < 0; boolean isFontMonospace = fontInfo.getDescriptor().isMonospace(); int score = 0; if (!"".equals(fontFamily) && (null == fontInfo.getAlias() && fontInfo.getDescriptor().getFamilyNameLowerCase().equals(fontFamily) || (null != fontInfo.getAlias() && fontInfo.getAlias().toLowerCase().equals(fontFamily)))) { score += FONT_FAMILY_EQUALS_AWARD; } else {
/** * Search in existed fonts for PostScript name or full font name. * <p> * Note, this method has O(n) complexity. * * @param fontName PostScript or full name. * @return Collection of {@link FontInfo} from set of fonts with given PostScript or full name. */ public Collection<FontInfo> get(String fontName) { if (fontName == null || fontName.length() == 0) { return Collections.<FontInfo>emptyList(); } fontName = fontName.toLowerCase(); List<FontInfo> list = new ArrayList<>(); for (FontInfo fi : getFonts()) { if (fontName.equals(fi.getDescriptor().getFullNameLowerCase()) || fontName.equals(fi.getDescriptor().getFontNameLowerCase())) { list.add(fi); } } return list; }
private static FontProgramDescriptor fetchDescriptorFromFontProgram(FontProgram fontProgram) { return new FontProgramDescriptor(fontProgram.getFontNames(), fontProgram.getFontMetrics()); } }
@Override public String toString() { String name = descriptor.getFontName(); if (name.length() > 0) { if (encoding != null) { return MessageFormatUtil.format("{0}+{1}", name, encoding); } else { return name; } } return super.toString(); }
/** * Search in existed fonts for PostScript name or full font name. * <p> * Note, this method has O(n) complexity. * * @param fontName PostScript or full name. * @return true, if {@link FontSet} contains font with given name. */ public boolean contains(String fontName) { if (fontName == null || fontName.length() == 0) { return false; } fontName = fontName.toLowerCase(); for (FontInfo fi : getFonts()) { if (fontName.equals(fi.getDescriptor().getFullNameLowerCase()) || fontName.equals(fi.getDescriptor().getFontNameLowerCase())) { return true; } } return false; }
private static FontProgramDescriptor fetchType1FontDescriptor(String fontName, byte[] afm) throws java.io.IOException { //TODO close original stream, may be separate static method should introduced Type1Font fp = new Type1Font(fontName, null, afm, null); return new FontProgramDescriptor(fp.getFontNames(), fp.getFontMetrics()); }
public static FontInfo create(FontProgram fontProgram, String encoding, String alias, Range range) { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(fontProgram); return new FontInfo(descriptor.getFontName(), null, encoding, descriptor, range, alias); }
/** * Search in existed fonts for PostScript name or full font name. * <p> * Note, this method has O(n) complexity. * * @param fontName PostScript or full name. * @return true, if {@link FontSet} contains font with given name. */ public boolean contains(String fontName) { if (fontName == null || fontName.length() == 0) { return false; } fontName = fontName.toLowerCase(); for (FontInfo fi : getFonts()) { if (fontName.equals(fi.getDescriptor().getFullNameLowerCase()) || fontName.equals(fi.getDescriptor().getFontNameLowerCase())) { return true; } } return false; }
private static FontProgramDescriptor fetchCidFontDescriptor(String fontName) { CidFont font = new CidFont(fontName, null); return new FontProgramDescriptor(font.getFontNames(), font.getFontMetrics()); }
public static FontInfo create(FontProgram fontProgram, String encoding, String alias, Range range) { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(fontProgram); return new FontInfo(descriptor.getFontName(), null, encoding, descriptor, range, alias); }
private static FontProgramDescriptor fetchType1FontDescriptor(String fontName, byte[] afm) throws java.io.IOException { //TODO close original stream, may be separate static method should introduced Type1Font fp = new Type1Font(fontName, null, afm, null); return new FontProgramDescriptor(fp.getFontNames(), fp.getFontMetrics()); }
private static FontProgramDescriptor fetchCidFontDescriptor(String fontName) { CidFont font = new CidFont(fontName, null); return new FontProgramDescriptor(font.getFontNames(), font.getFontMetrics()); }
private static FontProgramDescriptor fetchOpenTypeFontDescriptor(OpenTypeParser fontParser) throws java.io.IOException { fontParser.loadTables(false); return new FontProgramDescriptor(fontParser.getFontNames(), fontParser.getPostTable().italicAngle, fontParser.getPostTable().isFixedPitch); }
private static FontProgramDescriptor fetchOpenTypeFontDescriptor(OpenTypeParser fontParser) throws java.io.IOException { fontParser.loadTables(false); return new FontProgramDescriptor(fontParser.getFontNames(), fontParser.getPostTable().italicAngle, fontParser.getPostTable().isFixedPitch); }