当前位置: 首页>>代码示例>>Java>>正文


Java TrueTypeFont.close方法代码示例

本文整理汇总了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();
}
 
开发者ID:torakiki,项目名称:sambox,代码行数:24,代码来源:PDFontTest.java

示例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();
    }
}
 
开发者ID:torakiki,项目名称:sambox,代码行数:19,代码来源:PDTrueTypeFont.java

示例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();
        }
    }
}
 
开发者ID:torakiki,项目名称:sambox,代码行数:25,代码来源:PDType0Font.java

示例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;
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:28,代码来源:FontUtils.java

示例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;
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:41,代码来源:FontUtils.java


注:本文中的org.apache.fontbox.ttf.TrueTypeFont.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。