org.apache.batik.bridge.DefaultFontFamilyResolver Maven / Gradle / Ivy
The newest version!
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.apache.batik.bridge;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.batik.gvt.font.AWTFontFamily;
import org.apache.batik.gvt.font.AWTGVTFont;
import org.apache.batik.gvt.font.GVTFontFace;
import org.apache.batik.gvt.font.GVTFontFamily;
/**
* The is a utility class that is used for resolving UnresolvedFontFamilies.
*
* @author Bella Robinson
* @version $Id$
*/
public final class DefaultFontFamilyResolver implements FontFamilyResolver {
public static final DefaultFontFamilyResolver SINGLETON = new DefaultFontFamilyResolver();
private DefaultFontFamilyResolver() {
}
/**
* The default font. This will be used when no font families can
* be resolved for a particular text chunk/run.
*/
private static final AWTFontFamily DEFAULT_FONT_FAMILY =
new AWTFontFamily("SansSerif");
/**
* List of all available fonts on the current system, plus a few common
* alternatives.
*/
protected static final Map fonts = new HashMap();
protected static final List awtFontFamilies = new ArrayList();
protected static final List awtFonts = new ArrayList();
/**
* This sets up the list of available fonts.
*/
static {
fonts.put("sans-serif", "SansSerif");
fonts.put("serif", "Serif");
fonts.put("times", "Serif");
fonts.put("times new roman", "Serif");
fonts.put("cursive", "Dialog");
fonts.put("fantasy", "Symbol");
fonts.put("monospace", "Monospaced");
fonts.put("monospaced", "Monospaced");
fonts.put("courier", "Monospaced");
//
// Load all fonts. Work around
//
GraphicsEnvironment env;
env = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = env.getAvailableFontFamilyNames();
int nFonts = fontNames != null ? fontNames.length : 0;
for(int i=0; i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy