2007-03-22 10:30:00 -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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "gfxPlatformMac.h"
|
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#include "gfxQuartzSurface.h"
|
2008-02-05 22:48:47 -08:00
|
|
|
#include "gfxQuartzImageSurface.h"
|
2011-11-02 12:55:03 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-16 06:52:12 -07:00
|
|
|
#include "gfxMacPlatformFontList.h"
|
2010-03-10 04:46:41 -08:00
|
|
|
#include "gfxMacFont.h"
|
|
|
|
#include "gfxCoreTextShaper.h"
|
2008-09-30 20:01:53 -07:00
|
|
|
#include "gfxUserFontSet.h"
|
2009-03-29 17:31:51 -07:00
|
|
|
|
2009-01-18 12:14:14 -08:00
|
|
|
#include "nsTArray.h"
|
2011-06-11 19:30:16 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2009-04-07 09:02:11 -07:00
|
|
|
#include "qcms.h"
|
2013-10-07 16:15:59 -07:00
|
|
|
#include "gfx2DGlue.h"
|
2007-07-23 15:02:17 -07:00
|
|
|
|
2011-05-10 17:44:35 -07:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
2013-12-19 08:42:19 -08:00
|
|
|
#include "nsCocoaFeatures.h"
|
|
|
|
|
2011-06-11 19:30:16 -07:00
|
|
|
using namespace mozilla;
|
2011-11-02 12:55:03 -07:00
|
|
|
using namespace mozilla::gfx;
|
2011-06-11 19:30:16 -07:00
|
|
|
|
2011-05-10 17:44:35 -07:00
|
|
|
// cribbed from CTFontManager.h
|
|
|
|
enum {
|
|
|
|
kAutoActivationDisabled = 1
|
|
|
|
};
|
|
|
|
typedef uint32_t AutoActivationSetting;
|
|
|
|
|
|
|
|
// bug 567552 - disable auto-activation of fonts
|
|
|
|
|
|
|
|
static void
|
|
|
|
DisableFontActivation()
|
|
|
|
{
|
|
|
|
// get the main bundle identifier
|
|
|
|
CFBundleRef mainBundle = ::CFBundleGetMainBundle();
|
2013-07-31 08:44:31 -07:00
|
|
|
CFStringRef mainBundleID = nullptr;
|
2011-05-10 17:44:35 -07:00
|
|
|
|
|
|
|
if (mainBundle) {
|
|
|
|
mainBundleID = ::CFBundleGetIdentifier(mainBundle);
|
|
|
|
}
|
|
|
|
|
2014-03-05 11:18:38 -08:00
|
|
|
// bug 969388 and bug 922590 - mainBundlID as null is sometimes problematic
|
|
|
|
if (!mainBundleID) {
|
|
|
|
NS_WARNING("missing bundle ID, packaging set up incorrectly");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-10 17:44:35 -07:00
|
|
|
// if possible, fetch CTFontManagerSetAutoActivationSetting
|
|
|
|
void (*CTFontManagerSetAutoActivationSettingPtr)
|
|
|
|
(CFStringRef, AutoActivationSetting);
|
|
|
|
CTFontManagerSetAutoActivationSettingPtr =
|
|
|
|
(void (*)(CFStringRef, AutoActivationSetting))
|
|
|
|
dlsym(RTLD_DEFAULT, "CTFontManagerSetAutoActivationSetting");
|
|
|
|
|
|
|
|
// bug 567552 - disable auto-activation of fonts
|
|
|
|
if (CTFontManagerSetAutoActivationSettingPtr) {
|
|
|
|
CTFontManagerSetAutoActivationSettingPtr(mainBundleID,
|
|
|
|
kAutoActivationDisabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
gfxPlatformMac::gfxPlatformMac()
|
|
|
|
{
|
2013-03-07 15:00:07 -08:00
|
|
|
DisableFontActivation();
|
2008-05-01 02:07:17 -07:00
|
|
|
mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
|
2012-07-24 17:45:58 -07:00
|
|
|
|
2014-01-10 11:06:16 -08:00
|
|
|
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) |
|
|
|
|
BackendTypeBit(BackendType::SKIA) |
|
|
|
|
BackendTypeBit(BackendType::COREGRAPHICS);
|
|
|
|
uint32_t contentMask = BackendTypeBit(BackendType::COREGRAPHICS);
|
|
|
|
InitBackendPrefs(canvasMask, BackendType::COREGRAPHICS,
|
|
|
|
contentMask, BackendType::COREGRAPHICS);
|
2009-03-29 17:31:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxPlatformMac::~gfxPlatformMac()
|
|
|
|
{
|
2010-03-10 04:46:41 -08:00
|
|
|
gfxCoreTextShaper::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-08-16 06:52:12 -07:00
|
|
|
gfxPlatformFontList*
|
|
|
|
gfxPlatformMac::CreatePlatformFontList()
|
|
|
|
{
|
2010-11-08 03:02:27 -08:00
|
|
|
gfxPlatformFontList* list = new gfxMacPlatformFontList();
|
|
|
|
if (NS_SUCCEEDED(list->InitFontList())) {
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
gfxPlatformFontList::Shutdown();
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-16 06:52:12 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
already_AddRefed<gfxASurface>
|
2014-02-09 00:04:38 -08:00
|
|
|
gfxPlatformMac::CreateOffscreenSurface(const IntSize& size,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxContentType contentType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-28 04:52:10 -07:00
|
|
|
nsRefPtr<gfxASurface> newSurface =
|
2014-02-09 00:04:38 -08:00
|
|
|
new gfxQuartzSurface(ThebesIntSize(size),
|
|
|
|
OptimalFormatForContent(contentType));
|
2013-04-28 04:52:10 -07:00
|
|
|
return newSurface.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-01-09 10:54:44 -08:00
|
|
|
|
2012-09-24 08:02:49 -07:00
|
|
|
TemporaryRef<ScaledFont>
|
2012-07-24 03:18:37 -07:00
|
|
|
gfxPlatformMac::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
2011-11-02 12:55:03 -07:00
|
|
|
{
|
|
|
|
gfxMacFont *font = static_cast<gfxMacFont*>(aFont);
|
2012-09-24 08:02:49 -07:00
|
|
|
return font->GetScaledFont(aTarget);
|
2011-11-02 12:55:03 -07:00
|
|
|
}
|
|
|
|
|
2008-03-13 03:32:50 -07:00
|
|
|
nsresult
|
|
|
|
gfxPlatformMac::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
|
|
|
{
|
2009-08-16 06:52:12 -07:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetStandardFamilyName(aFontName, aFamilyName);
|
2008-03-13 03:32:50 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-02 12:06:16 -07:00
|
|
|
gfxFontGroup *
|
2014-06-05 23:09:23 -07:00
|
|
|
gfxPlatformMac::CreateFontGroup(const FontFamilyList& aFontFamilyList,
|
2008-09-30 20:01:53 -07:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet)
|
2007-04-02 12:06:16 -07:00
|
|
|
{
|
2014-06-05 23:09:23 -07:00
|
|
|
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
2009-08-16 06:52:12 -07:00
|
|
|
// these will move to gfxPlatform once all platforms support the fontlist
|
2008-09-30 20:01:53 -07:00
|
|
|
gfxFontEntry*
|
2009-01-02 19:21:49 -08:00
|
|
|
gfxPlatformMac::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
|
|
|
const nsAString& aFontName)
|
2008-09-30 20:01:53 -07:00
|
|
|
{
|
2009-08-16 06:52:12 -07:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aProxyEntry,
|
|
|
|
aFontName);
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxFontEntry*
|
2008-12-05 15:19:27 -08:00
|
|
|
gfxPlatformMac::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint8_t *aFontData, uint32_t aLength)
|
2008-09-30 20:01:53 -07:00
|
|
|
{
|
2009-10-07 07:13:40 -07:00
|
|
|
// Ownership of aFontData is received here, and passed on to
|
|
|
|
// gfxPlatformFontList::MakePlatformFont(), which must ensure the data
|
|
|
|
// is released with NS_Free when no longer needed
|
|
|
|
return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(aProxyEntry,
|
|
|
|
aFontData,
|
|
|
|
aLength);
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
2008-09-30 20:01:53 -07:00
|
|
|
{
|
2009-01-12 21:16:58 -08:00
|
|
|
// check for strange format flags
|
|
|
|
NS_ASSERTION(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
|
|
|
|
"strange font format hint set");
|
|
|
|
|
|
|
|
// accept supported formats
|
2009-09-17 04:03:12 -07:00
|
|
|
if (aFormatFlags & (gfxUserFontSet::FLAG_FORMAT_WOFF |
|
|
|
|
gfxUserFontSet::FLAG_FORMAT_OPENTYPE |
|
2009-01-12 21:16:58 -08:00
|
|
|
gfxUserFontSet::FLAG_FORMAT_TRUETYPE |
|
|
|
|
gfxUserFontSet::FLAG_FORMAT_TRUETYPE_AAT)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-09-30 20:01:53 -07:00
|
|
|
}
|
|
|
|
|
2009-01-12 21:16:58 -08:00
|
|
|
// reject all other formats, known and unknown
|
|
|
|
if (aFormatFlags != 0) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-01-12 21:16:58 -08:00
|
|
|
}
|
2008-09-30 20:01:53 -07:00
|
|
|
|
2009-01-12 21:16:58 -08:00
|
|
|
// no format hint set, need to look at data
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-04-02 12:06:16 -07:00
|
|
|
}
|
|
|
|
|
2009-08-16 06:52:12 -07:00
|
|
|
// these will also move to gfxPlatform once all platforms support the fontlist
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2010-02-24 09:57:57 -08:00
|
|
|
gfxPlatformMac::GetFontList(nsIAtom *aLangGroup,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 12:14:14 -08:00
|
|
|
nsTArray<nsString>& aListOfFonts)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-16 06:52:12 -07:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetFontList(aLangGroup, aGenericFamily, aListOfFonts);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxPlatformMac::UpdateFontList()
|
|
|
|
{
|
2009-08-16 06:52:12 -07:00
|
|
|
gfxPlatformFontList::PlatformFontList()->UpdateFontList();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-07-23 15:02:17 -07:00
|
|
|
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontArialUnicodeMS[] = "Arial Unicode MS";
|
|
|
|
static const char kFontAppleBraille[] = "Apple Braille";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontAppleColorEmoji[] = "Apple Color Emoji";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontAppleSymbols[] = "Apple Symbols";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontDevanagariSangamMN[] = "Devanagari Sangam MN";
|
|
|
|
static const char kFontEuphemiaUCAS[] = "Euphemia UCAS";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontGeneva[] = "Geneva";
|
|
|
|
static const char kFontGeezaPro[] = "Geeza Pro";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontGujaratiSangamMN[] = "Gujarati Sangam MN";
|
|
|
|
static const char kFontGurmukhiMN[] = "Gurmukhi MN";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontHiraginoKakuGothic[] = "Hiragino Kaku Gothic ProN";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontHiraginoSansGB[] = "Hiragino Sans GB";
|
|
|
|
static const char kFontKefa[] = "Kefa";
|
|
|
|
static const char kFontKhmerMN[] = "Khmer MN";
|
|
|
|
static const char kFontLaoMN[] = "Lao MN";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontLucidaGrande[] = "Lucida Grande";
|
|
|
|
static const char kFontMenlo[] = "Menlo";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontMicrosoftTaiLe[] = "Microsoft Tai Le";
|
|
|
|
static const char kFontMingLiUExtB[] = "MingLiU-ExtB";
|
|
|
|
static const char kFontMyanmarMN[] = "Myanmar MN";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontPlantagenetCherokee[] = "Plantagenet Cherokee";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontSimSunExtB[] = "SimSun-ExtB";
|
|
|
|
static const char kFontSongtiSC[] = "Songti SC";
|
2012-03-08 18:05:24 -08:00
|
|
|
static const char kFontSTHeiti[] = "STHeiti";
|
2014-04-14 16:45:18 -07:00
|
|
|
static const char kFontSTIXGeneral[] = "STIXGeneral";
|
|
|
|
static const char kFontTamilMN[] = "Tamil MN";
|
2012-03-08 18:05:24 -08:00
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxPlatformMac::GetCommonFallbackFonts(const uint32_t aCh,
|
|
|
|
int32_t aRunScript,
|
2012-03-08 18:05:24 -08:00
|
|
|
nsTArray<const char*>& aFontList)
|
|
|
|
{
|
|
|
|
aFontList.AppendElement(kFontLucidaGrande);
|
|
|
|
|
|
|
|
if (!IS_IN_BMP(aCh)) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t p = aCh >> 16;
|
2014-04-14 16:45:18 -07:00
|
|
|
uint32_t b = aCh >> 8;
|
2012-03-08 18:05:24 -08:00
|
|
|
if (p == 1) {
|
2014-04-14 16:45:18 -07:00
|
|
|
if (b >= 0x1f0 && b < 0x1f7) {
|
|
|
|
aFontList.AppendElement(kFontAppleColorEmoji);
|
|
|
|
} else {
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
aFontList.AppendElement(kFontSTIXGeneral);
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
}
|
|
|
|
} else if (p == 2) {
|
|
|
|
// OSX installations with MS Office may have these fonts
|
|
|
|
aFontList.AppendElement(kFontMingLiUExtB);
|
|
|
|
aFontList.AppendElement(kFontSimSunExtB);
|
2012-03-08 18:05:24 -08:00
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t b = (aCh >> 8) & 0xff;
|
2012-03-08 18:05:24 -08:00
|
|
|
|
|
|
|
switch (b) {
|
|
|
|
case 0x03:
|
|
|
|
case 0x05:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x07:
|
|
|
|
aFontList.AppendElement(kFontGeezaPro);
|
|
|
|
break;
|
2014-04-14 16:45:18 -07:00
|
|
|
case 0x09:
|
|
|
|
aFontList.AppendElement(kFontDevanagariSangamMN);
|
|
|
|
break;
|
|
|
|
case 0x0a:
|
|
|
|
aFontList.AppendElement(kFontGurmukhiMN);
|
|
|
|
aFontList.AppendElement(kFontGujaratiSangamMN);
|
|
|
|
break;
|
|
|
|
case 0x0b:
|
|
|
|
aFontList.AppendElement(kFontTamilMN);
|
|
|
|
break;
|
|
|
|
case 0x0e:
|
|
|
|
aFontList.AppendElement(kFontLaoMN);
|
|
|
|
break;
|
|
|
|
case 0x0f:
|
|
|
|
aFontList.AppendElement(kFontSongtiSC);
|
|
|
|
break;
|
2012-03-08 18:05:24 -08:00
|
|
|
case 0x10:
|
|
|
|
aFontList.AppendElement(kFontMenlo);
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontMyanmarMN);
|
2012-03-08 18:05:24 -08:00
|
|
|
break;
|
|
|
|
case 0x13: // Cherokee
|
|
|
|
aFontList.AppendElement(kFontPlantagenetCherokee);
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontKefa);
|
2012-03-08 18:05:24 -08:00
|
|
|
break;
|
2014-04-14 16:45:18 -07:00
|
|
|
case 0x14: // Unified Canadian Aboriginal Syllabics
|
|
|
|
case 0x15:
|
|
|
|
case 0x16:
|
|
|
|
aFontList.AppendElement(kFontEuphemiaUCAS);
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x18: // Mongolian, UCAS
|
2012-03-08 18:05:24 -08:00
|
|
|
aFontList.AppendElement(kFontSTHeiti);
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontEuphemiaUCAS);
|
|
|
|
break;
|
|
|
|
case 0x19: // Khmer
|
|
|
|
aFontList.AppendElement(kFontKhmerMN);
|
|
|
|
aFontList.AppendElement(kFontMicrosoftTaiLe);
|
2012-03-08 18:05:24 -08:00
|
|
|
break;
|
|
|
|
case 0x1d:
|
|
|
|
case 0x1e:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x20: // Symbol ranges
|
|
|
|
case 0x21:
|
|
|
|
case 0x22:
|
|
|
|
case 0x23:
|
|
|
|
case 0x24:
|
|
|
|
case 0x25:
|
|
|
|
case 0x26:
|
|
|
|
case 0x27:
|
|
|
|
case 0x29:
|
|
|
|
case 0x2a:
|
|
|
|
case 0x2b:
|
|
|
|
case 0x2e:
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
aFontList.AppendElement(kFontMenlo);
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontSTIXGeneral);
|
2012-03-08 18:05:24 -08:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
aFontList.AppendElement(kFontHiraginoKakuGothic);
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontAppleColorEmoji);
|
2012-03-08 18:05:24 -08:00
|
|
|
break;
|
|
|
|
case 0x2c:
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
2012-03-08 18:05:24 -08:00
|
|
|
case 0x2d:
|
2014-04-14 16:45:18 -07:00
|
|
|
aFontList.AppendElement(kFontKefa);
|
2012-03-08 18:05:24 -08:00
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
break;
|
|
|
|
case 0x28: // Braille
|
|
|
|
aFontList.AppendElement(kFontAppleBraille);
|
|
|
|
break;
|
2014-04-14 16:45:18 -07:00
|
|
|
case 0x31:
|
|
|
|
aFontList.AppendElement(kFontHiraginoSansGB);
|
|
|
|
break;
|
2012-03-08 18:05:24 -08:00
|
|
|
case 0x4d:
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
|
|
|
case 0xa0: // Yi
|
|
|
|
case 0xa1:
|
|
|
|
case 0xa2:
|
|
|
|
case 0xa3:
|
|
|
|
case 0xa4:
|
|
|
|
aFontList.AppendElement(kFontSTHeiti);
|
|
|
|
break;
|
|
|
|
case 0xa6:
|
|
|
|
case 0xa7:
|
|
|
|
aFontList.AppendElement(kFontGeneva);
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
2014-04-14 16:45:18 -07:00
|
|
|
case 0xab:
|
|
|
|
aFontList.AppendElement(kFontKefa);
|
|
|
|
break;
|
2012-03-08 18:05:24 -08:00
|
|
|
case 0xfc:
|
|
|
|
case 0xff:
|
|
|
|
aFontList.AppendElement(kFontAppleSymbols);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Arial Unicode MS has lots of glyphs for obscure, use it as a last resort
|
|
|
|
aFontList.AppendElement(kFontArialUnicodeMS);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2008-05-01 02:07:17 -07:00
|
|
|
gfxPlatformMac::ReadAntiAliasingThreshold()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t threshold = 0; // default == no threshold
|
2008-05-01 02:07:17 -07:00
|
|
|
|
|
|
|
// first read prefs flag to determine whether to use the setting or not
|
2011-09-28 23:19:26 -07:00
|
|
|
bool useAntiAliasingThreshold = Preferences::GetBool("gfx.use_text_smoothing_setting", false);
|
2011-06-11 19:30:16 -07:00
|
|
|
|
2008-05-01 02:07:17 -07:00
|
|
|
// if the pref setting is disabled, return 0 which effectively disables this feature
|
|
|
|
if (!useAntiAliasingThreshold)
|
|
|
|
return threshold;
|
|
|
|
|
|
|
|
// value set via Appearance pref panel, "Turn off text smoothing for font sizes xxx and smaller"
|
|
|
|
CFNumberRef prefValue = (CFNumberRef)CFPreferencesCopyAppValue(CFSTR("AppleAntiAliasingThreshold"), kCFPreferencesCurrentApplication);
|
|
|
|
|
|
|
|
if (prefValue) {
|
|
|
|
if (!CFNumberGetValue(prefValue, kCFNumberIntType, &threshold)) {
|
|
|
|
threshold = 0;
|
|
|
|
}
|
|
|
|
CFRelease(prefValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return threshold;
|
|
|
|
}
|
2008-01-30 16:23:36 -08:00
|
|
|
|
2012-01-09 10:54:44 -08:00
|
|
|
already_AddRefed<gfxASurface>
|
|
|
|
gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
|
|
|
|
{
|
2014-06-19 13:35:33 -07:00
|
|
|
if (aTarget->GetBackendType() == BackendType::COREGRAPHICS_ACCELERATED) {
|
2012-07-31 08:17:43 -07:00
|
|
|
RefPtr<SourceSurface> source = aTarget->Snapshot();
|
|
|
|
RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
|
|
|
|
unsigned char* data = sourceData->GetData();
|
|
|
|
nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(data, ThebesIntSize(sourceData->GetSize()), sourceData->Stride(),
|
2014-01-23 10:26:40 -08:00
|
|
|
gfxImageFormat::ARGB32);
|
2012-07-31 08:17:43 -07:00
|
|
|
// We could fix this by telling gfxImageSurface it owns data.
|
2014-01-23 10:26:40 -08:00
|
|
|
nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormat::ARGB32);
|
2012-07-31 08:17:43 -07:00
|
|
|
cpy->CopyFrom(surf);
|
|
|
|
return cpy.forget();
|
2014-06-19 13:35:33 -07:00
|
|
|
} else if (aTarget->GetBackendType() == BackendType::COREGRAPHICS) {
|
2014-01-10 11:06:16 -08:00
|
|
|
CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
|
2012-01-09 10:54:44 -08:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
//XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
|
|
|
|
IntSize intSize = aTarget->GetSize();
|
|
|
|
gfxIntSize size(intSize.width, intSize.height);
|
2012-01-13 06:48:29 -08:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
nsRefPtr<gfxASurface> surf =
|
|
|
|
new gfxQuartzSurface(cg, size);
|
2012-07-25 23:48:24 -07:00
|
|
|
|
2012-07-25 19:30:20 -07:00
|
|
|
return surf.forget();
|
2012-01-09 10:54:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
|
|
|
|
}
|
|
|
|
|
2012-07-31 08:17:43 -07:00
|
|
|
bool
|
|
|
|
gfxPlatformMac::UseAcceleratedCanvas()
|
|
|
|
{
|
|
|
|
// Lion or later is required
|
2014-03-27 22:40:42 -07:00
|
|
|
return nsCocoaFeatures::OnLionOrLater() && Preferences::GetBool("gfx.canvas.azure.accelerated", false);
|
2012-07-31 08:17:43 -07:00
|
|
|
}
|
2012-01-09 10:54:44 -08:00
|
|
|
|
2013-11-07 02:20:08 -08:00
|
|
|
void
|
|
|
|
gfxPlatformMac::GetPlatformCMSOutputProfile(void* &mem, size_t &size)
|
2007-07-23 15:02:17 -07:00
|
|
|
{
|
2013-11-07 02:20:08 -08:00
|
|
|
mem = nullptr;
|
|
|
|
size = 0;
|
|
|
|
|
2013-10-08 22:53:37 -07:00
|
|
|
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
|
|
|
|
if (!cspace) {
|
|
|
|
cspace = ::CGColorSpaceCreateDeviceRGB();
|
|
|
|
}
|
|
|
|
if (!cspace) {
|
2013-11-07 02:20:08 -08:00
|
|
|
return;
|
2013-10-08 22:53:37 -07:00
|
|
|
}
|
2007-07-23 15:02:17 -07:00
|
|
|
|
2013-10-08 22:53:37 -07:00
|
|
|
CFDataRef iccp = ::CGColorSpaceCopyICCProfile(cspace);
|
2009-10-03 11:33:55 -07:00
|
|
|
|
2013-10-08 22:53:37 -07:00
|
|
|
::CFRelease(cspace);
|
|
|
|
|
|
|
|
if (!iccp) {
|
2013-11-07 02:20:08 -08:00
|
|
|
return;
|
2007-07-23 15:02:17 -07:00
|
|
|
}
|
|
|
|
|
2013-11-07 02:20:08 -08:00
|
|
|
// copy to external buffer
|
|
|
|
size = static_cast<size_t>(::CFDataGetLength(iccp));
|
|
|
|
if (size > 0) {
|
|
|
|
void *data = malloc(size);
|
|
|
|
if (data) {
|
|
|
|
memcpy(data, ::CFDataGetBytePtr(iccp), size);
|
|
|
|
mem = data;
|
|
|
|
} else {
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-10-08 22:53:37 -07:00
|
|
|
|
|
|
|
::CFRelease(iccp);
|
2007-07-23 15:02:17 -07:00
|
|
|
}
|