Backed out changeset b88172246b66 due to Win32 debug failures.
[mozilla-central.git] / gfx / thebes / gfxMacPlatformFontList.h
blob2eb3942eac09f32f9f763a78d95ee4301f5ba1ca
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 Corporation code.
17 * The Initial Developer of the Original Code is Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2006-2009
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Vladimir Vukicevic <vladimir@pobox.com>
23 * Masayuki Nakano <masayuki@d-toybox.com>
24 * John Daggett <jdaggett@mozilla.com>
25 * Jonathan Kew <jfkthame@gmail.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef gfxMacPlatformFontList_H_
42 #define gfxMacPlatformFontList_H_
44 #include "nsDataHashtable.h"
45 #include "nsRefPtrHashtable.h"
47 #include "gfxPlatformFontList.h"
48 #include "gfxPlatform.h"
50 #include <Carbon/Carbon.h>
52 #include "nsUnicharUtils.h"
53 #include "nsTArray.h"
55 class gfxMacPlatformFontList;
57 // a single member of a font family (i.e. a single face, such as Times Italic)
58 class MacOSFontEntry : public gfxFontEntry
60 public:
61 friend class gfxMacPlatformFontList;
63 MacOSFontEntry(const nsAString& aPostscriptName, PRInt32 aWeight,
64 gfxFontFamily *aFamily, PRBool aIsStandardFace = PR_FALSE);
66 ATSFontRef GetFontRef();
67 nsresult ReadCMAP();
69 PRBool RequiresAATLayout() const { return mRequiresAAT; }
71 virtual nsresult GetFontTable(PRUint32 aTableTag, FallibleTArray<PRUint8>& aBuffer);
73 PRBool IsCFF();
75 protected:
76 // for use with data fonts
77 MacOSFontEntry(const nsAString& aPostscriptName, ATSFontRef aFontRef,
78 PRUint16 aWeight, PRUint16 aStretch, PRUint32 aItalicStyle,
79 gfxUserFontData *aUserFontData);
81 virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle, PRBool aNeedsBold);
83 ATSFontRef mATSFontRef;
84 PRPackedBool mATSFontRefInitialized;
85 PRPackedBool mRequiresAAT;
86 PRPackedBool mIsCFF;
87 PRPackedBool mIsCFFInitialized;
90 class gfxMacPlatformFontList : public gfxPlatformFontList {
91 public:
92 static gfxMacPlatformFontList* PlatformFontList() {
93 return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
96 static PRInt32 AppleWeightToCSSWeight(PRInt32 aAppleWeight);
98 virtual gfxFontEntry* GetDefaultFont(const gfxFontStyle* aStyle, PRBool& aNeedsBold);
100 virtual PRBool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
102 virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
103 const nsAString& aFontName);
105 virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
106 const PRUint8 *aFontData, PRUint32 aLength);
108 void ClearPrefFonts() { mPrefFonts.Clear(); }
110 private:
111 friend class gfxPlatformMac;
113 gfxMacPlatformFontList();
115 // initialize font lists
116 virtual nsresult InitFontList();
118 // special case font faces treated as font families (set via prefs)
119 void InitSingleFaceList();
121 // eliminate faces which have the same ATS font reference
122 void EliminateDuplicateFaces(const nsAString& aFamilyName);
124 static void ATSNotification(ATSFontNotificationInfoRef aInfo, void* aUserArg);
126 // keep track of ATS generation to prevent unneeded updates when loading downloaded fonts
127 PRUint32 mATSGeneration;
129 enum {
130 kATSGenerationInitial = -1
134 #endif /* gfxMacPlatformFontList_H_ */