~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/gfx/public/nsIFontMetrics.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 *
 
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/
 
9
 *
 
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.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
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.
 
21
 *
 
22
 * Contributor(s):
 
23
 *
 
24
 *
 
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.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
#ifndef nsIFontMetrics_h___
 
40
#define nsIFontMetrics_h___
 
41
 
 
42
#include "nsISupports.h"
 
43
#include "nsCoord.h"
 
44
 
 
45
struct nsFont;
 
46
class nsString;
 
47
class nsIDeviceContext;
 
48
class nsIAtom;
 
49
 
 
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 } }
 
54
 
 
55
//----------------------------------------------------------------------
 
56
 
 
57
/**
 
58
 * A native font handle
 
59
 */
 
60
typedef void* nsFontHandle;
 
61
 
 
62
/**
 
63
 * Font metrics interface
 
64
 *
 
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).
 
72
 *
 
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.
 
78
 */
 
79
class nsIFontMetrics : public nsISupports
 
80
{
 
81
public:
 
82
  NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
 
83
 
 
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
 
87
   *
 
88
   * @see nsIDeviceContext#GetMetricsFor()
 
89
   */
 
90
  NS_IMETHOD  Init(const nsFont& aFont, nsIAtom* aLangGroup,
 
91
                   nsIDeviceContext *aContext) = 0;
 
92
 
 
93
  /**
 
94
   * Destroy this font metrics. This breaks the association between
 
95
   * the font metrics and the device context.
 
96
   */
 
97
  NS_IMETHOD  Destroy() = 0;
 
98
 
 
99
  /**
 
100
   * Return the font's xheight property, scaled into app-units.
 
101
   */
 
102
  NS_IMETHOD  GetXHeight(nscoord& aResult) = 0;
 
103
 
 
104
  /**
 
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.
 
108
   */
 
109
  NS_IMETHOD  GetSuperscriptOffset(nscoord& aResult) = 0;
 
110
 
 
111
  /**
 
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.
 
115
   */
 
116
  NS_IMETHOD  GetSubscriptOffset(nscoord& aResult) = 0;
 
117
 
 
118
  /**
 
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.
 
122
   */
 
123
  NS_IMETHOD  GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
 
124
 
 
125
  /**
 
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.
 
129
   */
 
130
  NS_IMETHOD  GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
 
131
 
 
132
  /**
 
133
   * Returns the height (in app units) of the font. This is ascent plus descent
 
134
   * plus any internal leading
 
135
   *
 
136
   * This method will be removed once the callers have been moved over to the
 
137
   * new GetEmHeight (and possibly GetMaxHeight).
 
138
   */
 
139
  NS_IMETHOD  GetHeight(nscoord &aHeight) = 0;
 
140
 
 
141
 
 
142
#if defined(XP_WIN) || defined(XP_OS2)
 
143
#define FONT_LEADING_APIS_V2 1
 
144
#endif 
 
145
 
 
146
#ifdef FONT_LEADING_APIS_V2
 
147
  /**
 
148
   * Returns the amount of internal leading (in app units) for the font. This
 
149
   * is computed as the "height  - (ascent + descent)"
 
150
   */
 
151
  NS_IMETHOD  GetInternalLeading(nscoord &aLeading) = 0;
 
152
 
 
153
  /**
 
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.
 
157
   */
 
158
  NS_IMETHOD  GetExternalLeading(nscoord &aLeading) = 0;
 
159
#else
 
160
  /**
 
161
   * Returns the amount of internal leading (in app units) for the font. This
 
162
   * is computed as the "height  - (ascent + descent)"
 
163
   */
 
164
  NS_IMETHOD  GetLeading(nscoord &aLeading) = 0;
 
165
 
 
166
  /**
 
167
   * Returns the normal line height (em height + leading).
 
168
   */
 
169
  NS_IMETHOD  GetNormalLineHeight(nscoord &aHeight) = 0;
 
170
#endif /* FONT_LEADING_APIS_V2 */
 
171
 
 
172
  /**
 
173
   * Returns the height (in app units) of the Western font's em square. This is
 
174
   * em ascent plus em descent.
 
175
   */
 
176
  NS_IMETHOD  GetEmHeight(nscoord &aHeight) = 0;
 
177
 
 
178
  /**
 
179
   * Returns, in app units, the ascent part of the Western font's em square.
 
180
   */
 
181
  NS_IMETHOD  GetEmAscent(nscoord &aAscent) = 0;
 
182
 
 
183
  /**
 
184
   * Returns, in app units, the descent part of the Western font's em square.
 
185
   */
 
186
  NS_IMETHOD  GetEmDescent(nscoord &aDescent) = 0;
 
187
 
 
188
  /**
 
189
   * Returns the height (in app units) of the Western font's bounding box.
 
190
   * This is max ascent plus max descent.
 
191
   */
 
192
  NS_IMETHOD  GetMaxHeight(nscoord &aHeight) = 0;
 
193
 
 
194
  /**
 
195
   * Returns, in app units, the maximum distance characters in this font extend
 
196
   * above the base line.
 
197
   */
 
198
  NS_IMETHOD  GetMaxAscent(nscoord &aAscent) = 0;
 
199
 
 
200
  /**
 
201
   * Returns, in app units, the maximum distance characters in this font extend
 
202
   * below the base line.
 
203
   */
 
204
  NS_IMETHOD  GetMaxDescent(nscoord &aDescent) = 0;
 
205
 
 
206
  /**
 
207
   * Returns, in app units, the maximum character advance for the font
 
208
   */
 
209
  NS_IMETHOD  GetMaxAdvance(nscoord &aAdvance) = 0;
 
210
 
 
211
  /**
 
212
   * Returns the font associated with these metrics
 
213
   */
 
214
  NS_IMETHOD  GetFont(const nsFont *&aFont) = 0;
 
215
 
 
216
  /**
 
217
   * Returns the language group associated with these metrics
 
218
   */
 
219
  NS_IMETHOD  GetLangGroup(nsIAtom** aLangGroup) = 0;
 
220
 
 
221
  /**
 
222
   * Returns the font handle associated with these metrics
 
223
   */
 
224
  NS_IMETHOD  GetFontHandle(nsFontHandle &aHandle) = 0;
 
225
 
 
226
  /**
 
227
   * Returns the average character width
 
228
   */
 
229
  NS_IMETHOD  GetAveCharWidth(nscoord& aAveCharWidth) = 0;
 
230
 
 
231
  /**
 
232
   * Returns the often needed width of the space character
 
233
   */
 
234
  NS_IMETHOD  GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
 
235
};
 
236
 
 
237
#endif /* nsIFontMetrics_h___ */