2
* This program is free software; you can redistribute it and/or modify it under the
3
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
6
* You should have received a copy of the GNU Lesser General Public License along with this
7
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
8
* or from the Free Software Foundation, Inc.,
9
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
11
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
* See the GNU Lesser General Public License for more details.
15
* Copyright (c) 2006 - 2009 Pentaho Corporation and Contributors. All rights reserved.
18
package org.pentaho.reporting.libraries.fonts.truetype;
20
import org.pentaho.reporting.libraries.fonts.registry.BaselineInfo;
21
import org.pentaho.reporting.libraries.fonts.registry.FontMetrics;
22
import org.pentaho.reporting.libraries.fonts.tools.StrictGeomUtility;
26
* Creation-Date: 15.12.2005, 12:01:13
28
* @author Thomas Morgner
30
public class TrueTypeFontMetrics implements FontMetrics
32
private ScalableTrueTypeFontMetrics fontMetrics;
33
private double fontSize;
35
public TrueTypeFontMetrics(final ScalableTrueTypeFontMetrics fontMetrics,
36
final double fontSize)
38
if (fontMetrics == null)
40
throw new NullPointerException("The font must not be null");
42
this.fontMetrics = fontMetrics;
43
this.fontSize = fontSize;
47
* Is it guaranteed that the font always returns the same baseline info objct?
49
* @return true, if the baseline info in question is always the same, false otherwise.
51
public boolean isUniformFontMetrics()
57
* From the baseline to the
61
public long getAscent()
63
return (long) (fontSize * fontMetrics.getAscent());
66
public long getDescent()
68
return (long) (fontSize * fontMetrics.getDescent());
71
public long getLeading()
73
return (long) (fontSize * fontMetrics.getLeading());
76
public long getXHeight()
78
return (long) (fontSize * fontMetrics.getXHeight());
81
public long getOverlinePosition()
83
return getLeading() - Math.max (1000, StrictGeomUtility.toInternalValue(fontSize)/ 20);
86
public long getUnderlinePosition()
88
return (long) (fontSize * fontMetrics.getUnderlinePosition());
91
public long getStrikeThroughPosition()
93
return (long) (fontSize * fontMetrics.getStrikeThroughPosition());
96
public long getMaxAscent()
98
return (long) (fontSize * fontMetrics.getMaxAscent());
101
public long getMaxDescent()
103
return (long) (fontSize * fontMetrics.getMaxDescent());
106
public long getItalicAngle()
108
return fontMetrics.getItalicAngle();
111
public long getMaxHeight()
113
return (long) ((fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent() + fontMetrics.getLeading()) * fontSize);
116
public long getMaxCharAdvance()
118
return (long) (fontMetrics.getMaxCharAdvance() * fontSize);
121
public long getCharWidth(final int character)
126
public long getKerning(final int previous, final int character)
132
* Baselines are defined for scripts, not glyphs. A glyph carries script
133
* information most of the time (unless it is a neutral characters or just
139
public BaselineInfo getBaselines(final int c, final BaselineInfo info)
141
throw new UnsupportedOperationException("Not yet implemented.");