org.apache.fontbox.cff.Type1CharStringParser Maven / Gradle / Ivy
/*
* 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.fontbox.cff;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class represents a converter for a mapping into a Type 1 sequence.
*
* @see "Adobe Type 1 Font Format, Adobe Systems (1999)"
*
* @author Villu Ruusmann
* @author John Hewson
*/
public class Type1CharStringParser
{
private static final Log LOG = LogFactory.getLog(Type1CharStringParser.class);
// 1-byte commands
static final int RETURN = 11;
static final int CALLSUBR = 10;
// 2-byte commands
static final int TWO_BYTE = 12;
static final int CALLOTHERSUBR = 16;
static final int POP = 17;
private final String fontName;
private final String glyphName;
/**
* Constructs a new Type1CharStringParser object.
*
* @param fontName font name
* @param glyphName glyph name
*/
public Type1CharStringParser(String fontName, String glyphName)
{
this.fontName = fontName;
this.glyphName = glyphName;
}
/**
* The given byte array will be parsed and converted to a Type1 sequence.
*
* @param bytes the given mapping as byte array
* @param subrs list of local subroutines
* @return the Type1 sequence
* @throws IOException if an error occurs during reading
*/
public List