2009-10-07 07:13:40 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
#define FORCE_PR_LOG /* Allow logging in the release build */
|
|
|
|
#endif
|
|
|
|
#include "prlog.h"
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
#include "gfxGDIFontList.h"
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "gfxFontUtils.h"
|
2010-03-15 02:34:25 -07:00
|
|
|
#include "gfxGDIFont.h"
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsUnicharUtils.h"
|
|
|
|
|
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsISimpleEnumerator.h"
|
|
|
|
#include "nsIWindowsRegKey.h"
|
|
|
|
|
2011-07-26 23:42:53 -07:00
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
|
2010-03-15 02:34:25 -07:00
|
|
|
#include <usp10.h>
|
2012-02-23 06:53:55 -08:00
|
|
|
#include <t2embapi.h>
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2011-07-26 23:42:53 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
#define ROUND(x) floor((x) + 0.5)
|
|
|
|
|
2010-05-26 22:05:30 -07:00
|
|
|
|
|
|
|
#ifndef CLEARTYPE_QUALITY
|
|
|
|
#define CLEARTYPE_QUALITY 5
|
|
|
|
#endif
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
#ifdef PR_LOGGING
|
2011-01-21 08:44:33 -08:00
|
|
|
#define LOG_FONTLIST(args) PR_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
|
|
|
|
PR_LOG_DEBUG, args)
|
|
|
|
#define LOG_FONTLIST_ENABLED() PR_LOG_TEST( \
|
|
|
|
gfxPlatform::GetLog(eGfxLog_fontlist), \
|
|
|
|
PR_LOG_DEBUG)
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-03-08 18:05:14 -08:00
|
|
|
#define LOG_CMAPDATA_ENABLED() PR_LOG_TEST( \
|
|
|
|
gfxPlatform::GetLog(eGfxLog_cmapdata), \
|
|
|
|
PR_LOG_DEBUG)
|
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#endif // PR_LOGGING
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
// font info loader constants
|
2011-01-21 08:44:32 -08:00
|
|
|
|
|
|
|
// avoid doing this during startup even on slow machines but try to start
|
|
|
|
// it soon enough so that system fallback doesn't happen first
|
2012-08-22 08:56:38 -07:00
|
|
|
static const uint32_t kDelayBeforeLoadingFonts = 120 * 1000; // 2 minutes after init
|
|
|
|
static const uint32_t kIntervalBetweenLoadingFonts = 2000; // every 2 seconds until complete
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
static __inline void
|
|
|
|
BuildKeyNameFromFontName(nsAString &aName)
|
|
|
|
{
|
|
|
|
if (aName.Length() >= LF_FACESIZE)
|
|
|
|
aName.Truncate(LF_FACESIZE - 1);
|
|
|
|
ToLowerCase(aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implementation of gfxPlatformFontList for Win32 GDI,
|
|
|
|
// using GDI font enumeration APIs to get the list of fonts
|
|
|
|
|
2012-03-19 15:52:08 -07:00
|
|
|
typedef LONG
|
|
|
|
(WINAPI *TTLoadEmbeddedFontProc)(HANDLE* phFontReference, ULONG ulFlags,
|
|
|
|
ULONG* pulPrivStatus, ULONG ulPrivs,
|
|
|
|
ULONG* pulStatus,
|
|
|
|
READEMBEDPROC lpfnReadFromStream,
|
|
|
|
LPVOID lpvReadStream,
|
|
|
|
LPWSTR szWinFamilyName,
|
|
|
|
LPSTR szMacFamilyName,
|
|
|
|
TTLOADINFO* pTTLoadInfo);
|
|
|
|
|
|
|
|
typedef LONG
|
|
|
|
(WINAPI *TTDeleteEmbeddedFontProc)(HANDLE hFontReference, ULONG ulFlags,
|
|
|
|
ULONG* pulStatus);
|
|
|
|
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
static TTLoadEmbeddedFontProc TTLoadEmbeddedFontPtr = nullptr;
|
|
|
|
static TTDeleteEmbeddedFontProc TTDeleteEmbeddedFontPtr = nullptr;
|
2012-02-28 08:04:05 -08:00
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
class WinUserFontData : public gfxUserFontData {
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
WinUserFontData(HANDLE aFontRef, bool aIsEmbedded)
|
2010-07-16 18:32:18 -07:00
|
|
|
: mFontRef(aFontRef), mIsEmbedded(aIsEmbedded)
|
2009-10-07 07:13:40 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual ~WinUserFontData()
|
|
|
|
{
|
2010-07-16 18:32:18 -07:00
|
|
|
if (mIsEmbedded) {
|
2009-10-07 07:13:40 -07:00
|
|
|
ULONG pulStatus;
|
2010-07-16 18:32:18 -07:00
|
|
|
LONG err;
|
2012-03-19 15:52:08 -07:00
|
|
|
err = TTDeleteEmbeddedFontPtr(mFontRef, 0, &pulStatus);
|
2010-07-16 18:32:18 -07:00
|
|
|
#if DEBUG
|
|
|
|
if (err != E_NONE) {
|
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "error deleting embedded font handle (%p) - TTDeleteEmbeddedFont returned %8.8x", mFontRef, err);
|
|
|
|
NS_ASSERTION(err == E_NONE, buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else {
|
2012-10-04 01:35:15 -07:00
|
|
|
DebugOnly<BOOL> success;
|
2010-07-16 18:32:18 -07:00
|
|
|
success = RemoveFontMemResourceEx(mFontRef);
|
|
|
|
#if DEBUG
|
|
|
|
if (!success) {
|
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "error deleting font handle (%p) - RemoveFontMemResourceEx failed", mFontRef);
|
|
|
|
NS_ASSERTION(success, buf);
|
|
|
|
}
|
|
|
|
#endif
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE mFontRef;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsEmbedded;
|
2009-10-07 07:13:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
BYTE
|
2012-08-22 08:56:38 -07:00
|
|
|
FontTypeToOutPrecision(uint8_t fontType)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
BYTE ret;
|
|
|
|
switch (fontType) {
|
|
|
|
case GFX_FONT_TYPE_TT_OPENTYPE:
|
|
|
|
case GFX_FONT_TYPE_TRUETYPE:
|
|
|
|
ret = OUT_TT_ONLY_PRECIS;
|
|
|
|
break;
|
|
|
|
case GFX_FONT_TYPE_PS_OPENTYPE:
|
|
|
|
ret = OUT_PS_ONLY_PRECIS;
|
|
|
|
break;
|
|
|
|
case GFX_FONT_TYPE_TYPE1:
|
|
|
|
ret = OUT_OUTLINE_PRECIS;
|
|
|
|
break;
|
|
|
|
case GFX_FONT_TYPE_RASTER:
|
|
|
|
ret = OUT_RASTER_PRECIS;
|
|
|
|
break;
|
|
|
|
case GFX_FONT_TYPE_DEVICE:
|
|
|
|
ret = OUT_DEVICE_PRECIS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = OUT_DEFAULT_PRECIS;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
*
|
|
|
|
* GDIFontEntry
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-09-05 00:34:40 -07:00
|
|
|
GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
|
|
|
|
gfxWindowsFontType aFontType,
|
2012-08-22 08:56:38 -07:00
|
|
|
bool aItalic, uint16_t aWeight, int16_t aStretch,
|
2012-07-03 03:42:07 -07:00
|
|
|
gfxUserFontData *aUserFontData,
|
|
|
|
bool aFamilyHasItalicFace)
|
2011-09-05 00:34:40 -07:00
|
|
|
: gfxFontEntry(aFaceName),
|
|
|
|
mWindowsFamily(0), mWindowsPitch(0),
|
|
|
|
mFontType(aFontType),
|
2012-04-18 16:59:43 -07:00
|
|
|
mForceGDI(false),
|
2012-07-03 03:42:07 -07:00
|
|
|
mFamilyHasItalicFace(aFamilyHasItalicFace),
|
2011-09-05 00:34:40 -07:00
|
|
|
mCharset(), mUnicodeRanges()
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
mUserFontData = aUserFontData;
|
|
|
|
mItalic = aItalic;
|
|
|
|
mWeight = aWeight;
|
2011-09-05 00:34:40 -07:00
|
|
|
mStretch = aStretch;
|
2009-10-07 07:13:40 -07:00
|
|
|
if (IsType1())
|
2011-10-17 07:59:28 -07:00
|
|
|
mForceGDI = true;
|
2012-07-30 07:20:58 -07:00
|
|
|
mIsUserFont = aUserFontData != nullptr;
|
2010-05-26 22:05:30 -07:00
|
|
|
|
2010-06-08 17:33:13 -07:00
|
|
|
InitLogFont(aFaceName, aFontType);
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
GDIFontEntry::ReadCMAP()
|
|
|
|
{
|
2012-04-18 16:59:43 -07:00
|
|
|
// attempt this once, if errors occur leave a blank cmap
|
|
|
|
if (mCharacterMap) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-06-25 05:43:10 -07:00
|
|
|
// skip non-SFNT fonts completely
|
|
|
|
if (mFontType != GFX_FONT_TYPE_PS_OPENTYPE &&
|
|
|
|
mFontType != GFX_FONT_TYPE_TT_OPENTYPE &&
|
|
|
|
mFontType != GFX_FONT_TYPE_TRUETYPE)
|
|
|
|
{
|
2012-04-18 16:59:43 -07:00
|
|
|
mCharacterMap = new gfxCharacterMap();
|
2012-04-27 01:26:41 -07:00
|
|
|
mCharacterMap->mBuildOnTheFly = true;
|
2010-06-25 05:43:10 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-04-18 16:59:43 -07:00
|
|
|
nsRefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
|
2012-04-08 21:31:55 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
|
2012-04-18 16:59:43 -07:00
|
|
|
nsresult rv;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
AutoFallibleTArray<uint8_t,16384> cmap;
|
2012-04-18 16:59:43 -07:00
|
|
|
rv = GetFontTable(kCMAP, cmap);
|
|
|
|
|
|
|
|
bool unicodeFont = false, symbolFont = false; // currently ignored
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-04-18 16:59:43 -07:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = gfxFontUtils::ReadCMAP(cmap.Elements(), cmap.Length(),
|
|
|
|
*charmap, mUVSOffset,
|
|
|
|
unicodeFont, symbolFont);
|
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
mSymbolFont = symbolFont;
|
2012-04-18 16:59:43 -07:00
|
|
|
|
2009-10-07 10:16:52 -07:00
|
|
|
mHasCmapTable = NS_SUCCEEDED(rv);
|
2012-04-18 16:59:43 -07:00
|
|
|
if (mHasCmapTable) {
|
|
|
|
gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
|
|
|
|
mCharacterMap = pfl->FindCharMap(charmap);
|
|
|
|
} else {
|
|
|
|
// if error occurred, initialize to null cmap
|
|
|
|
mCharacterMap = new gfxCharacterMap();
|
|
|
|
// For fonts where we failed to read the character map,
|
|
|
|
// we can take a slow path to look up glyphs character by character
|
|
|
|
mCharacterMap->mBuildOnTheFly = true;
|
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-01-21 08:44:33 -08:00
|
|
|
#ifdef PR_LOGGING
|
2012-04-18 16:59:43 -07:00
|
|
|
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d hash: %8.8x%s\n",
|
2012-03-27 14:38:39 -07:00
|
|
|
NS_ConvertUTF16toUTF8(mName).get(),
|
2012-04-18 16:59:43 -07:00
|
|
|
charmap->SizeOfIncludingThis(moz_malloc_size_of),
|
|
|
|
charmap->mHash, mCharacterMap == charmap ? " new" : ""));
|
2012-03-08 18:05:14 -08:00
|
|
|
if (LOG_CMAPDATA_ENABLED()) {
|
|
|
|
char prefix[256];
|
|
|
|
sprintf(prefix, "(cmapdata) name: %.220s",
|
|
|
|
NS_ConvertUTF16toUTF8(mName).get());
|
2012-04-18 16:59:43 -07:00
|
|
|
charmap->Dump(prefix, eGfxLog_cmapdata);
|
2012-03-08 18:05:14 -08:00
|
|
|
}
|
2011-01-21 08:44:33 -08:00
|
|
|
#endif
|
2012-04-18 16:59:43 -07:00
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-05-19 23:09:30 -07:00
|
|
|
GDIFontEntry::IsSymbolFont()
|
|
|
|
{
|
|
|
|
// initialize cmap first
|
|
|
|
HasCmapTable();
|
|
|
|
return mSymbolFont;
|
|
|
|
}
|
|
|
|
|
2009-10-07 08:26:58 -07:00
|
|
|
gfxFont *
|
2011-09-28 23:19:26 -07:00
|
|
|
GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold)
|
2009-10-07 08:26:58 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isXP = (gfxWindowsPlatform::WindowsOSVersion()
|
2010-05-26 22:05:30 -07:00
|
|
|
< gfxWindowsPlatform::kWindowsVista);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool useClearType = isXP && !aFontStyle->systemFont &&
|
2010-05-26 22:05:30 -07:00
|
|
|
(gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() ||
|
2010-06-08 17:33:13 -07:00
|
|
|
(mIsUserFont && !mIsLocalUserFont &&
|
2010-05-26 22:05:30 -07:00
|
|
|
gfxWindowsPlatform::GetPlatform()->UseClearTypeForDownloadableFonts()));
|
|
|
|
|
|
|
|
return new gfxGDIFont(this, aFontStyle, aNeedsBold,
|
|
|
|
(useClearType ? gfxFont::kAntialiasSubpixel
|
|
|
|
: gfxFont::kAntialiasDefault));
|
2009-10-07 08:26:58 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
GDIFontEntry::GetFontTable(uint32_t aTableTag,
|
|
|
|
FallibleTArray<uint8_t>& aBuffer)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
2010-06-11 12:14:38 -07:00
|
|
|
if (!IsTrueType()) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
AutoDC dc;
|
|
|
|
AutoSelectFont font(dc.GetDC(), &mLogFont);
|
|
|
|
if (font.IsValid()) {
|
2012-10-04 01:35:15 -07:00
|
|
|
uint32_t tableSize =
|
|
|
|
::GetFontData(dc.GetDC(), NS_SWAP32(aTableTag), 0, NULL, 0);
|
2009-10-07 07:13:40 -07:00
|
|
|
if (tableSize != GDI_ERROR) {
|
|
|
|
if (aBuffer.SetLength(tableSize)) {
|
2010-06-11 12:14:38 -07:00
|
|
|
::GetFontData(dc.GetDC(), NS_SWAP32(aTableTag), 0,
|
|
|
|
aBuffer.Elements(), tableSize);
|
2009-10-07 07:13:40 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-14 00:24:26 -08:00
|
|
|
GDIFontEntry::FillLogFont(LOGFONTW *aLogFont,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t aWeight, gfxFloat aSize,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseCleartype)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
memcpy(aLogFont, &mLogFont, sizeof(LOGFONTW));
|
|
|
|
|
|
|
|
aLogFont->lfHeight = (LONG)-ROUND(aSize);
|
|
|
|
|
2012-02-14 00:24:26 -08:00
|
|
|
if (aLogFont->lfHeight == 0) {
|
2009-10-07 07:13:40 -07:00
|
|
|
aLogFont->lfHeight = -1;
|
2012-02-14 00:24:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If a non-zero weight is passed in, use this to override the original
|
|
|
|
// weight in the entry's logfont. This is used to control synthetic bolding
|
|
|
|
// for installed families with no bold face, and for downloaded fonts
|
|
|
|
// (but NOT for local user fonts, because it could cause a different,
|
|
|
|
// glyph-incompatible face to be used)
|
|
|
|
if (aWeight) {
|
|
|
|
aLogFont->lfWeight = aWeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
// for non-local() user fonts, we never want to apply italics here;
|
|
|
|
// if the face is described as italic, we should use it as-is,
|
|
|
|
// and if it's not, but then the element is styled italic, we'll use
|
|
|
|
// a cairo transform to create fake italic (oblique)
|
|
|
|
if (IsUserFont() && !IsLocalUserFont()) {
|
|
|
|
aLogFont->lfItalic = 0;
|
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-02-14 00:24:26 -08:00
|
|
|
aLogFont->lfQuality = (aUseCleartype ? CLEARTYPE_QUALITY : DEFAULT_QUALITY);
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
2011-02-22 09:04:37 -08:00
|
|
|
#define MISSING_GLYPH 0x1F // glyph index returned for missing characters
|
|
|
|
// on WinXP with .fon fonts, but not Type1 (.pfb)
|
2010-06-25 05:43:10 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
GDIFontEntry::TestCharacterMap(uint32_t aCh)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
2012-04-18 16:59:43 -07:00
|
|
|
if (!mCharacterMap) {
|
2012-10-04 01:35:15 -07:00
|
|
|
ReadCMAP();
|
2012-04-18 16:59:43 -07:00
|
|
|
NS_ASSERTION(mCharacterMap, "failed to initialize a character map");
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
2012-04-18 16:59:43 -07:00
|
|
|
if (mCharacterMap->mBuildOnTheFly) {
|
2009-10-07 07:13:40 -07:00
|
|
|
if (aCh > 0xFFFF)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
// previous code was using the group style
|
|
|
|
gfxFontStyle fakeStyle;
|
|
|
|
if (mItalic)
|
2012-03-15 02:04:46 -07:00
|
|
|
fakeStyle.style = NS_FONT_STYLE_ITALIC;
|
2009-10-07 07:13:40 -07:00
|
|
|
fakeStyle.weight = mWeight * 100;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
nsRefPtr<gfxFont> tempFont = FindOrMakeFont(&fakeStyle, false);
|
2010-03-15 02:34:25 -07:00
|
|
|
if (!tempFont || !tempFont->Valid())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-03-15 02:34:25 -07:00
|
|
|
gfxGDIFont *font = static_cast<gfxGDIFont*>(tempFont.get());
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
HDC dc = GetDC((HWND)nullptr);
|
2009-10-07 07:13:40 -07:00
|
|
|
SetGraphicsMode(dc, GM_ADVANCED);
|
|
|
|
HFONT hfont = font->GetHFONT();
|
|
|
|
HFONT oldFont = (HFONT)SelectObject(dc, hfont);
|
|
|
|
|
|
|
|
PRUnichar str[1] = { (PRUnichar)aCh };
|
|
|
|
WORD glyph[1];
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool hasGlyph = false;
|
2010-06-25 05:43:10 -07:00
|
|
|
|
|
|
|
// Bug 573038 - in some cases GetGlyphIndicesW returns 0xFFFF for a
|
|
|
|
// missing glyph or 0x1F in other cases to indicate the "invalid"
|
|
|
|
// glyph. Map both cases to "not found"
|
2010-03-15 02:34:25 -07:00
|
|
|
if (IsType1() || mForceGDI) {
|
2010-06-25 05:43:10 -07:00
|
|
|
// Type1 fonts and uniscribe APIs don't get along.
|
|
|
|
// ScriptGetCMap will return E_HANDLE
|
|
|
|
DWORD ret = GetGlyphIndicesW(dc, str, 1,
|
|
|
|
glyph, GGI_MARK_NONEXISTING_GLYPHS);
|
|
|
|
if (ret != GDI_ERROR
|
2011-02-22 09:04:37 -08:00
|
|
|
&& glyph[0] != 0xFFFF
|
|
|
|
&& (IsType1() || glyph[0] != MISSING_GLYPH))
|
2010-06-25 05:43:10 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
hasGlyph = true;
|
2010-06-25 05:43:10 -07:00
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
} else {
|
2010-06-25 05:43:10 -07:00
|
|
|
// ScriptGetCMap works better than GetGlyphIndicesW
|
|
|
|
// for things like bitmap/vector fonts
|
2010-03-15 02:34:25 -07:00
|
|
|
SCRIPT_CACHE sc = NULL;
|
|
|
|
HRESULT rv = ScriptGetCMap(dc, &sc, str, 1, 0, glyph);
|
2009-10-07 07:13:40 -07:00
|
|
|
if (rv == S_OK)
|
2011-10-17 07:59:28 -07:00
|
|
|
hasGlyph = true;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(dc, oldFont);
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
|
|
|
|
if (hasGlyph) {
|
2012-04-18 16:59:43 -07:00
|
|
|
mCharacterMap->set(aCh);
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// font had a cmap so simply check that
|
2012-04-18 16:59:43 -07:00
|
|
|
return mCharacterMap->test(aCh);
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GDIFontEntry::InitLogFont(const nsAString& aName,
|
2011-09-05 00:34:40 -07:00
|
|
|
gfxWindowsFontType aFontType)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
#define CLIP_TURNOFF_FONTASSOCIATION 0x40
|
2012-07-03 03:42:07 -07:00
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
mLogFont.lfHeight = -1;
|
|
|
|
|
|
|
|
// Fill in logFont structure
|
|
|
|
mLogFont.lfWidth = 0;
|
|
|
|
mLogFont.lfEscapement = 0;
|
|
|
|
mLogFont.lfOrientation = 0;
|
|
|
|
mLogFont.lfUnderline = FALSE;
|
|
|
|
mLogFont.lfStrikeOut = FALSE;
|
|
|
|
mLogFont.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
mLogFont.lfOutPrecision = FontTypeToOutPrecision(aFontType);
|
|
|
|
mLogFont.lfClipPrecision = CLIP_TURNOFF_FONTASSOCIATION;
|
2010-06-08 17:33:13 -07:00
|
|
|
mLogFont.lfQuality = DEFAULT_QUALITY;
|
2009-10-07 07:13:40 -07:00
|
|
|
mLogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
|
|
|
|
// always force lfItalic if we want it. Font selection code will
|
|
|
|
// do its best to give us an italic font entry, but if no face exists
|
|
|
|
// it may give us a regular one based on weight. Windows should
|
|
|
|
// do fake italic for us in that case.
|
|
|
|
mLogFont.lfItalic = mItalic;
|
|
|
|
mLogFont.lfWeight = mWeight;
|
|
|
|
|
2011-06-02 05:56:50 -07:00
|
|
|
int len = NS_MIN<int>(aName.Length(), LF_FACESIZE - 1);
|
2009-10-07 07:13:40 -07:00
|
|
|
memcpy(&mLogFont.lfFaceName, nsPromiseFlatString(aName).get(), len * 2);
|
|
|
|
mLogFont.lfFaceName[len] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
GDIFontEntry*
|
2011-09-05 00:34:40 -07:00
|
|
|
GDIFontEntry::CreateFontEntry(const nsAString& aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
gfxWindowsFontType aFontType, bool aItalic,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t aWeight, int16_t aStretch,
|
2012-07-03 03:42:07 -07:00
|
|
|
gfxUserFontData* aUserFontData,
|
|
|
|
bool aFamilyHasItalicFace)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
// jtdfix - need to set charset, unicode ranges, pitch/family
|
|
|
|
|
2011-09-05 00:34:40 -07:00
|
|
|
GDIFontEntry *fe = new GDIFontEntry(aName, aFontType, aItalic,
|
2012-07-03 03:42:07 -07:00
|
|
|
aWeight, aStretch, aUserFontData,
|
|
|
|
aFamilyHasItalicFace);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
return fe;
|
|
|
|
}
|
|
|
|
|
2012-03-27 14:38:39 -07:00
|
|
|
void
|
|
|
|
GDIFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const
|
|
|
|
{
|
|
|
|
aSizes->mFontListSize += aMallocSizeOf(this);
|
|
|
|
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
|
|
|
}
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
/***************************************************************
|
|
|
|
*
|
|
|
|
* GDIFontFamily
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
int CALLBACK
|
|
|
|
GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
|
|
|
|
const NEWTEXTMETRICEXW *nmetrics,
|
|
|
|
DWORD fontType, LPARAM data)
|
|
|
|
{
|
|
|
|
const NEWTEXTMETRICW& metrics = nmetrics->ntmTm;
|
|
|
|
LOGFONTW logFont = lpelfe->elfLogFont;
|
|
|
|
GDIFontFamily *ff = reinterpret_cast<GDIFontFamily*>(data);
|
|
|
|
|
|
|
|
// Some fonts claim to support things > 900, but we don't so clamp the sizes
|
2011-10-28 11:33:28 -07:00
|
|
|
logFont.lfWeight = clamped(logFont.lfWeight, LONG(100), LONG(900));
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
gfxWindowsFontType feType = GDIFontEntry::DetermineFontType(metrics, fontType);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
GDIFontEntry *fe = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < ff->mAvailableFonts.Length(); ++i) {
|
2009-10-07 07:13:40 -07:00
|
|
|
fe = static_cast<GDIFontEntry*>(ff->mAvailableFonts[i].get());
|
|
|
|
if (feType > fe->mFontType) {
|
|
|
|
// if the new type is better than the old one, remove the old entries
|
|
|
|
ff->mAvailableFonts.RemoveElementAt(i);
|
|
|
|
--i;
|
|
|
|
} else if (feType < fe->mFontType) {
|
|
|
|
// otherwise if the new type is worse, skip it
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < ff->mAvailableFonts.Length(); ++i) {
|
2009-10-07 07:13:40 -07:00
|
|
|
fe = static_cast<GDIFontEntry*>(ff->mAvailableFonts[i].get());
|
|
|
|
// check if we already know about this face
|
|
|
|
if (fe->mWeight == logFont.lfWeight &&
|
|
|
|
fe->mItalic == (logFont.lfItalic == 0xFF)) {
|
|
|
|
// update the charset bit here since this could be different
|
2010-01-14 13:31:06 -08:00
|
|
|
fe->mCharset.set(metrics.tmCharSet);
|
2009-10-07 07:13:40 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-03 03:42:07 -07:00
|
|
|
// We can't set the hasItalicFace flag correctly here,
|
|
|
|
// because we might not have seen the family's italic face(s) yet.
|
|
|
|
// Later code does _not_ rely on this flag for platform fonts;
|
|
|
|
// it is only needed for fonts loaded with src:local
|
2011-09-05 00:34:40 -07:00
|
|
|
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
|
|
|
|
feType, (logFont.lfItalic == 0xFF),
|
2012-08-22 08:56:38 -07:00
|
|
|
(uint16_t) (logFont.lfWeight), 0,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr, false);
|
2009-10-07 07:13:40 -07:00
|
|
|
if (!fe)
|
|
|
|
return 1;
|
|
|
|
|
2011-01-26 19:05:55 -08:00
|
|
|
ff->AddFontEntry(fe);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
// mark the charset bit
|
2010-01-14 13:31:06 -08:00
|
|
|
fe->mCharset.set(metrics.tmCharSet);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
fe->mWindowsFamily = logFont.lfPitchAndFamily & 0xF0;
|
|
|
|
fe->mWindowsPitch = logFont.lfPitchAndFamily & 0x0F;
|
|
|
|
|
|
|
|
if (nmetrics->ntmFontSig.fsUsb[0] != 0x00000000 &&
|
|
|
|
nmetrics->ntmFontSig.fsUsb[1] != 0x00000000 &&
|
|
|
|
nmetrics->ntmFontSig.fsUsb[2] != 0x00000000 &&
|
|
|
|
nmetrics->ntmFontSig.fsUsb[3] != 0x00000000) {
|
|
|
|
|
|
|
|
// set the unicode ranges
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t x = 0;
|
|
|
|
for (uint32_t i = 0; i < 4; ++i) {
|
2009-10-07 07:13:40 -07:00
|
|
|
DWORD range = nmetrics->ntmFontSig.fsUsb[i];
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t k = 0; k < 32; ++k) {
|
2010-01-14 13:31:06 -08:00
|
|
|
fe->mUnicodeRanges.set(x++, (range & (1 << k)) != 0);
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
2011-01-21 08:44:33 -08:00
|
|
|
if (LOG_FONTLIST_ENABLED()) {
|
|
|
|
LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
|
2009-10-07 07:13:40 -07:00
|
|
|
" with style: %s weight: %d stretch: %d",
|
|
|
|
NS_ConvertUTF16toUTF8(fe->Name()).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(ff->Name()).get(),
|
|
|
|
(logFont.lfItalic == 0xff) ? "italic" : "normal",
|
|
|
|
logFont.lfWeight, fe->Stretch()));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GDIFontFamily::FindStyleVariations()
|
|
|
|
{
|
|
|
|
if (mHasStyles)
|
|
|
|
return;
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasStyles = true;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
HDC hdc = GetDC(nullptr);
|
2009-10-07 07:13:40 -07:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
|
|
|
|
LOGFONTW logFont;
|
|
|
|
memset(&logFont, 0, sizeof(LOGFONTW));
|
|
|
|
logFont.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
logFont.lfPitchAndFamily = 0;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t l = NS_MIN<uint32_t>(mName.Length(), LF_FACESIZE - 1);
|
2009-10-07 07:13:40 -07:00
|
|
|
memcpy(logFont.lfFaceName,
|
|
|
|
nsPromiseFlatString(mName).get(),
|
|
|
|
l * sizeof(PRUnichar));
|
|
|
|
logFont.lfFaceName[l] = 0;
|
|
|
|
|
|
|
|
EnumFontFamiliesExW(hdc, &logFont,
|
|
|
|
(FONTENUMPROCW)GDIFontFamily::FamilyAddStylesProc,
|
|
|
|
(LPARAM)this, 0);
|
2010-02-18 03:52:44 -08:00
|
|
|
#ifdef PR_LOGGING
|
2011-01-21 08:44:33 -08:00
|
|
|
if (LOG_FONTLIST_ENABLED() && mAvailableFonts.Length() == 0) {
|
|
|
|
LOG_FONTLIST(("(fontlist) no styles available in family \"%s\"",
|
|
|
|
NS_ConvertUTF16toUTF8(mName).get()));
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
ReleaseDC(nullptr, hdc);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
if (mIsBadUnderlineFamily)
|
|
|
|
SetBadUnderlineFonts();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
*
|
|
|
|
* gfxGDIFontList
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
gfxGDIFontList::gfxGDIFontList()
|
|
|
|
{
|
|
|
|
mFontSubstitutes.Init(50);
|
2012-02-28 08:04:05 -08:00
|
|
|
|
2012-03-19 15:52:08 -07:00
|
|
|
InitializeFontEmbeddingProcs();
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RemoveCharsetFromFontSubstitute(nsAString &aName)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t comma = aName.FindChar(PRUnichar(','));
|
2009-10-07 07:13:40 -07:00
|
|
|
if (comma >= 0)
|
|
|
|
aName.Truncate(comma);
|
|
|
|
}
|
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
#define MAX_VALUE_NAME 512
|
|
|
|
#define MAX_VALUE_DATA 512
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
nsresult
|
|
|
|
gfxGDIFontList::GetFontSubstitutes()
|
|
|
|
{
|
2011-01-21 08:44:32 -08:00
|
|
|
HKEY hKey;
|
|
|
|
DWORD i, rv, lenAlias, lenActual, valueType;
|
|
|
|
WCHAR aliasName[MAX_VALUE_NAME];
|
|
|
|
WCHAR actualName[MAX_VALUE_DATA];
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes",
|
|
|
|
0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
|
|
|
{
|
2009-10-07 07:13:40 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2011-01-21 08:44:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) {
|
|
|
|
aliasName[0] = 0;
|
2011-10-10 22:50:08 -07:00
|
|
|
lenAlias = ArrayLength(aliasName);
|
2011-01-21 08:44:32 -08:00
|
|
|
actualName[0] = 0;
|
|
|
|
lenActual = sizeof(actualName);
|
|
|
|
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType,
|
|
|
|
(LPBYTE)actualName, &lenActual);
|
|
|
|
|
|
|
|
if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {
|
2009-10-07 07:13:40 -07:00
|
|
|
continue;
|
2011-01-21 08:44:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aliasName[0] == WCHAR('@')) {
|
2009-10-07 07:13:40 -07:00
|
|
|
continue;
|
2011-01-21 08:44:32 -08:00
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
nsAutoString substituteName((PRUnichar*) aliasName);
|
|
|
|
nsAutoString actualFontName((PRUnichar*) actualName);
|
2009-10-07 07:13:40 -07:00
|
|
|
RemoveCharsetFromFontSubstitute(substituteName);
|
|
|
|
BuildKeyNameFromFontName(substituteName);
|
|
|
|
RemoveCharsetFromFontSubstitute(actualFontName);
|
|
|
|
BuildKeyNameFromFontName(actualFontName);
|
|
|
|
gfxFontFamily *ff;
|
2011-01-21 08:44:32 -08:00
|
|
|
if (!actualFontName.IsEmpty() &&
|
|
|
|
(ff = mFontFamilies.GetWeak(actualFontName))) {
|
2009-10-07 07:13:40 -07:00
|
|
|
mFontSubstitutes.Put(substituteName, ff);
|
|
|
|
} else {
|
|
|
|
mNonExistingFonts.AppendElement(substituteName);
|
|
|
|
}
|
|
|
|
}
|
2011-10-28 06:58:49 -07:00
|
|
|
|
|
|
|
// "Courier" on a default Windows install is an ugly bitmap font.
|
|
|
|
// If there is no substitution for Courier in the registry
|
|
|
|
// substitute "Courier" with "Courier New".
|
|
|
|
nsAutoString substituteName;
|
|
|
|
substituteName.AssignLiteral("Courier");
|
|
|
|
BuildKeyNameFromFontName(substituteName);
|
2012-03-27 14:38:39 -07:00
|
|
|
if (!mFontSubstitutes.GetWeak(substituteName)) {
|
2011-10-28 06:58:49 -07:00
|
|
|
gfxFontFamily *ff;
|
|
|
|
nsAutoString actualFontName;
|
|
|
|
actualFontName.AssignLiteral("Courier New");
|
|
|
|
BuildKeyNameFromFontName(actualFontName);
|
|
|
|
ff = mFontFamilies.GetWeak(actualFontName);
|
|
|
|
if (ff) {
|
|
|
|
mFontSubstitutes.Put(substituteName, ff);
|
|
|
|
}
|
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-08 03:02:27 -08:00
|
|
|
nsresult
|
2009-10-07 07:13:40 -07:00
|
|
|
gfxGDIFontList::InitFontList()
|
|
|
|
{
|
2011-07-26 23:42:53 -07:00
|
|
|
Telemetry::AutoTimer<Telemetry::GDI_INITFONTLIST_TOTAL> timer;
|
2009-10-07 07:13:40 -07:00
|
|
|
gfxFontCache *fc = gfxFontCache::GetCache();
|
|
|
|
if (fc)
|
|
|
|
fc->AgeAllGenerations();
|
|
|
|
|
2010-01-28 17:41:25 -08:00
|
|
|
// reset font lists
|
|
|
|
gfxPlatformFontList::InitFontList();
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
mFontSubstitutes.Clear();
|
|
|
|
mNonExistingFonts.Clear();
|
|
|
|
|
|
|
|
// iterate over available families
|
|
|
|
LOGFONTW logfont;
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
|
|
|
|
AutoDC hdc;
|
|
|
|
int result = EnumFontFamiliesExW(hdc.GetDC(), &logfont,
|
|
|
|
(FONTENUMPROCW)&EnumFontFamExProc,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
GetFontSubstitutes();
|
|
|
|
|
|
|
|
StartLoader(kDelayBeforeLoadingFonts, kIntervalBetweenLoadingFonts);
|
2010-11-08 03:02:27 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
2010-11-08 03:02:27 -08:00
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
int CALLBACK
|
|
|
|
gfxGDIFontList::EnumFontFamExProc(ENUMLOGFONTEXW *lpelfe,
|
|
|
|
NEWTEXTMETRICEXW *lpntme,
|
|
|
|
DWORD fontType,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
const LOGFONTW& lf = lpelfe->elfLogFont;
|
|
|
|
|
|
|
|
if (lf.lfFaceName[0] == '@') {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString name(lf.lfFaceName);
|
|
|
|
BuildKeyNameFromFontName(name);
|
|
|
|
|
|
|
|
gfxGDIFontList *fontList = PlatformFontList();
|
|
|
|
|
|
|
|
if (!fontList->mFontFamilies.GetWeak(name)) {
|
2010-01-14 13:31:06 -08:00
|
|
|
nsDependentString faceName(lf.lfFaceName);
|
|
|
|
nsRefPtr<gfxFontFamily> family = new GDIFontFamily(faceName);
|
2009-10-07 07:13:40 -07:00
|
|
|
fontList->mFontFamilies.Put(name, family);
|
2011-01-07 04:29:49 -08:00
|
|
|
|
|
|
|
// if locale is such that CJK font names are the default coming from
|
|
|
|
// GDI, then if a family name is non-ASCII immediately read in other
|
|
|
|
// family names. This assures that MS Gothic, MS Mincho are all found
|
|
|
|
// before lookups begin.
|
|
|
|
if (!IsASCII(faceName)) {
|
|
|
|
family->ReadOtherFamilyNames(gfxPlatformFontList::PlatformFontList());
|
|
|
|
}
|
|
|
|
|
2010-02-11 04:00:07 -08:00
|
|
|
if (fontList->mBadUnderlineFamilyNames.Contains(name))
|
2010-01-27 22:56:16 -08:00
|
|
|
family->SetBadUnderlineFamily();
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
|
|
|
gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
|
|
|
const nsAString& aFullname)
|
|
|
|
{
|
2010-01-28 17:41:25 -08:00
|
|
|
gfxFontEntry *lookup;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2010-01-28 17:41:25 -08:00
|
|
|
// initialize name lookup tables if needed
|
|
|
|
if (!mFaceNamesInitialized) {
|
|
|
|
InitFaceNameLists();
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
2010-01-28 17:41:25 -08:00
|
|
|
// lookup in name lookup tables, return null if not found
|
2012-03-27 14:38:39 -07:00
|
|
|
if (!(lookup = mPostscriptNames.GetWeak(aFullname)) &&
|
|
|
|
!(lookup = mFullnames.GetWeak(aFullname)))
|
2010-01-28 17:41:25 -08:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-01-28 17:41:25 -08:00
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isCFF = false; // jtdfix -- need to determine this
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2010-01-28 17:41:25 -08:00
|
|
|
// use the face name from the lookup font entry, which will be the localized
|
|
|
|
// face name which GDI mapping tables use (e.g. with the system locale set to
|
|
|
|
// Dutch, a fullname of 'Arial Bold' will find a font entry with the face name
|
|
|
|
// 'Arial Vet' which can be used as a key in GDI font lookups).
|
2012-06-28 02:59:37 -07:00
|
|
|
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(),
|
2009-10-07 07:13:40 -07:00
|
|
|
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
2012-06-28 02:59:37 -07:00
|
|
|
lookup->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
|
2012-07-30 07:20:58 -07:00
|
|
|
lookup->mWeight, aProxyEntry->mStretch, nullptr,
|
2012-07-03 03:42:07 -07:00
|
|
|
lookup->Family()->HasItalicFace());
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
if (!fe)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
fe->mIsUserFont = true;
|
|
|
|
fe->mIsLocalUserFont = true;
|
2012-06-28 02:59:37 -07:00
|
|
|
|
|
|
|
// make the new font entry match the proxy entry style characteristics
|
|
|
|
fe->mWeight = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight);
|
|
|
|
fe->mItalic = aProxyEntry->mItalic;
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
return fe;
|
|
|
|
}
|
|
|
|
|
2012-03-19 15:52:08 -07:00
|
|
|
void gfxGDIFontList::InitializeFontEmbeddingProcs()
|
|
|
|
{
|
|
|
|
static HMODULE fontlib = LoadLibraryW(L"t2embed.dll");
|
|
|
|
if (!fontlib)
|
|
|
|
return;
|
|
|
|
TTLoadEmbeddedFontPtr = (TTLoadEmbeddedFontProc)
|
|
|
|
GetProcAddress(fontlib, "TTLoadEmbeddedFont");
|
|
|
|
TTDeleteEmbeddedFontPtr = (TTDeleteEmbeddedFontProc)
|
|
|
|
GetProcAddress(fontlib, "TTDeleteEmbeddedFont");
|
|
|
|
}
|
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
// used to control stream read by Windows TTLoadEmbeddedFont API
|
|
|
|
|
|
|
|
class EOTFontStreamReader {
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
EOTFontStreamReader(const uint8_t *aFontData, uint32_t aLength, uint8_t *aEOTHeader,
|
|
|
|
uint32_t aEOTHeaderLen, FontDataOverlay *aNameOverlay)
|
2009-10-07 07:13:40 -07:00
|
|
|
: mCurrentChunk(0), mChunkOffset(0)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFontData, "null font data ptr passed in");
|
|
|
|
NS_ASSERTION(aEOTHeader, "null EOT header ptr passed in");
|
|
|
|
NS_ASSERTION(aNameOverlay, "null name overlay struct passed in");
|
|
|
|
|
|
|
|
if (aNameOverlay->overlaySrc) {
|
|
|
|
mNumChunks = 4;
|
|
|
|
// 0 : EOT header
|
|
|
|
mDataChunks[0].mData = aEOTHeader;
|
|
|
|
mDataChunks[0].mLength = aEOTHeaderLen;
|
|
|
|
// 1 : start of font data to overlayDest
|
|
|
|
mDataChunks[1].mData = aFontData;
|
|
|
|
mDataChunks[1].mLength = aNameOverlay->overlayDest;
|
|
|
|
// 2 : overlay data
|
|
|
|
mDataChunks[2].mData = aFontData + aNameOverlay->overlaySrc;
|
|
|
|
mDataChunks[2].mLength = aNameOverlay->overlaySrcLen;
|
|
|
|
// 3 : rest of font data
|
|
|
|
mDataChunks[3].mData = aFontData + aNameOverlay->overlayDest + aNameOverlay->overlaySrcLen;
|
|
|
|
mDataChunks[3].mLength = aLength - aNameOverlay->overlayDest - aNameOverlay->overlaySrcLen;
|
|
|
|
} else {
|
|
|
|
mNumChunks = 2;
|
|
|
|
// 0 : EOT header
|
|
|
|
mDataChunks[0].mData = aEOTHeader;
|
|
|
|
mDataChunks[0].mLength = aEOTHeaderLen;
|
|
|
|
// 1 : font data
|
|
|
|
mDataChunks[1].mData = aFontData;
|
|
|
|
mDataChunks[1].mLength = aLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~EOTFontStreamReader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct FontDataChunk {
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t *mData;
|
|
|
|
uint32_t mLength;
|
2009-10-07 07:13:40 -07:00
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mNumChunks;
|
2009-10-07 07:13:40 -07:00
|
|
|
FontDataChunk mDataChunks[4];
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mCurrentChunk;
|
|
|
|
uint32_t mChunkOffset;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
unsigned long Read(void *outBuffer, const unsigned long aBytesToRead)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t bytesLeft = aBytesToRead; // bytes left in the out buffer
|
|
|
|
uint8_t *out = static_cast<uint8_t*> (outBuffer);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
while (mCurrentChunk < mNumChunks && bytesLeft) {
|
|
|
|
FontDataChunk& currentChunk = mDataChunks[mCurrentChunk];
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t bytesToCopy = NS_MIN(bytesLeft,
|
2009-10-07 07:13:40 -07:00
|
|
|
currentChunk.mLength - mChunkOffset);
|
|
|
|
memcpy(out, currentChunk.mData + mChunkOffset, bytesToCopy);
|
|
|
|
bytesLeft -= bytesToCopy;
|
|
|
|
mChunkOffset += bytesToCopy;
|
|
|
|
out += bytesToCopy;
|
|
|
|
|
|
|
|
NS_ASSERTION(mChunkOffset <= currentChunk.mLength, "oops, buffer overrun");
|
|
|
|
|
|
|
|
if (mChunkOffset == currentChunk.mLength) {
|
|
|
|
mCurrentChunk++;
|
|
|
|
mChunkOffset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aBytesToRead - bytesLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long ReadEOTStream(void *aReadStream, void *outBuffer,
|
|
|
|
const unsigned long aBytesToRead)
|
|
|
|
{
|
|
|
|
EOTFontStreamReader *eotReader =
|
|
|
|
static_cast<EOTFontStreamReader*> (aReadStream);
|
|
|
|
return eotReader->Read(outBuffer, aBytesToRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
gfxFontEntry*
|
|
|
|
gfxGDIFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t *aFontData,
|
|
|
|
uint32_t aLength)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
// MakePlatformFont is responsible for deleting the font data with NS_Free
|
|
|
|
// so we set up a stack object to ensure it is freed even if we take an
|
|
|
|
// early exit
|
|
|
|
struct FontDataDeleter {
|
2012-08-22 08:56:38 -07:00
|
|
|
FontDataDeleter(const uint8_t *aFontData)
|
2009-10-07 07:13:40 -07:00
|
|
|
: mFontData(aFontData) { }
|
|
|
|
~FontDataDeleter() { NS_Free((void*)mFontData); }
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t *mFontData;
|
2009-10-07 07:13:40 -07:00
|
|
|
};
|
|
|
|
FontDataDeleter autoDelete(aFontData);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool hasVertical;
|
|
|
|
bool isCFF = gfxFontUtils::IsCffFont(aFontData, hasVertical);
|
2011-03-24 13:11:38 -07:00
|
|
|
|
2009-10-07 07:13:40 -07:00
|
|
|
nsresult rv;
|
2012-07-30 07:20:58 -07:00
|
|
|
HANDLE fontRef = nullptr;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEmbedded = false;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
nsAutoString uniqueName;
|
|
|
|
rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName);
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2012-03-19 15:52:08 -07:00
|
|
|
// for TTF fonts, first try using the t2embed library if available
|
|
|
|
if (!isCFF && TTLoadEmbeddedFontPtr && TTDeleteEmbeddedFontPtr) {
|
2009-10-07 07:13:40 -07:00
|
|
|
// TrueType-style glyphs, use EOT library
|
2012-08-22 08:56:38 -07:00
|
|
|
AutoFallibleTArray<uint8_t,2048> eotHeader;
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint32_t eotlen;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
isEmbedded = true;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t nameLen = NS_MIN<uint32_t>(uniqueName.Length(), LF_FACESIZE - 1);
|
2011-06-13 19:02:35 -07:00
|
|
|
nsAutoString fontName(Substring(uniqueName, 0, nameLen));
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
FontDataOverlay overlayNameData = {0, 0, 0};
|
|
|
|
|
|
|
|
rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader,
|
|
|
|
&overlayNameData);
|
2010-07-16 18:32:18 -07:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
|
|
|
|
// load in embedded font data
|
|
|
|
eotlen = eotHeader.Length();
|
2012-08-22 08:56:38 -07:00
|
|
|
buffer = reinterpret_cast<uint8_t*> (eotHeader.Elements());
|
2010-07-16 18:32:18 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t ret;
|
2010-07-16 18:32:18 -07:00
|
|
|
ULONG privStatus, pulStatus;
|
|
|
|
EOTFontStreamReader eotReader(aFontData, aLength, buffer, eotlen,
|
|
|
|
&overlayNameData);
|
|
|
|
|
2012-03-19 15:52:08 -07:00
|
|
|
ret = TTLoadEmbeddedFontPtr(&fontRef, TTLOAD_PRIVATE, &privStatus,
|
|
|
|
LICENSE_PREVIEWPRINT, &pulStatus,
|
|
|
|
EOTFontStreamReader::ReadEOTStream,
|
|
|
|
&eotReader,
|
|
|
|
(PRUnichar*)(fontName.get()), 0, 0);
|
2010-07-16 18:32:18 -07:00
|
|
|
if (ret != E_NONE) {
|
2012-07-30 07:20:58 -07:00
|
|
|
fontRef = nullptr;
|
2010-07-16 18:32:18 -07:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "font (%s) not loaded using TTLoadEmbeddedFont - error %8.8x", NS_ConvertUTF16toUTF8(aProxyEntry->FamilyName()).get(), ret);
|
|
|
|
NS_WARNING(buf);
|
|
|
|
}
|
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// load CFF fonts or fonts that failed with t2embed loader
|
2012-07-30 07:20:58 -07:00
|
|
|
if (fontRef == nullptr) {
|
2009-10-07 07:13:40 -07:00
|
|
|
// Postscript-style glyphs, swizzle name table, load directly
|
2012-08-22 08:56:38 -07:00
|
|
|
FallibleTArray<uint8_t> newFontData;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
isEmbedded = false;
|
2009-10-07 07:13:40 -07:00
|
|
|
rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
DWORD numFonts = 0;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t *fontData = reinterpret_cast<uint8_t*> (newFontData.Elements());
|
|
|
|
uint32_t fontLength = newFontData.Length();
|
2009-10-07 07:13:40 -07:00
|
|
|
NS_ASSERTION(fontData, "null font data after renaming");
|
|
|
|
|
|
|
|
// http://msdn.microsoft.com/en-us/library/ms533942(VS.85).aspx
|
|
|
|
// "A font that is added by AddFontMemResourceEx is always private
|
|
|
|
// to the process that made the call and is not enumerable."
|
|
|
|
fontRef = AddFontMemResourceEx(fontData, fontLength,
|
|
|
|
0 /* reserved */, &numFonts);
|
|
|
|
if (!fontRef)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
// only load fonts with a single face contained in the data
|
2011-03-24 13:11:38 -07:00
|
|
|
// AddFontMemResourceEx generates an additional face name for
|
|
|
|
// vertical text if the font supports vertical writing
|
|
|
|
if (fontRef && numFonts != 1 + !!hasVertical) {
|
2009-10-07 07:13:40 -07:00
|
|
|
RemoveFontMemResourceEx(fontRef);
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// make a new font entry using the unique name
|
2010-07-16 18:32:18 -07:00
|
|
|
WinUserFontData *winUserFontData = new WinUserFontData(fontRef, isEmbedded);
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t w = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName,
|
|
|
|
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t(aProxyEntry->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL),
|
2012-07-03 03:42:07 -07:00
|
|
|
w, aProxyEntry->mStretch, winUserFontData, false);
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
if (!fe)
|
|
|
|
return fe;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
fe->mIsUserFont = true;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2010-07-16 18:32:18 -07:00
|
|
|
// Uniscribe doesn't place CFF fonts loaded privately
|
|
|
|
// via AddFontMemResourceEx on XP/Vista
|
|
|
|
if (isCFF && gfxWindowsPlatform::WindowsOSVersion()
|
|
|
|
< gfxWindowsPlatform::kWindows7) {
|
2011-10-17 07:59:28 -07:00
|
|
|
fe->mForceGDI = true;
|
2010-07-16 18:32:18 -07:00
|
|
|
}
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
return fe;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2011-09-28 23:19:26 -07:00
|
|
|
gfxGDIFontList::GetDefaultFont(const gfxFontStyle* aStyle, bool& aNeedsBold)
|
2009-10-07 07:13:40 -07:00
|
|
|
{
|
|
|
|
// this really shouldn't fail to find a font....
|
|
|
|
HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
LOGFONTW logFont;
|
|
|
|
if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) {
|
|
|
|
nsAutoString resolvedName;
|
|
|
|
if (ResolveFontName(nsDependentString(logFont.lfFaceName), resolvedName)) {
|
|
|
|
return FindFontForFamily(resolvedName, aStyle, aNeedsBold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ...but just in case, try another approach as well
|
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
ncm.cbSize = sizeof(ncm);
|
|
|
|
BOOL status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
|
|
|
|
sizeof(ncm), &ncm, 0);
|
|
|
|
if (status) {
|
|
|
|
nsAutoString resolvedName;
|
|
|
|
if (ResolveFontName(nsDependentString(ncm.lfMessageFont.lfFaceName), resolvedName)) {
|
|
|
|
return FindFontForFamily(resolvedName, aStyle, aNeedsBold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-10-07 07:13:40 -07:00
|
|
|
gfxGDIFontList::ResolveFontName(const nsAString& aFontName, nsAString& aResolvedFontName)
|
|
|
|
{
|
|
|
|
nsAutoString keyName(aFontName);
|
|
|
|
BuildKeyNameFromFontName(keyName);
|
|
|
|
|
2012-03-27 14:38:39 -07:00
|
|
|
gfxFontFamily *ff = mFontSubstitutes.GetWeak(keyName);
|
|
|
|
if (ff) {
|
2009-10-07 07:13:40 -07:00
|
|
|
aResolvedFontName = ff->Name();
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mNonExistingFonts.Contains(keyName))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
|
|
|
if (gfxPlatformFontList::ResolveFontName(aFontName, aResolvedFontName))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-10-07 07:13:40 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-10-07 07:13:40 -07:00
|
|
|
}
|
2012-03-27 14:38:39 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
gfxGDIFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const
|
|
|
|
{
|
|
|
|
gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
|
|
|
aSizes->mFontListSize +=
|
|
|
|
mFontSubstitutes.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
|
|
|
|
aMallocSizeOf);
|
|
|
|
aSizes->mFontListSize +=
|
|
|
|
mNonExistingFonts.SizeOfExcludingThis(aMallocSizeOf);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < mNonExistingFonts.Length(); ++i) {
|
2012-03-27 14:38:39 -07:00
|
|
|
aSizes->mFontListSize +=
|
|
|
|
mNonExistingFonts[i].SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxGDIFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontListSizes* aSizes) const
|
|
|
|
{
|
|
|
|
aSizes->mFontListSize += aMallocSizeOf(this);
|
|
|
|
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
|
|
|
}
|