1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsIFontMetrics_h___
|
|
|
|
#define nsIFontMetrics_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
|
|
|
|
struct nsFont;
|
|
|
|
class nsString;
|
|
|
|
class nsIDeviceContext;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIFontMetrics : public nsISupports
|
|
|
|
{
|
1998-08-29 03:26:33 +00:00
|
|
|
// XXX what about encoding, where do we put that? MMP
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
public:
|
1998-08-29 03:26:33 +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 nsIFontCache#GetMetricsFor()
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext *aContext) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of a unicode character
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an nsString
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character string
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of a Unicode character string
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 03:26:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the width (in app units) of an 8-bit character
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidth(nsIDeviceContext *aContext, const nsString& aString, nscoord &aWidth) = 0;
|
1998-08-05 22:21:21 +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
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
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;
|
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
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
* Get the widths (in app units) of the first 256 characters of the font
|
|
|
|
*/
|
1998-08-29 02:34:34 +00:00
|
|
|
NS_IMETHOD GetWidths(const nscoord *&aWidths) = 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
|
|
|
|
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;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIFontMetrics_h___ */
|