All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.openhtmltopdf.outputdevice.helper.FontFaceFontSupplier Maven / Gradle / Ivy

Go to download

Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact contains the core rendering and layout code.

There is a newer version: 1.0.10
Show newest version
package com.openhtmltopdf.outputdevice.helper;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.openhtmltopdf.extend.FSSupplier;
import com.openhtmltopdf.layout.SharedContext;
import com.openhtmltopdf.util.XRLog;

public class FontFaceFontSupplier implements FSSupplier {
    private final String src;
    private final SharedContext ctx;
    
    public FontFaceFontSupplier(SharedContext ctx, String src) {
        this.src = src;
        this.ctx = ctx;
    }
    
    @Override
    public InputStream supply() {
        byte[] font1 = ctx.getUserAgentCallback().getBinaryResource(src);
        
        if (font1 == null) {
            XRLog.exception("Could not load @font-face font: " + src);
            return null;
        }
        
        return new ByteArrayInputStream(font1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy