KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > afp > fonts > FopCharacterSet


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: FopCharacterSet.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.fonts;
21
22 import org.apache.fop.fonts.Typeface;
23
24 /**
25  * A Character set for a normal FOP font<p/>
26  */

27 public class FopCharacterSet extends CharacterSet {
28
29     /** The character set for this font */
30     private Typeface _characterSet = null;
31     private int _size = 0;
32
33     /**
34      * Constructor for the CharacterSetMetric object, the character set is used
35      * to load the font information from the actual AFP font.
36      * @param codePage the code page identifier
37      * @param encoding the encoding of the font
38      * @param name the character set name
39      * @param size the font size
40      * @param characterSet the fop character set
41      */

42     public FopCharacterSet(
43         String JavaDoc codePage,
44         String JavaDoc encoding,
45         String JavaDoc name,
46         int size,
47         Typeface characterSet) {
48         super(codePage, encoding, name, null);
49         _characterSet = characterSet;
50         _size = size * 1000;
51     }
52
53     /**
54      * Ascender height is the distance from the character baseline to the
55      * top of the character box. A negative ascender height signifies that
56      * all of the graphic character is below the character baseline. For
57      * a character rotation other than 0, ascender height loses its
58      * meaning when the character is lying on its side or is upside down
59      * with respect to normal viewing orientation. For the general case,
60      * Ascender Height is the character´┐Żs most positive y-axis value.
61      * For bounded character boxes, for a given character having an
62      * ascender, ascender height and baseline offset are equal.
63      * @return the ascender value in millipoints
64      */

65     public int getAscender() {
66         return _characterSet.getAscender(_size);
67     }
68
69     /**
70      * Cap height is the average height of the uppercase characters in
71      * a font. This value is specified by the designer of a font and is
72      * usually the height of the uppercase M.
73      * @return the cap height value in millipoints
74      */

75     public int getCapHeight() {
76         return _characterSet.getCapHeight(_size);
77     }
78
79     /**
80      * Descender depth is the distance from the character baseline to
81      * the bottom of a character box. A negative descender depth signifies
82      * that all of the graphic character is above the character baseline.
83      * @return the descender value in millipoints
84      */

85     public int getDescender() {
86         return _characterSet.getDescender(_size);
87     }
88
89     /**
90      * The first character in the character set
91      * @return the first character
92      */

93     public int getFirstChar() {
94         return 0;
95     }
96
97     /**
98      * The last character in the character set
99      * @return the last character
100      */

101     public int getLastChar() {
102         return 0;
103     }
104
105     /**
106      * Get the width (in 1/1000ths of a point size) of all characters
107      * @return the widths of all characters
108      */

109     public int[] getWidths() {
110         return _characterSet.getWidths();
111     }
112
113     /**
114      * XHeight refers to the height of the lower case letters above the baseline.
115      * @return the typical height of characters
116      */

117     public int getXHeight() {
118         return _characterSet.getXHeight(_size);
119     }
120
121     /**
122      * Get the width (in 1/1000ths of a point size) of the character
123      * identified by the parameter passed.
124      * @param character the character from which the width will be calculated
125      * @return the width of the character
126      */

127     public int width(int character) {
128         return _characterSet.getWidth(character, _size);
129     }
130
131     /**
132      * Map a Unicode character to a code point in the font.
133      * @param c character to map
134      * @return the mapped character
135      */

136     public char mapChar(char c) {
137         return _characterSet.mapChar(c);
138     }
139
140 }
Popular Tags