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
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.
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"
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
61 friend class gfxMacPlatformFontList
;
63 MacOSFontEntry(const nsAString
& aPostscriptName
, PRInt32 aWeight
,
64 gfxFontFamily
*aFamily
, PRBool aIsStandardFace
= PR_FALSE
);
66 ATSFontRef
GetFontRef();
69 virtual nsresult
GetFontTable(PRUint32 aTableTag
, nsTArray
<PRUint8
>& aBuffer
);
72 // for use with data fonts
73 MacOSFontEntry(const nsAString
& aPostscriptName
, ATSFontRef aFontRef
,
74 PRUint16 aWeight
, PRUint16 aStretch
, PRUint32 aItalicStyle
,
75 gfxUserFontData
*aUserFontData
);
77 virtual gfxFont
* CreateFontInstance(const gfxFontStyle
*aFontStyle
, PRBool aNeedsBold
);
79 ATSFontRef mATSFontRef
;
80 PRPackedBool mATSFontRefInitialized
;
83 class gfxMacPlatformFontList
: public gfxPlatformFontList
{
85 static gfxMacPlatformFontList
* PlatformFontList() {
86 return static_cast<gfxMacPlatformFontList
*>(sPlatformFontList
);
89 static PRInt32
AppleWeightToCSSWeight(PRInt32 aAppleWeight
);
91 virtual gfxFontEntry
* GetDefaultFont(const gfxFontStyle
* aStyle
, PRBool
& aNeedsBold
);
93 virtual PRBool
GetStandardFamilyName(const nsAString
& aFontName
, nsAString
& aFamilyName
);
95 virtual gfxFontEntry
* LookupLocalFont(const gfxProxyFontEntry
*aProxyEntry
,
96 const nsAString
& aFontName
);
98 virtual gfxFontEntry
* MakePlatformFont(const gfxProxyFontEntry
*aProxyEntry
,
99 const PRUint8
*aFontData
, PRUint32 aLength
);
101 void ClearPrefFonts() { mPrefFonts
.Clear(); }
104 friend class gfxPlatformMac
;
106 gfxMacPlatformFontList();
108 // initialize font lists
109 virtual void InitFontList();
111 // special case font faces treated as font families (set via prefs)
112 void InitSingleFaceList();
114 // eliminate faces which have the same ATS font reference
115 void EliminateDuplicateFaces(const nsAString
& aFamilyName
);
117 static void ATSNotification(ATSFontNotificationInfoRef aInfo
, void* aUserArg
);
119 // keep track of ATS generation to prevent unneeded updates when loading downloaded fonts
120 PRUint32 mATSGeneration
;
123 kATSGenerationInitial
= -1
127 #endif /* gfxMacPlatformFontList_H_ */