1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /* $Id: OutlineFont.java 1564017 2014-02-03 19:29:24Z vhennebert $ */
19 
20 package org.apache.fop.afp.fonts;
21 
22 import java.awt.Rectangle;
23 
24 import org.apache.fop.afp.AFPEventProducer;
25 
26 /**
27  * Default implementation of AbstractOutlineFont.
28  */
29 public class OutlineFont extends AbstractOutlineFont {
30 
31     /**
32      * Construct outline font with specified name and character set.
33      * @param name font's name
34      * @param embeddable whether or not this font is embeddable
35      * @param charSet font's character set
36      * @param eventProducer Handles any AFP related events
37      */
OutlineFont(String name, boolean embeddable, CharacterSet charSet, AFPEventProducer eventProducer)38     public OutlineFont(String name, boolean embeddable, CharacterSet charSet,
39             AFPEventProducer eventProducer) {
40         super(name, embeddable, charSet, eventProducer);
41     }
42 
43     /**
44      * Obtain the width of the character for the specified point size.
45      * @param character the character
46      * @param size the font size (in mpt)
47      * @return the width of the character for the specified point size
48      */
getWidth(int character, int size)49     public int getWidth(int character, int size) {
50         return charSet.getWidth(toUnicodeCodepoint(character), size);
51     }
52 
53     @Override
getBoundingBox(int character, int size)54     public Rectangle getBoundingBox(int character, int size) {
55         return charSet.getCharacterBox(toUnicodeCodepoint(character), size);
56     }
57 }
58