// Path: src/main/java/org/fit/cssbox/io/DocumentSource.java
// public abstract class DocumentSource implements java.io.Closeable
// {
//     
//     /**
//      * Creates a new document source from an URL.
//      * @param url the document URL
//      * @throws IOException
//      */
//     public DocumentSource(URL url) throws IOException
//     {
//     }
//     
//     /**
//      * Creates a new document source based on a string representation of the URL.
//      * @param urlstring the URL string
//      * @throws IOException
//      */
//     public DocumentSource(URL base, String urlstring) throws IOException
//     {
//     }
//     
//     /**
//      * Obtains the final URL of the obtained document. This URL may be different
//      * from the URL used for DocumentSource construction, e.g. when some HTTP redirect
//      * occurs.
//      * @return the document URL.
//      */
//     abstract public URL getURL();
//     
//     /**
//      * Obtains the MIME content type of the target document.
//      * @return a MIME string.
//      */
//     abstract public String getContentType();
//     
//     /**
//      * Obtains the input stream for reading the referenced document.
//      * @return The input stream.
//      * @throws IOException
//      */
//     abstract public InputStream getInputStream() throws IOException;
// 
//     /**
//      * Closes the document source.
//      */
//     abstract public void close() throws IOException;
//     
// }


import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.fit.cssbox.io.DocumentSource;
/*
 * FontDecoder.java
 * Copyright (c) 2005-2017 Radek Burget
 *
 * CSSBox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * CSSBox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public License
 * along with CSSBox. If not, see <http://www.gnu.org/licenses/>.
 *
 * Created on 1. 11. 2017, 23:23:03 by burgetr
 */
package org.fit.cssbox.css;




/**
 *
 * @author burgetr
 */
public class FontDecoder
{
    public static List<String> supportedFormats;
    static {
        supportedFormats = new ArrayList<String>(1);
        supportedFormats.add("truetype");
    }
    
    private static Map<URL, String> registeredFonts = new HashMap<>();

    public static void registerFont(URL url, String family)
    {
        registeredFonts.put(url, family);
    }
    
    public static String findRegisteredFont(URL url)
    {
        return registeredFonts.get(url);
    }
    
// Path: src/main/java/org/fit/cssbox/io/DocumentSource.java
// public abstract class DocumentSource implements java.io.Closeable
// {
//     
//     /**
//      * Creates a new document source from an URL.
//      * @param url the document URL
//      * @throws IOException
//      */
//     public DocumentSource(URL url) throws IOException
//     {
//     }
//     
//     /**
//      * Creates a new document source based on a string representation of the URL.
//      * @param urlstring the URL string
//      * @throws IOException
//      */
//     public DocumentSource(URL base, String urlstring) throws IOException
//     {
//     }
//     
//     /**
//      * Obtains the final URL of the obtained document. This URL may be different
//      * from the URL used for DocumentSource construction, e.g. when some HTTP redirect
//      * occurs.
//      * @return the document URL.
//      */
//     abstract public URL getURL();
//     
//     /**
//      * Obtains the MIME content type of the target document.
//      * @return a MIME string.
//      */
//     abstract public String getContentType();
//     
//     /**
//      * Obtains the input stream for reading the referenced document.
//      * @return The input stream.
//      * @throws IOException
//      */
//     abstract public InputStream getInputStream() throws IOException;
// 
//     /**
//      * Closes the document source.
//      */
//     abstract public void close() throws IOException;
//     
// }


// Path: src/main/java/org/fit/cssbox/css/FontDecoder.java
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.fit.cssbox.io.DocumentSource;

/*
 * FontDecoder.java
 * Copyright (c) 2005-2017 Radek Burget
 *
 * CSSBox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * CSSBox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public License
 * along with CSSBox. If not, see <http://www.gnu.org/licenses/>.
 *
 * Created on 1. 11. 2017, 23:23:03 by burgetr
 */
package org.fit.cssbox.css;




/**
 *
 * @author burgetr
 */
public class FontDecoder
{
    public static List<String> supportedFormats;
    static {
        supportedFormats = new ArrayList<String>(1);
        supportedFormats.add("truetype");
    }
    
    private static Map<URL, String> registeredFonts = new HashMap<>();

    public static void registerFont(URL url, String family)
    {
        registeredFonts.put(url, family);
    }
    
    public static String findRegisteredFont(URL url)
    {
        return registeredFonts.get(url);
    }
    
    public static Font decodeFont(DocumentSource fontSource, String format) throws FontFormatException, IOException