1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#ifndef nsIFontMetrics_h___
40
#define nsIFontMetrics_h___
42
#include "nsISupports.h"
47
class nsIDeviceContext;
50
// IID for the nsIFontMetrics interface
51
#define NS_IFONT_METRICS_IID \
52
{ 0xc74cb770, 0xa33e, 0x11d1, \
53
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
55
//----------------------------------------------------------------------
58
* A native font handle
60
typedef void* nsFontHandle;
63
* Font metrics interface
65
* This interface may be somewhat misnamed. A better name might be
66
* nsIFontList. The style system uses the nsFont struct for various font
67
* properties, one of which is font-family, which can contain a *list* of
68
* font names. The nsFont struct is "realized" by asking the device context
69
* to cough up an nsIFontMetrics object, which contains a list of real font
70
* handles, one for each font mentioned in font-family (and for each fallback
71
* when we fall off the end of that list).
73
* The style system needs to have access to certain metrics, such as the
74
* em height (for the CSS "em" unit), and we use the first Western font's
75
* metrics for that purpose. The platform-specific implementations are
76
* expected to select non-Western fonts that "fit" reasonably well with the
77
* Western font that is loaded at Init time.
79
class nsIFontMetrics : public nsISupports
82
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
85
* Initialize the font metrics. Call this after creating the font metrics.
86
* Font metrics you get from the font cache do NOT need to be initialized
88
* @see nsIDeviceContext#GetMetricsFor()
90
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
91
nsIDeviceContext *aContext) = 0;
94
* Destroy this font metrics. This breaks the association between
95
* the font metrics and the device context.
97
NS_IMETHOD Destroy() = 0;
100
* Return the font's xheight property, scaled into app-units.
102
NS_IMETHOD GetXHeight(nscoord& aResult) = 0;
105
* Return the font's superscript offset (the distance from the
106
* baseline to where a superscript's baseline should be placed). The
107
* value returned will be a positive value.
109
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult) = 0;
112
* Return the font's subscript offset (the distance from the
113
* baseline to where a subscript's baseline should be placed). The
114
* value returned will be a positive value.
116
NS_IMETHOD GetSubscriptOffset(nscoord& aResult) = 0;
119
* Return the font's strikeout offset (the distance from the
120
* baseline to where a strikeout should be placed) and size
121
* Positive values are above the baseline, negative below.
123
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
126
* Return the font's underline offset (the distance from the
127
* baseline to where a underline should be placed) and size.
128
* Positive values are above the baseline, negative below.
130
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
133
* Returns the height (in app units) of the font. This is ascent plus descent
134
* plus any internal leading
136
* This method will be removed once the callers have been moved over to the
137
* new GetEmHeight (and possibly GetMaxHeight).
139
NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
142
#if defined(XP_WIN) || defined(XP_OS2)
143
#define FONT_LEADING_APIS_V2 1
146
#ifdef FONT_LEADING_APIS_V2
148
* Returns the amount of internal leading (in app units) for the font. This
149
* is computed as the "height - (ascent + descent)"
151
NS_IMETHOD GetInternalLeading(nscoord &aLeading) = 0;
154
* Returns the amount of external leading (in app units) as suggested by font
155
* vendor. This value is suggested by font vendor to add to normal line-height
156
* beside font height.
158
NS_IMETHOD GetExternalLeading(nscoord &aLeading) = 0;
161
* Returns the amount of internal leading (in app units) for the font. This
162
* is computed as the "height - (ascent + descent)"
164
NS_IMETHOD GetLeading(nscoord &aLeading) = 0;
167
* Returns the normal line height (em height + leading).
169
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight) = 0;
170
#endif /* FONT_LEADING_APIS_V2 */
173
* Returns the height (in app units) of the Western font's em square. This is
174
* em ascent plus em descent.
176
NS_IMETHOD GetEmHeight(nscoord &aHeight) = 0;
179
* Returns, in app units, the ascent part of the Western font's em square.
181
NS_IMETHOD GetEmAscent(nscoord &aAscent) = 0;
184
* Returns, in app units, the descent part of the Western font's em square.
186
NS_IMETHOD GetEmDescent(nscoord &aDescent) = 0;
189
* Returns the height (in app units) of the Western font's bounding box.
190
* This is max ascent plus max descent.
192
NS_IMETHOD GetMaxHeight(nscoord &aHeight) = 0;
195
* Returns, in app units, the maximum distance characters in this font extend
196
* above the base line.
198
NS_IMETHOD GetMaxAscent(nscoord &aAscent) = 0;
201
* Returns, in app units, the maximum distance characters in this font extend
202
* below the base line.
204
NS_IMETHOD GetMaxDescent(nscoord &aDescent) = 0;
207
* Returns, in app units, the maximum character advance for the font
209
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
212
* Returns the font associated with these metrics
214
NS_IMETHOD GetFont(const nsFont *&aFont) = 0;
217
* Returns the language group associated with these metrics
219
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup) = 0;
222
* Returns the font handle associated with these metrics
224
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
227
* Returns the average character width
229
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
232
* Returns the often needed width of the space character
234
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
237
#endif /* nsIFontMetrics_h___ */