2001-09-26 00:16:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifndef nsIFontMetrics_h___
|
|
|
|
#define nsIFontMetrics_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
|
|
|
|
struct nsFont;
|
|
|
|
class nsString;
|
|
|
|
class nsIDeviceContext;
|
1999-12-09 22:44:34 +00:00
|
|
|
class nsIAtom;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// IID for the nsIFontMetrics interface
|
|
|
|
#define NS_IFONT_METRICS_IID \
|
|
|
|
{ 0xc74cb770, 0xa33e, 0x11d1, \
|
|
|
|
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* A native font handle
|
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
typedef void* nsFontHandle;
|
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Font metrics interface
|
2000-04-26 21:53:26 +00:00
|
|
|
*
|
|
|
|
* This interface may be somewhat misnamed. A better name might be
|
|
|
|
* nsIFontList. The style system uses the nsFont struct for various font
|
|
|
|
* properties, one of which is font-family, which can contain a *list* of
|
|
|
|
* font names. The nsFont struct is "realized" by asking the device context
|
|
|
|
* to cough up an nsIFontMetrics object, which contains a list of real font
|
|
|
|
* handles, one for each font mentioned in font-family (and for each fallback
|
|
|
|
* when we fall off the end of that list).
|
|
|
|
*
|
|
|
|
* The style system needs to have access to certain metrics, such as the
|
|
|
|
* em height (for the CSS "em" unit), and we use the first Western font's
|
|
|
|
* metrics for that purpose. The platform-specific implementations are
|
|
|
|
* expected to select non-Western fonts that "fit" reasonably well with the
|
|
|
|
* Western font that is loaded at Init time.
|
1998-08-29 03:26:33 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIFontMetrics : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
1999-06-14 06:16:08 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
|
1999-02-12 17:13:30 +00:00
|
|
|
|
1999-12-07 23:27:17 +00:00
|
|
|
/**
|
|
|
|
* Initialize the font metrics. Call this after creating the font metrics.
|
|
|
|
* Font metrics you get from the font cache do NOT need to be initialized
|
|
|
|
*
|
|
|
|
* @see nsIDeviceContext#GetMetricsFor()
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|
|
|
nsIDeviceContext *aContext) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-09-08 22:31:51 +00:00
|
|
|
/**
|
|
|
|
* Destroy this font metrics. This breaks the association between
|
1998-10-02 01:07:56 +00:00
|
|
|
* the font metrics and the device context.
|
1998-09-08 22:31:51 +00:00
|
|
|
*/
|
|
|
|
NS_IMETHOD Destroy() = 0;
|
1998-09-10 23:41:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the font's xheight property, scaled into app-units.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetXHeight(nscoord& aResult) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the font's superscript offset (the distance from the
|
|
|
|
* baseline to where a superscript's baseline should be placed). The
|
|
|
|
* value returned will be a positive value.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the font's subscript offset (the distance from the
|
|
|
|
* baseline to where a subscript's baseline should be placed). The
|
|
|
|
* value returned will be a positive value.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetSubscriptOffset(nscoord& aResult) = 0;
|
1998-09-17 00:14:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the font's strikeout offset (the distance from the
|
|
|
|
* baseline to where a strikeout should be placed) and size
|
|
|
|
* Positive values are above the baseline, negative below.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the font's underline offset (the distance from the
|
|
|
|
* baseline to where a underline should be placed) and size.
|
|
|
|
* Positive values are above the baseline, negative below.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
|
1998-09-08 22:31:51 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the height (in app units) of the font. This is ascent plus descent
|
|
|
|
* plus any internal leading
|
2000-04-26 21:53:26 +00:00
|
|
|
*
|
|
|
|
* This method will be removed once the callers have been moved over to the
|
|
|
|
* new GetEmHeight (and possibly GetMaxHeight).
|
1998-08-29 03:26:33 +00:00
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2002-04-11 00:00:40 +00:00
|
|
|
|
2002-04-24 03:56:07 +00:00
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
2002-04-11 00:00:40 +00:00
|
|
|
#define FONT_LEADING_APIS_V2 1
|
|
|
|
#endif
|
|
|
|
|
2000-11-02 00:47:12 +00:00
|
|
|
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_MAC) || defined(XP_BEOS)
|
2000-05-04 21:46:22 +00:00
|
|
|
#define NEW_FONT_HEIGHT_APIS 1
|
|
|
|
#endif
|
|
|
|
#ifdef NEW_FONT_HEIGHT_APIS
|
2002-04-11 00:00:40 +00:00
|
|
|
#ifndef FONT_LEADING_APIS_V2
|
2000-05-04 21:46:22 +00:00
|
|
|
/**
|
|
|
|
* Returns the normal line height (em height + leading).
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight) = 0;
|
2002-04-11 00:00:40 +00:00
|
|
|
#endif /* not FONT_LEADING_APIS_V2 */
|
2000-05-04 21:46:22 +00:00
|
|
|
#endif /* NEW_FONT_HEIGHT_APIS */
|
|
|
|
|
2002-04-11 00:00:40 +00:00
|
|
|
#ifdef FONT_LEADING_APIS_V2
|
|
|
|
/**
|
|
|
|
* Returns the amount of internal leading (in app units) for the font. This
|
|
|
|
* is computed as the "height - (ascent + descent)"
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetInternalLeading(nscoord &aLeading) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the amount of external leading (in app units) as suggested by font
|
|
|
|
* vendor. This value is suggested by font vendor to add to normal line-height
|
|
|
|
* beside font height.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetExternalLeading(nscoord &aLeading) = 0;
|
|
|
|
#else
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the amount of internal leading (in app units) for the font. This
|
|
|
|
* is computed as the "height - (ascent + descent)"
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetLeading(nscoord &aLeading) = 0;
|
2002-04-11 00:00:40 +00:00
|
|
|
#endif /* FONT_LEADING_APIS_V2 */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-04-26 21:53:26 +00:00
|
|
|
#ifdef NEW_FONT_HEIGHT_APIS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the height (in app units) of the Western font's em square. This is
|
|
|
|
* em ascent plus em descent.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetEmHeight(nscoord &aHeight) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns, in app units, the ascent part of the Western font's em square.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetEmAscent(nscoord &aAscent) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns, in app units, the descent part of the Western font's em square.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetEmDescent(nscoord &aDescent) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the height (in app units) of the Western font's bounding box.
|
|
|
|
* This is max ascent plus max descent.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetMaxHeight(nscoord &aHeight) = 0;
|
|
|
|
|
|
|
|
#endif /* NEW_FONT_HEIGHT_APIS */
|
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns, in app units, the maximum distance characters in this font extend
|
|
|
|
* above the base line.
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetMaxAscent(nscoord &aAscent) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns, in app units, the maximum distance characters in this font extend
|
|
|
|
* below the base line.
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetMaxDescent(nscoord &aDescent) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns, in app units, the maximum character advance for the font
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the font associated with these metrics
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetFont(const nsFont *&aFont) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-12-07 23:27:17 +00:00
|
|
|
/**
|
|
|
|
* Returns the language group associated with these metrics
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup) = 0;
|
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the font handle associated with these metrics
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
|
2000-03-29 01:26:08 +00:00
|
|
|
|
2001-01-03 03:05:09 +00:00
|
|
|
#if defined(_WIN32) || defined(XP_OS2)
|
2000-03-29 01:26:08 +00:00
|
|
|
/**
|
|
|
|
* Returns the average character width
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
|
|
|
|
#endif
|
2001-10-30 22:58:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the often needed width of the space character
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIFontMetrics_h___ */
|