本文整理了Java中com.itextpdf.text.Font.getBaseFont()
方法的一些代码示例,展示了Font.getBaseFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Font.getBaseFont()
方法的具体详情如下:
包路径:com.itextpdf.text.Font
类名称:Font
方法名:getBaseFont
[英]Gets the BaseFont
inside this object.
[中]获取此对象内的BaseFont
。
代码示例来源:origin: stackoverflow.com
Font font = FontFactory.getFont("/fonts/Sansation_Regular.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK);
BaseFont baseFont = font.getBaseFont();
代码示例来源:origin: stackoverflow.com
Font fontBase = FontFactory.getFont("/resources/times.ttf",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED,
0.8f, Font.NORMAL,
BaseColor.BLACK);
BaseFont bf = fontBase.getBaseFont();
代码示例来源:origin: fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext5.extension
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;
}
}
代码示例来源:origin: org.technbolts/gutenberg
public BaseFont baseFont() {
return font().getBaseFont();
}
代码示例来源:origin: org.technbolts/gutenberg
protected BaseFont verbatimBaseFont() {
try {
return inconsolata();
} catch (IOException e) {
return FontFactory.getFont(FontFactory.COURIER).getBaseFont();
} catch (DocumentException e) {
return FontFactory.getFont(FontFactory.COURIER).getBaseFont();
}
}
代码示例来源:origin: com.itextpdf/itextpdf
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;
}
}
代码示例来源:origin: org.technbolts/gutenberg
@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);
}
}
代码示例来源:origin: com.itextpdf/itextg
/**
* 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);
}
代码示例来源:origin: org.technbolts/gutenberg
@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);
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* 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);
}
代码示例来源:origin: org.technbolts.tzatziki/tzatziki-pdf
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();
}
代码示例来源:origin: caryyu/excel2pdf
@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);
}
}
代码示例来源:origin: org.technbolts/gutenberg
public static FontDescriptor fontDescriptor(Font font) {
return new FontDescriptor(font, font.getBaseFont(), null, font.getSize(), font.getStyle(), font.getColor());
}
代码示例来源:origin: com.itextpdf/itextg
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) {
代码示例来源:origin: com.itextpdf/itextpdf
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) {
代码示例来源:origin: com.itextpdf/itextpdf
if (baseFont != null && !baseFont.equals(font.getBaseFont())) {
return -2;
代码示例来源:origin: com.itextpdf/itextg
if (baseFont != null && !baseFont.equals(font.getBaseFont())) {
return -2;
代码示例来源:origin: org.technbolts/gutenberg
@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();
}
}
代码示例来源:origin: org.technbolts/gutenberg
@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();
}
}
代码示例来源:origin: org.technbolts/gutenberg
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()));
}
内容来源于网络,如有侵权,请联系作者删除!