Back to index

lightning-sunbird  0.9+nobinonly
nsIFontMetrics.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsIFontMetrics_h___
00039 #define nsIFontMetrics_h___
00040 
00041 #include "nsISupports.h"
00042 #include "nsCoord.h"
00043 #include "nsFont.h"
00044 
00045 class nsString;
00046 class nsIDeviceContext;
00047 class nsIAtom;
00048 
00049 // IID for the nsIFontMetrics interface
00050 #define NS_IFONT_METRICS_IID   \
00051 { 0xc74cb770, 0xa33e, 0x11d1, \
00052 { 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
00053 
00054 //----------------------------------------------------------------------
00055 
00059 typedef void* nsFontHandle;
00060 
00078 class nsIFontMetrics : public nsISupports
00079 {
00080 public:
00081   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
00082 
00083   
00089   NS_IMETHOD  Init(const nsFont& aFont, nsIAtom* aLangGroup,
00090                    nsIDeviceContext *aContext) = 0;
00091 
00096   NS_IMETHOD  Destroy() = 0;
00097 
00101   NS_IMETHOD  GetXHeight(nscoord& aResult) = 0;
00102 
00108   NS_IMETHOD  GetSuperscriptOffset(nscoord& aResult) = 0;
00109 
00115   NS_IMETHOD  GetSubscriptOffset(nscoord& aResult) = 0;
00116 
00122   NS_IMETHOD  GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
00123 
00129   NS_IMETHOD  GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
00130 
00138   NS_IMETHOD  GetHeight(nscoord &aHeight) = 0;
00139 
00140 
00141 #if defined(XP_WIN) || defined(XP_OS2)
00142 #define FONT_LEADING_APIS_V2 1
00143 #endif 
00144 
00145 #ifdef FONT_LEADING_APIS_V2
00146 
00150   NS_IMETHOD  GetInternalLeading(nscoord &aLeading) = 0;
00151 
00157   NS_IMETHOD  GetExternalLeading(nscoord &aLeading) = 0;
00158 #else
00159 
00163   NS_IMETHOD  GetLeading(nscoord &aLeading) = 0;
00164 
00168   NS_IMETHOD  GetNormalLineHeight(nscoord &aHeight) = 0;
00169 #endif /* FONT_LEADING_APIS_V2 */
00170 
00175   NS_IMETHOD  GetEmHeight(nscoord &aHeight) = 0;
00176 
00180   NS_IMETHOD  GetEmAscent(nscoord &aAscent) = 0;
00181 
00185   NS_IMETHOD  GetEmDescent(nscoord &aDescent) = 0;
00186 
00191   NS_IMETHOD  GetMaxHeight(nscoord &aHeight) = 0;
00192 
00197   NS_IMETHOD  GetMaxAscent(nscoord &aAscent) = 0;
00198 
00203   NS_IMETHOD  GetMaxDescent(nscoord &aDescent) = 0;
00204 
00208   NS_IMETHOD  GetMaxAdvance(nscoord &aAdvance) = 0;
00209 
00214   const nsFont &Font() { return mFont; }
00215 
00219   NS_IMETHOD  GetLangGroup(nsIAtom** aLangGroup) = 0;
00220 
00224   NS_IMETHOD  GetFontHandle(nsFontHandle &aHandle) = 0;
00225 
00229   NS_IMETHOD  GetAveCharWidth(nscoord& aAveCharWidth) = 0;
00230 
00234   NS_IMETHOD  GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
00235 
00236 protected:
00237 
00238   nsFont mFont;             // The font for this metrics object.
00239 };
00240 
00241 #endif /* nsIFontMetrics_h___ */