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 Foundation code.
17 * The Initial Developer of the Original Code is Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2006
19 * the Initial Developer. All Rights Reserved.
22 * Stuart Parmenter <pavlov@pavlov.net>
23 * Masayuki Nakano <masayuki@d-toybox.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef GFX_WINDOWS_PLATFORM_H
40 #define GFX_WINDOWS_PLATFORM_H
42 #include "gfxFontUtils.h"
43 #include "gfxWindowsSurface.h"
44 #include "gfxWindowsFonts.h"
45 #include "gfxPlatform.h"
47 #include "nsVoidArray.h"
48 #include "nsDataHashtable.h"
52 class THEBES_API gfxWindowsPlatform
: public gfxPlatform
, private gfxFontInfoLoader
{
55 virtual ~gfxWindowsPlatform();
56 static gfxWindowsPlatform
*GetPlatform() {
57 return (gfxWindowsPlatform
*) gfxPlatform::GetPlatform();
60 already_AddRefed
<gfxASurface
> CreateOffscreenSurface(const gfxIntSize
& size
,
61 gfxASurface::gfxImageFormat imageFormat
);
63 nsresult
GetFontList(const nsACString
& aLangGroup
,
64 const nsACString
& aGenericFamily
,
65 nsStringArray
& aListOfFonts
);
67 nsresult
UpdateFontList();
69 void GetFontFamilyList(nsTArray
<nsRefPtr
<FontFamily
> >& aFamilyArray
);
71 nsresult
ResolveFontName(const nsAString
& aFontName
,
72 FontResolverCallback aCallback
,
73 void *aClosure
, PRBool
& aAborted
);
75 nsresult
GetStandardFamilyName(const nsAString
& aFontName
, nsAString
& aFamilyName
);
77 gfxFontGroup
*CreateFontGroup(const nsAString
&aFamilies
,
78 const gfxFontStyle
*aStyle
,
79 gfxUserFontSet
*aUserFontSet
);
82 * Look up a local platform font using the full font face name (needed to support @font-face src local() )
84 virtual gfxFontEntry
* LookupLocalFont(const nsAString
& aFontName
);
87 * Activate a platform font (needed to support @font-face src url() )
89 virtual gfxFontEntry
* MakePlatformFont(const gfxProxyFontEntry
*aProxyEntry
,
91 const PRUint8
*aFontData
,
95 * Check whether format is supported on a platform or not (if unclear, returns true)
97 virtual PRBool
IsFontFormatSupported(nsIURI
*aFontURI
, PRUint32 aFormatFlags
);
99 /* Given a string and a font we already have find the font that
100 * supports the most code points and most closely resembles aFont
102 * this involves looking at the fonts on your machine and seeing which
103 * code points they support as well as looking at things like the font
104 * family, style, weight, etc.
106 already_AddRefed
<gfxWindowsFont
> FindFontForChar(PRUint32 aCh
, gfxWindowsFont
*aFont
);
108 /* Find a FontFamily/FontEntry object that represents a font on your system given a name */
109 FontFamily
*FindFontFamily(const nsAString
& aName
);
110 FontEntry
*FindFontEntry(const nsAString
& aName
, const gfxFontStyle
& aFontStyle
);
112 PRBool
GetPrefFontEntries(const nsCString
& aLangGroup
, nsTArray
<nsRefPtr
<FontEntry
> > *array
);
113 void SetPrefFontEntries(const nsCString
& aLangGroup
, nsTArray
<nsRefPtr
<FontEntry
> >& array
);
115 typedef nsDataHashtable
<nsStringHashKey
, nsRefPtr
<FontFamily
> > FontTable
;
120 void InitBadUnderlineList();
122 static int CALLBACK
FontEnumProc(const ENUMLOGFONTEXW
*lpelfe
,
123 const NEWTEXTMETRICEXW
*metrics
,
124 DWORD fontType
, LPARAM data
);
125 static int CALLBACK
FamilyAddStylesProc(const ENUMLOGFONTEXW
*lpelfe
,
126 const NEWTEXTMETRICEXW
*nmetrics
,
127 DWORD fontType
, LPARAM data
);
129 static PLDHashOperator
FontGetStylesProc(nsStringHashKey::KeyType aKey
,
130 nsRefPtr
<FontFamily
>& aFontFamily
,
133 static PLDHashOperator
FontGetCMapDataProc(nsStringHashKey::KeyType aKey
,
134 nsRefPtr
<FontFamily
>& aFontFamily
,
137 static int CALLBACK
FontResolveProc(const ENUMLOGFONTEXW
*lpelfe
,
138 const NEWTEXTMETRICEXW
*metrics
,
139 DWORD fontType
, LPARAM data
);
141 static PLDHashOperator
HashEnumFunc(nsStringHashKey::KeyType aKey
,
142 nsRefPtr
<FontFamily
>& aData
,
145 static PLDHashOperator
FindFontForCharProc(nsStringHashKey::KeyType aKey
,
146 nsRefPtr
<FontFamily
>& aFontFamily
,
149 virtual cmsHPROFILE
GetPlatformCMSOutputProfile();
151 static int PrefChangedCallback(const char*, void*);
153 // gfxFontInfoLoader overrides, used to load in font cmaps
154 virtual void InitLoader();
155 virtual PRBool
RunLoader();
156 virtual void FinishLoader();
159 FontTable mFontAliases
;
160 FontTable mFontSubstitutes
;
161 nsStringArray mNonExistingFonts
;
163 // when system-wide font lookup fails for a character, cache it to skip future searches
164 gfxSparseBitSet mCodepointsWithNoFonts
;
166 nsDataHashtable
<nsCStringHashKey
, nsTArray
<nsRefPtr
<FontEntry
> > > mPrefFonts
;
168 // data used as part of the font cmap loading process
169 nsTArray
<nsRefPtr
<FontFamily
> > mFontFamilies
;
170 PRUint32 mStartIndex
;
172 PRUint32 mNumFamilies
;
175 #endif /* GFX_WINDOWS_PLATFORM_H */