Font font = FontFactory.getFont("/fonts/Sansation_Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK); BaseFont baseFont = font.getBaseFont();
Font fontBase = FontFactory.getFont("/resources/times.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK); BaseFont bf = fontBase.getBaseFont();
public static FontGroup getUnicodeGroup( char ch, Font font, Font fontAsian, Font fontComplex ) { if ( font != null && font.getBaseFont() != null ) { if ( font.getBaseFont().charExists( ch ) ) { return WESTERN; } } if ( fontAsian != null && fontAsian.getBaseFont() != null ) { if ( fontAsian.getBaseFont().charExists( ch ) ) { return ASIAN; } } if ( fontComplex != null && fontComplex.getBaseFont() != null ) { if ( fontComplex.getBaseFont().charExists( ch ) ) { return COMPLEX; } } return WESTERN; } }
public BaseFont baseFont() { return font().getBaseFont(); }
protected BaseFont verbatimBaseFont() { try { return inconsolata(); } catch (IOException e) { return FontFactory.getFont(FontFactory.COURIER).getBaseFont(); } catch (DocumentException e) { return FontFactory.getFont(FontFactory.COURIER).getBaseFont(); } }
private boolean isSupported(Font font) { BaseFont bf = font.getBaseFont(); if (bf instanceof TrueTypeFont && BaseFont.WINANSI.equals(bf.getEncoding()) && !((TrueTypeFont) bf).isWinAnsiSupported()) { LOGGER.warn(MessageFormat.format("cmap(1, 0) not found for TrueType Font {0}, it is required for WinAnsi encoding.", font)); return false; } return true; } }
@Override public BaseFont awtToPdf(Font font) { String fontName = font.getName(); try { if ("sanserif".equalsIgnoreCase(fontName)) return FontFactory.getFont(FontFactory.HELVETICA).getBaseFont(); InputStream stream = openStream(fontName); if (stream == null) { log.error("Font resource not found for font {}", fontName); throw new RuntimeException("Font resource not found for font " + fontName); } return BaseFont.createFont( fontName + ".ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true, toByteArray(stream), null ); } catch (IOException e) { throw new RuntimeException("Failed to map font " + fontName, e); } catch (DocumentException e) { throw new RuntimeException("Failed to map font " + fontName, e); } }
/** * Adds a <CODE>Font</CODE> to be searched for valid characters. * @param font the <CODE>Font</CODE> */ public void addFont(Font font) { if (font.getBaseFont() != null) { fonts.add(font); return; } BaseFont bf = font.getCalculatedBaseFont(true); Font f2 = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor()); fonts.add(f2); }
@Override public void emit(RichText text, ITextContext context) { StringBuilder b = new StringBuilder(); Font font = text.getFont(); BaseFont baseFont = font.getBaseFont(); for (char c : text.getText().toCharArray()) { if (!baseFont.charExists(c)) { emitText(context, b, font); reset(b); emitSymbol(context, String.valueOf(c)); } else { b.append(c); } } emitText(context, b, font); }
/** * Adds a <CODE>Font</CODE> to be searched for valid characters. * @param font the <CODE>Font</CODE> */ public void addFont(Font font) { if (!isSupported(font)) { unsupportedFonts.add(font); return; } if (font.getBaseFont() != null) { fonts.add(font); return; } BaseFont bf = font.getCalculatedBaseFont(true); Font f2 = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor()); fonts.add(f2); }
private float widthPercent(FluentIterable<Tag> tags, ITextContext emitterContext) { Rectangle artBox = emitterContext.getDocumentArtBox(); Font font = headerCellStyler.cellFont(); BaseFont baseFont = font.getBaseFont(); float len = 0; for (Tag tag : tags) { float sLen = baseFont.getWidthPoint(tag.getTag(), font.getSize()); len = Math.max(len, sLen); } len = Math.min(artBox.getWidth() / 2, len); return len / artBox.getWidth(); }
@Override public void onStartPage(PdfWriter writer, Document document) { try { this.template = writer.getDirectContent().createTemplate(100, 100); this.baseFont = new Font(Resource.BASE_FONT_CHINESE, 8, Font.NORMAL).getBaseFont(); } catch (Exception e) { throw new ExceptionConverter(e); } }
public static FontDescriptor fontDescriptor(Font font) { return new FontDescriptor(font, font.getBaseFont(), null, font.getSize(), font.getStyle(), font.getColor()); }
p.setLeading(leading); p.font = font; if (font.getFamily() != FontFamily.SYMBOL && font.getFamily() != FontFamily.ZAPFDINGBATS && font.getBaseFont() == null) { int index; while((index = SpecialSymbol.index(string)) > -1) {
p.setLeading(leading); p.font = font; if (font.getFamily() != FontFamily.SYMBOL && font.getFamily() != FontFamily.ZAPFDINGBATS && font.getBaseFont() == null) { int index; while((index = SpecialSymbol.index(string)) > -1) {
if (baseFont != null && !baseFont.equals(font.getBaseFont())) { return -2;
if (baseFont != null && !baseFont.equals(font.getBaseFont())) { return -2;
@Override public void process(int level, Node node, InvocationContext context) { Font font = context.peekFont(); int style = Font.STRIKETHRU; context.pushFont(new Font(font.getBaseFont(), font.getSize(), font.getStyle() | style)); context.processChildren(level, node); context.popFont(); } }
@Override public void process(int level, Node node, InvocationContext context) { StrongEmphSuperNode emNode = (StrongEmphSuperNode) node; Font font = context.peekFont(); int style = emNode.isStrong() ? Font.BOLD : Font.ITALIC; context.pushFont(new Font(font.getBaseFont(), font.getSize(), font.getStyle() | style)); context.processChildren(level, node); context.popFont(); } }
public Font modify(Font font) { if (noModifier()) return font; int fontStyle = styleOf(font); fontStyle = overrideIfNotNull(fontStyle, style); fontStyle = applyStyleModifier(fontStyle, bold, Font.BOLD); fontStyle = applyStyleModifier(fontStyle, italic, Font.ITALIC); return new Font(font.getBaseFont(), val(size, font.getSize()), val(fontStyle, font.getStyle()), val(color, font.getColor())); }