001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Ilya S. Okomin
019: * @version $Revision$
020: *
021: */package org.apache.harmony.awt.gl.font;
022:
023: /**
024: * Extra font metrics: sub/superscripts sizes, offsets, average char width.
025: */
026: public class FontExtraMetrics {
027:
028: /* !! Subscript/superscript metrics are undefined for Type1. As a possible
029: * solution we can use values for Type1, that are proportionate to TrueType
030: * ones:
031: * SubscriptSizeX == 0.7 * fontSize
032: * SubscriptSizeY == 0.65 * fontSize
033: * SubscriptOffsetX == 0;
034: * SubscriptOffsetY == 0.15 * fontSize;
035: * SuperscriptSizeX == 0.7 * fontSize
036: * SuperscriptSizeY == 0.65 * fontSize
037: * SuperscriptOffsetX == 0;
038: * SuperscriptOffsetY == 0.45 * fontSize
039: *
040: */
041:
042: /*
043: * The average width of characters in the font.
044: */
045: private float lAverageCharWidth;
046:
047: /*
048: * Horizontal size for subscripts.
049: */
050: private float lSubscriptSizeX;
051:
052: /*
053: * Vertical size for subscripts.
054: */
055: private float lSubscriptSizeY;
056:
057: /*
058: * Horizontal offset for subscripts, the offset from the character origin
059: * to the origin of the subscript character.
060: */
061: private float lSubscriptOffsetX;
062:
063: /*
064: * Vertical offset for subscripts, the offset from the character origin
065: * to the origin of the subscript character.
066: */
067: private float lSubscriptOffsetY;
068:
069: /*
070: * Horizontal size for superscripts.
071: */
072: private float lSuperscriptSizeX;
073:
074: /*
075: * Vertical size for superscripts.
076: */
077: private float lSuperscriptSizeY;
078:
079: /*
080: * Horizontal offset for superscripts, the offset from the character
081: * base line to the base line of the superscript character.
082: */
083: private float lSuperscriptOffsetX;
084:
085: /*
086: * Vertical offset for superscripts, the offset from the character
087: * base line to the base line of the superscript character.
088: */
089: private float lSuperscriptOffsetY;
090:
091: public FontExtraMetrics() {
092: // default constructor
093: }
094:
095: public FontExtraMetrics(float[] metrics) {
096: lAverageCharWidth = metrics[0];
097: lSubscriptSizeX = metrics[1];
098: lSubscriptSizeY = metrics[2];
099: lSubscriptOffsetX = metrics[3];
100: lSubscriptOffsetY = metrics[4];
101: lSuperscriptSizeX = metrics[5];
102: lSuperscriptSizeY = metrics[6];
103: lSuperscriptOffsetX = metrics[7];
104: lSuperscriptOffsetY = metrics[8];
105: }
106:
107: public float getAverageCharWidth() {
108: return lAverageCharWidth;
109: }
110:
111: public float getSubscriptSizeX() {
112: return lSubscriptSizeX;
113: }
114:
115: public float getSubscriptSizeY() {
116: return lSubscriptSizeY;
117: }
118:
119: public float getSubscriptOffsetX() {
120: return lSubscriptOffsetX;
121: }
122:
123: public float getSubscriptOffsetY() {
124: return lSubscriptOffsetY;
125: }
126:
127: public float getSuperscriptSizeX() {
128: return lSuperscriptSizeX;
129: }
130:
131: public float getSuperscriptSizeY() {
132: return lSuperscriptSizeY;
133: }
134:
135: public float getSuperscriptOffsetX() {
136: return lSuperscriptOffsetX;
137: }
138:
139: public float getSuperscriptOffsetY() {
140: return lSuperscriptOffsetY;
141: }
142:
143: }
|