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

org.xhtmlrenderer.util.FontUtil Maven / Gradle / Ivy

Go to download

Flying Saucer is a CSS 2.1 renderer written in Java. This artifact contains the core rendering and layout code as well as Java2D output.

There is a newer version: 9.11.0
Show newest version
package org.xhtmlrenderer.util;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Base64;
import java.util.logging.Level;

public class FontUtil {

    public static Boolean isEmbeddedBase64Font(String uri) {
        return uri != null && uri.startsWith("data:font/");
    }

    public static InputStream getEmbeddedBase64Data(String uri) {
        int b64Index = (uri!= null)? uri.indexOf("base64,") : -1;
        if (b64Index != -1) {
            String b64encoded = uri.substring(b64Index + "base64,".length());
            return new ByteArrayInputStream(Base64.getDecoder().decode(b64encoded));
        } else {
            XRLog.load(Level.SEVERE, "Embedded css fonts must be encoded in base 64.");
            return null;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy