本文整理汇总了Java中org.apache.fontbox.ttf.TrueTypeFont.close方法的典型用法代码示例。如果您正苦于以下问题:Java TrueTypeFont.close方法的具体用法?Java TrueTypeFont.close怎么用?Java TrueTypeFont.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.fontbox.ttf.TrueTypeFont
的用法示例。
在下文中一共展示了TrueTypeFont.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPDFBox3826
import org.apache.fontbox.ttf.TrueTypeFont; //导入方法依赖的package包/类
/**
* PDFBOX-3826: Test ability to reuse a TrueTypeFont created from a file or a stream for several PDFs to avoid
* parsing it over and over again. Also check that full or partial embedding is done, and do render and text
* extraction.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void testPDFBox3826() throws IOException, URISyntaxException
{
URL url = PDFontTest.class.getClassLoader()
.getResource("org/sejda/sambox/ttf/LiberationSans-Regular.ttf");
File fontFile = new File(url.toURI());
TrueTypeFont ttf1 = new TTFParser().parse(fontFile);
testPDFBox3826checkFonts(testPDFBox3826createDoc(ttf1), fontFile);
ttf1.close();
TrueTypeFont ttf2 = new TTFParser().parse(new FileInputStream(fontFile));
testPDFBox3826checkFonts(testPDFBox3826createDoc(ttf2), fontFile);
ttf2.close();
}
示例2: PDTrueTypeFont
import org.apache.fontbox.ttf.TrueTypeFont; //导入方法依赖的package包/类
/**
* Creates a new TrueType font for embedding.
*/
private PDTrueTypeFont(TrueTypeFont ttf, Encoding encoding, boolean closeTTF) throws IOException
{
PDTrueTypeFontEmbedder embedder = new PDTrueTypeFontEmbedder(dict, ttf, encoding);
this.encoding = encoding;
this.ttf = ttf;
setFontDescriptor(embedder.getFontDescriptor());
isEmbedded = true;
isDamaged = false;
glyphList = GlyphList.getAdobeGlyphList();
if (closeTTF)
{
// the TTF is fully loaded and it is save to close the underlying data source
ttf.close();
}
}
示例3: PDType0Font
import org.apache.fontbox.ttf.TrueTypeFont; //导入方法依赖的package包/类
/**
* Private. Creates a new TrueType font for embedding.
*/
private PDType0Font(PDDocument document, TrueTypeFont ttf, boolean embedSubset,
boolean closeOnSubset)
throws IOException
{
embedder = new PDCIDFontType2Embedder(document, dict, ttf, embedSubset, this);
descendantFont = embedder.getCIDFont();
readEncoding();
fetchCMapUCS2();
if (closeOnSubset)
{
if (embedSubset)
{
this.ttf = ttf;
}
else
{
// the TTF is fully loaded and it is safe to close the underlying data source
ttf.close();
}
}
}
示例4: loadOriginal
import org.apache.fontbox.ttf.TrueTypeFont; //导入方法依赖的package包/类
/**
* Tries to load the original full font from the system
*/
public PDFont loadOriginal(PDDocument document) {
String lookupName = fontName.replace("-", " ");
LOG.debug("Searching the system for a font matching name '{}'", lookupName);
FontMapping<TrueTypeFont> fontMapping = FontMappers.instance().getTrueTypeFont(lookupName, null);
if (fontMapping != null && fontMapping.getFont() != null && !fontMapping.isFallback()) {
TrueTypeFont mappedFont = fontMapping.getFont();
try {
LOG.debug("Original font available on the system: {}", fontName);
return PDType0Font.load(document, mappedFont.getOriginalData());
} catch (IOException ioe) {
LOG.warn("Failed to load font from system", ioe);
try {
mappedFont.close();
} catch (IOException e) {
LOG.warn("Failed closing font", e);
}
}
}
return null;
}
示例5: loadSimilar
import org.apache.fontbox.ttf.TrueTypeFont; //导入方法依赖的package包/类
/**
* Tries to load a similar full font from the system
*/
public PDFont loadSimilar(PDDocument document) {
String lookupName = fontName.replace("-", " ");
// Eg: Arial-BoldMT
PDFontDescriptor descriptor = new PDFontDescriptor(new COSDictionary());
descriptor.setFontName(fontName.split("-")[0]);
descriptor.setForceBold(FontUtils.isBold(subsetFont));
descriptor.setItalic(FontUtils.isItalic(subsetFont));
LOG.debug(
"Searching the system for a font matching name '{}' and description [name:{}, bold:{}, italic:{}]",
lookupName, descriptor.getFontName(), descriptor.isForceBold(), descriptor.isItalic());
FontMapping<TrueTypeFont> fontMapping = FontMappers.instance().getTrueTypeFont(lookupName, descriptor);
if (fontMapping != null && fontMapping.getFont() != null) {
TrueTypeFont mappedFont = fontMapping.getFont();
try {
if (fontMapping.isFallback()) {
LOG.debug("Fallback font available on the system: {} (for {})", mappedFont.getName(), fontName);
} else {
LOG.debug("Original font available on the system: {}", fontName);
}
return PDType0Font.load(document, mappedFont.getOriginalData());
} catch (IOException ioe) {
LOG.warn("Failed to load font from system", ioe);
try {
mappedFont.close();
} catch (Exception e) {
LOG.warn("Failed closing font", e);
}
}
}
return null;
}