Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / gfx / src / thebes / nsIThebesFontMetrics.h
blob14e506fdb0576fee1951873ecc4695dbfebbfe86
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * Christopher Blizzard <blizzard@mozilla.org>.
19 * Portions created by the Initial Developer are Copyright (C) 2002
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 the GNU General Public License Version 2 or later (the "GPL"), or
26 * 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 __nsIThebesFontMetrics_h
39 #define __nsIThebesFontMetrics_h
41 #include "nsIFontMetrics.h"
42 #include "nsIRenderingContext.h"
44 class nsThebesRenderingContext;
46 class gfxFontGroup;
48 class nsIThebesFontMetrics : public nsIFontMetrics {
49 public:
50 // Get the width for this string. aWidth will be updated with the
51 // width in points, not twips. Callers must convert it if they
52 // want it in another format.
53 virtual nsresult GetWidth(const char* aString, PRUint32 aLength,
54 nscoord& aWidth, nsThebesRenderingContext *aContext) = 0;
55 // aCachedOffset will be updated with a new offset.
56 virtual nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
57 nscoord& aWidth, PRInt32 *aFontID,
58 nsThebesRenderingContext *aContext) = 0;
60 // Get the text dimensions for this string
61 virtual nsresult GetTextDimensions(const PRUnichar* aString,
62 PRUint32 aLength,
63 nsTextDimensions& aDimensions,
64 PRInt32* aFontID) = 0;
65 virtual nsresult GetTextDimensions(const char* aString,
66 PRInt32 aLength,
67 PRInt32 aAvailWidth,
68 PRInt32* aBreaks,
69 PRInt32 aNumBreaks,
70 nsTextDimensions& aDimensions,
71 PRInt32& aNumCharsFit,
72 nsTextDimensions& aLastWordDimensions,
73 PRInt32* aFontID) = 0;
74 virtual nsresult GetTextDimensions(const PRUnichar* aString,
75 PRInt32 aLength,
76 PRInt32 aAvailWidth,
77 PRInt32* aBreaks,
78 PRInt32 aNumBreaks,
79 nsTextDimensions& aDimensions,
80 PRInt32& aNumCharsFit,
81 nsTextDimensions& aLastWordDimensions,
82 PRInt32* aFontID) = 0;
84 // Draw a string using this font handle on the surface passed in.
85 virtual nsresult DrawString(const char *aString, PRUint32 aLength,
86 nscoord aX, nscoord aY,
87 const nscoord* aSpacing,
88 nsThebesRenderingContext *aContext) = 0;
89 // aCachedOffset will be updated with a new offset.
90 virtual nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
91 nscoord aX, nscoord aY,
92 PRInt32 aFontID,
93 const nscoord* aSpacing,
94 nsThebesRenderingContext *aContext) = 0;
96 #ifdef MOZ_MATHML
97 // These two functions get the bounding metrics for this handle,
98 // updating the aBoundingMetrics in Points. This means that the
99 // caller will have to update them to twips before passing it
100 // back.
101 virtual nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
102 nsThebesRenderingContext *aContext,
103 nsBoundingMetrics &aBoundingMetrics) = 0;
104 // aCachedOffset will be updated with a new offset.
105 virtual nsresult GetBoundingMetrics(const PRUnichar *aString,
106 PRUint32 aLength,
107 nsThebesRenderingContext *aContext,
108 nsBoundingMetrics &aBoundingMetrics) = 0;
109 #endif /* MOZ_MATHML */
111 // Set the direction of the text rendering
112 virtual nsresult SetRightToLeftText(PRBool aIsRTL) = 0;
113 virtual PRBool GetRightToLeftText() = 0;
114 virtual void SetTextRunRTL(PRBool aIsRTL) = 0;
116 virtual PRInt32 GetMaxStringLength() = 0;
118 virtual gfxFontGroup* GetThebesFontGroup() = 0;
121 #endif /* __nsIThebesFontMetrics_h */