Back to index

lightning-sunbird  0.9+nobinonly
nsFontFreeType.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Brian Stell <bstell@netscape.com>
00025  *   Louie Zhao  <louie.zhao@sun.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 #ifndef nsFontFreeType_h__
00041 #define nsFontFreeType_h__
00042 
00043 #include "gfx-config.h"
00044 #include "nsFontMetricsGTK.h"
00045 #include "nsFreeType.h"
00046 
00047 #if (!defined(MOZ_ENABLE_FREETYPE2))
00048 class nsFreeTypeFont : public nsFontGTK {
00049 public:
00050   static nsFreeTypeFont *NewFont(nsITrueTypeFontCatalogEntry*,
00051                                  PRUint16, const char *);
00052 };
00053 #else
00054 
00055 class nsFreeTypeFont : public nsFontGTK
00056 {
00057 public:
00058 
00059   nsFreeTypeFont();
00060   nsFreeTypeFont(nsITrueTypeFontCatalogEntry *, PRUint16, const char *);
00061   virtual ~nsFreeTypeFont(void);
00062   static nsFreeTypeFont *NewFont(nsITrueTypeFontCatalogEntry*,
00063                                  PRUint16, const char *);
00064 
00065   void LoadFont(void);
00066 
00067   virtual GdkFont* GetGDKFont(void);
00068   virtual PRBool   GetGDKFontIs10646(void);
00069   virtual PRBool   IsFreeTypeFont(void);
00070 
00071   virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength);
00072   virtual gint DrawString(nsRenderingContextGTK* aContext,
00073                           nsDrawingSurfaceGTK* aSurface, nscoord aX,
00074                           nscoord aY, const PRUnichar* aString,
00075                           PRUint32 aLength);
00076 #ifdef MOZ_MATHML
00077   virtual nsresult GetBoundingMetrics(const PRUnichar*   aString,
00078                                       PRUint32           aLength,
00079                                       nsBoundingMetrics& aBoundingMetrics);
00080 #endif
00081   virtual nsresult doGetBoundingMetrics(const PRUnichar*   aString,
00082                                         PRUint32 aLength,
00083                                         PRInt32* aLeftBearing,
00084                                         PRInt32* aRightBearing,
00085                                         PRInt32* aAscent,
00086                                         PRInt32* aDescent,
00087                                         PRInt32* aWidth);
00088 
00089   virtual PRUint32 Convert(const PRUnichar* aSrc, PRUint32 aSrcLen,
00090                            PRUnichar* aDest, PRUint32 aDestLen);
00091 
00092   FT_Face getFTFace();
00093   int     ascent();
00094   int     descent();
00095   PRBool  getXHeight(unsigned long &val);
00096   int     max_ascent();
00097   int     max_descent();
00098   int     max_width();
00099   PRBool  superscript_y(long &val);
00100   PRBool  subscript_y(long &val);
00101   PRBool  underlinePosition(long &val);
00102   PRBool  underline_thickness(unsigned long &val);
00103 
00104   FT_Error FaceRequester(FT_Face* aface);
00105   static void FreeGlobals();
00106 
00107   static PRUint8 sLinearWeightTable[256];
00108 
00109 protected:
00110   XImage *GetXImage(PRUint32 width, PRUint32 height);
00111   nsITrueTypeFontCatalogEntry *mFaceID;
00112   PRUint16        mPixelSize;
00113   FTC_Image_Desc  mImageDesc;
00114   nsCOMPtr<nsIFreeType2> mFt2;
00115 };
00116 
00117 void WeightTableInitCorrection(PRUint8*, PRUint8, double);
00118 
00119 #endif
00120 #endif
00121