Bug 574778 - Fix win widget's ConstrainPosition so that it supports full screen windo...
[mozilla-central.git] / gfx / src / nsIFontMetrics.h
blob185445db2f0eee9d695dae0e70b32da4478442c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (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 * http://www.mozilla.org/MPL/
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
13 * License.
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.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsIFontMetrics_h___
39 #define nsIFontMetrics_h___
41 #include "nsISupports.h"
42 #include "nsCoord.h"
43 #include "nsFont.h"
45 class nsString;
46 class nsIDeviceContext;
47 class nsIAtom;
48 class gfxUserFontSet;
50 // IID for the nsIFontMetrics interface
51 #define NS_IFONT_METRICS_IID \
52 { 0x360C5575, 0xF7AC, 0x4079, \
53 { 0xB8, 0xA6, 0x56, 0x91, 0x4B, 0xEA, 0x2A, 0xEA } }
55 //----------------------------------------------------------------------
57 /**
58 * A native font handle
60 typedef void* nsFontHandle;
62 /**
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
81 public:
82 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
84 /**
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* aLanguage,
91 nsIDeviceContext *aContext, gfxUserFontSet *aUserFontSet = nsnull) = 0;
93 /**
94 * Destroy this font metrics. This breaks the association between
95 * the font metrics and the device context.
97 NS_IMETHOD Destroy() = 0;
99 /**
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 * Returns the amount of internal leading (in app units) for the font. This
143 * is computed as the "height - (ascent + descent)"
145 NS_IMETHOD GetInternalLeading(nscoord &aLeading) = 0;
148 * Returns the amount of external leading (in app units) as suggested by font
149 * vendor. This value is suggested by font vendor to add to normal line-height
150 * beside font height.
152 NS_IMETHOD GetExternalLeading(nscoord &aLeading) = 0;
155 * Returns the height (in app units) of the Western font's em square. This is
156 * em ascent plus em descent.
158 NS_IMETHOD GetEmHeight(nscoord &aHeight) = 0;
161 * Returns, in app units, the ascent part of the Western font's em square.
163 NS_IMETHOD GetEmAscent(nscoord &aAscent) = 0;
166 * Returns, in app units, the descent part of the Western font's em square.
168 NS_IMETHOD GetEmDescent(nscoord &aDescent) = 0;
171 * Returns the height (in app units) of the Western font's bounding box.
172 * This is max ascent plus max descent.
174 NS_IMETHOD GetMaxHeight(nscoord &aHeight) = 0;
177 * Returns, in app units, the maximum distance characters in this font extend
178 * above the base line.
180 NS_IMETHOD GetMaxAscent(nscoord &aAscent) = 0;
183 * Returns, in app units, the maximum distance characters in this font extend
184 * below the base line.
186 NS_IMETHOD GetMaxDescent(nscoord &aDescent) = 0;
189 * Returns, in app units, the maximum character advance for the font
191 NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
194 * Returns the font associated with these metrics. The return value
195 * is only defined after Init() has been called.
197 const nsFont &Font() { return mFont; }
200 * Returns the language associated with these metrics
202 NS_IMETHOD GetLanguage(nsIAtom** aLanguage) = 0;
205 * Returns the font handle associated with these metrics
207 NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
210 * Returns the average character width
212 NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
215 * Returns the often needed width of the space character
217 NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
219 protected:
221 nsFont mFont; // The font for this metrics object.
224 NS_DEFINE_STATIC_IID_ACCESSOR(nsIFontMetrics, NS_IFONT_METRICS_IID)
226 #endif /* nsIFontMetrics_h___ */