bug 556420 - Add support for android to thebes r=joedrew

This commit is contained in:
Vladimir Vukicevic 2010-05-11 13:27:36 -04:00
parent 86c80047ba
commit 706e10c197
10 changed files with 681 additions and 0 deletions

View File

@ -99,6 +99,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = nsSystemFontsMac.mm
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += nsSystemFontsAndroid.cpp
endif
EXPORTS += nsIThebesFontMetrics.h
LOCAL_INCLUDES = \

View File

@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Android port
*
* The Initial Developer of the Original Code is mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDeviceContext.h"
#include "nsIRenderingContext.h"
#include "nsSystemFontsAndroid.h"
#include "gfxPlatform.h"
#define DEFAULT_FONT "Droid Sans"
nsSystemFontsAndroid::nsSystemFontsAndroid()
: mDefaultFontName(NS_LITERAL_STRING(DEFAULT_FONT))
, mButtonFontName(NS_LITERAL_STRING(DEFAULT_FONT))
, mFieldFontName(NS_LITERAL_STRING(DEFAULT_FONT))
, mMenuFontName(NS_LITERAL_STRING(DEFAULT_FONT))
{
}
nsSystemFontsAndroid::~nsSystemFontsAndroid()
{
}
nsresult
nsSystemFontsAndroid::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
gfxFontStyle *aFontStyle) const
{
aFontStyle->style = FONT_STYLE_NORMAL;
aFontStyle->systemFont = PR_TRUE;
*aFontName = NS_LITERAL_STRING("Droid Sans");
aFontStyle->weight = 400;
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
aFontStyle->size = 9.0 * float(gfxPlatform::GetDPI()) / 72.0f;
return NS_OK;
}
nsresult
nsSystemFontsAndroid::GetSystemFont(nsSystemFontID anID, nsString *aFontName,
gfxFontStyle *aFontStyle) const
{
switch (anID) {
case eSystemFont_Menu: // css2
case eSystemFont_PullDownMenu: // css3
*aFontName = mMenuFontName;
*aFontStyle = mMenuFontStyle;
break;
case eSystemFont_Field: // css3
case eSystemFont_List: // css3
*aFontName = mFieldFontName;
*aFontStyle = mFieldFontStyle;
break;
case eSystemFont_Button: // css3
*aFontName = mButtonFontName;
*aFontStyle = mButtonFontStyle;
break;
case eSystemFont_Caption: // css2
case eSystemFont_Icon: // css2
case eSystemFont_MessageBox: // css2
case eSystemFont_SmallCaption: // css2
case eSystemFont_StatusBar: // css2
case eSystemFont_Window: // css3
case eSystemFont_Document: // css3
case eSystemFont_Workspace: // css3
case eSystemFont_Desktop: // css3
case eSystemFont_Info: // css3
case eSystemFont_Dialog: // css3
case eSystemFont_Tooltips: // moz
case eSystemFont_Widget: // moz
*aFontName = mDefaultFontName;
*aFontStyle = mDefaultFontStyle;
break;
}
return NS_OK;
}

View File

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Android port
*
* The Initial Developer of the Original Code is mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _NS_SYSTEMFONTSANDROID_H_
#define _NS_SYSTEMFONTSANDROID_H_
#include <gfxFont.h>
class nsSystemFontsAndroid
{
public:
nsSystemFontsAndroid();
~nsSystemFontsAndroid();
nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
gfxFontStyle *aFontStyle) const;
private:
nsresult GetSystemFontInfo(const char *aClassName, nsString *aFontName,
gfxFontStyle *aFontStyle) const;
/*
* The following system font constants exist:
*
* css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27
* eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu,
* eSystemFont_MessageBox, eSystemFont_SmallCaption,
* eSystemFont_StatusBar,
* // css3
* eSystemFont_Window, eSystemFont_Document,
* eSystemFont_Workspace, eSystemFont_Desktop,
* eSystemFont_Info, eSystemFont_Dialog,
* eSystemFont_Button, eSystemFont_PullDownMenu,
* eSystemFont_List, eSystemFont_Field,
* // moz
* eSystemFont_Tooltips, eSystemFont_Widget
*/
nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName;
gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle;
};
#endif /* _NS_SYSTEMFONTSANDROID_H_ */

View File

@ -88,6 +88,9 @@ static nsSystemFontsMac *gSystemFonts = nsnull;
#elif defined(MOZ_WIDGET_QT)
#include "nsSystemFontsQt.h"
static nsSystemFontsQt *gSystemFonts = nsnull;
#elif defined(ANDROID)
#include "nsSystemFontsAndroid.h"
static nsSystemFontsAndroid *gSystemFonts = nsnull;
#else
#error Need to declare gSystemFonts!
#endif
@ -829,6 +832,8 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
gSystemFonts = new nsSystemFontsMac();
#elif defined(MOZ_WIDGET_QT)
gSystemFonts = new nsSystemFontsQt();
#elif defined(ANDROID)
gSystemFonts = new nsSystemFontsAndroid();
#else
#error Need to know how to create gSystemFonts, fix me!
#endif

View File

@ -60,6 +60,14 @@ endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
EXPORTS += \
gfxAndroidPlatform.h \
gfxFT2Fonts.h \
gfxFT2FontBase.h \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
ifdef MOZ_X11

View File

@ -0,0 +1,105 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Android port code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_PLATFORM_ANDROID_H
#define GFX_PLATFORM_ANDROID_H
#include "gfxFontUtils.h"
#include "gfxFT2Fonts.h"
#include "gfxPlatform.h"
#include "nsDataHashtable.h"
#include "nsTArray.h"
typedef struct FT_LibraryRec_ *FT_Library;
class FontFamily;
class FontEntry;
class THEBES_API gfxAndroidPlatform : public gfxPlatform {
public:
gfxAndroidPlatform();
virtual ~gfxAndroidPlatform();
static gfxAndroidPlatform *GetPlatform() {
return (gfxAndroidPlatform*) gfxPlatform::GetPlatform();
}
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
nsresult GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,
nsTArray<nsString>& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure, PRBool& aAborted);
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet);
FontFamily *FindFontFamily(const nsAString& aName);
FontEntry *FindFontEntry(const nsAString& aFamilyName, const gfxFontStyle& aFontStyle);
already_AddRefed<gfxFont> FindFontForChar(PRUint32 aCh, gfxFont *aFont);
PRBool GetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList);
void SetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
FT_Library GetFTLibrary();
protected:
void AppendFacesFromFontFile(const char *aFileName);
typedef nsDataHashtable<nsStringHashKey, nsRefPtr<FontFamily> > FontTable;
FontTable mFonts;
FontTable mFontAliases;
FontTable mFontSubstitutes;
// when system-wide font lookup fails for a character, cache it to skip future searches
gfxSparseBitSet mCodepointsWithNoFonts;
nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > mPrefFonts;
};
#endif /* GFX_PLATFORM_ANDROID_H */

View File

@ -104,6 +104,16 @@ OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
ACDEFINES += -UWIN32_LEAN_AND_MEAN
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += \
gfxAndroidPlatform.cpp \
gfxFT2Fonts.cpp \
gfxFT2FontBase.cpp \
gfxFT2Utils.cpp \
nsUnicodeRange.cpp \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += gfxOS2Fonts.cpp \
gfxOS2Platform.cpp \
@ -225,6 +235,10 @@ CXXFLAGS += $(CAIRO_FT_CFLAGS)
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CXXFLAGS += $(CAIRO_FT_CFLAGS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CXXFLAGS += $(MOZ_PANGO_CFLAGS)
endif

View File

@ -0,0 +1,342 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Android port code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <android/log.h>
#include <sys/types.h>
#include <dirent.h>
#include "gfxAndroidPlatform.h"
#include "cairo.h"
#include "cairo-ft.h"
#include "gfxImageSurface.h"
#include "nsUnicharUtils.h"
#include "nsMathUtils.h"
#include "nsTArray.h"
#include "qcms.h"
#include "ft2build.h"
#include FT_FREETYPE_H
#include "gfxFT2Fonts.h"
static FT_Library gPlatformFTLibrary = NULL;
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
gfxAndroidPlatform::gfxAndroidPlatform()
{
FT_Init_FreeType(&gPlatformFTLibrary);
mFonts.Init(200);
mFontAliases.Init(20);
mFontSubstitutes.Init(50);
mPrefFonts.Init(10);
UpdateFontList();
}
gfxAndroidPlatform::~gfxAndroidPlatform()
{
cairo_debug_reset_static_data();
FT_Done_FreeType(gPlatformFTLibrary);
gPlatformFTLibrary = NULL;
}
already_AddRefed<gfxASurface>
gfxAndroidPlatform::CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat)
{
nsRefPtr<gfxASurface> newSurface =
new gfxImageSurface (size, imageFormat);
return newSurface.forget();
}
struct FontListData {
FontListData(nsIAtom *aLangGroup, const nsACString& aGenericFamily, nsTArray<nsString>& aListOfFonts) :
mLangGroup(aLangGroup), mGenericFamily(aGenericFamily), mStringArray(aListOfFonts) {}
nsIAtom *mLangGroup;
const nsACString& mGenericFamily;
nsTArray<nsString>& mStringArray;
};
static PLDHashOperator
FontListHashEnumFunc(nsStringHashKey::KeyType aKey,
nsRefPtr<FontFamily>& aFontFamily,
void* userArg)
{
FontListData *data = (FontListData*)userArg;
// use the first variation for now. This data should be the same
// for all the variations and should probably be moved up to
// the Family
gfxFontStyle style;
style.language = data->mLangGroup;
nsRefPtr<FontEntry> aFontEntry = aFontFamily->FindFontEntry(style);
NS_ASSERTION(aFontEntry, "couldn't find any font entry in family");
if (!aFontEntry)
return PL_DHASH_NEXT;
data->mStringArray.AppendElement(aFontFamily->Name());
return PL_DHASH_NEXT;
}
nsresult
gfxAndroidPlatform::GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,
nsTArray<nsString>& aListOfFonts)
{
FontListData data(aLangGroup, aGenericFamily, aListOfFonts);
mFonts.Enumerate(FontListHashEnumFunc, &data);
aListOfFonts.Sort();
aListOfFonts.Compact();
return NS_OK;
}
void
gfxAndroidPlatform::AppendFacesFromFontFile(const char *fileName)
{
FT_Face dummy;
if (FT_Err_Ok == FT_New_Face(GetFTLibrary(), fileName, -1, &dummy)) {
for (FT_Long i = 0; i < dummy->num_faces; i++) {
FT_Face face;
if (FT_Err_Ok != FT_New_Face(GetFTLibrary(), fileName,
i, &face))
continue;
FontEntry* fe = FontEntry::CreateFontEntryFromFace(face);
if (fe) {
LOG("font family: %s", face->family_name);
NS_ConvertUTF8toUTF16 name(face->family_name);
ToLowerCase(name);
nsRefPtr<FontFamily> ff;
if (!mFonts.Get(name, &ff)) {
ff = new FontFamily(name);
mFonts.Put(name, ff);
}
ff->AddFontEntry(fe);
ff->SetHasStyles(PR_TRUE);
}
}
FT_Done_Face(dummy);
}
}
nsresult
gfxAndroidPlatform::UpdateFontList()
{
gfxFontCache *fc = gfxFontCache::GetCache();
if (fc)
fc->AgeAllGenerations();
mFonts.Clear();
mFontAliases.Clear();
mFontSubstitutes.Clear();
mPrefFonts.Clear();
mCodepointsWithNoFonts.reset();
//CancelLoader();
DIR *d = opendir("/system/fonts");
struct dirent *ent = NULL;
while(d && (ent = readdir(d)) != NULL) {
int namelen = strlen(ent->d_name);
if (namelen > 4 &&
strcasecmp(ent->d_name + namelen - 4, ".ttf") == 0)
{
nsCString s("/system/fonts");
s.Append("/");
s.Append(nsDependentCString(ent->d_name));
LOG("Font: %s", nsPromiseFlatCString(s).get());
AppendFacesFromFontFile(nsPromiseFlatCString(s).get());
}
}
// initialize the cmap loading process after font list has been initialized
//StartLoader(kDelayBeforeLoadingCmaps, kIntervalBetweenLoadingCmaps);
// initialize ranges of characters for which system-wide font search should be skipped
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
return NS_OK;
}
nsresult
gfxAndroidPlatform::ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
void *aClosure,
PRBool& aAborted)
{
if (aFontName.IsEmpty())
return NS_ERROR_FAILURE;
nsAutoString keyName(aFontName);
ToLowerCase(keyName);
nsRefPtr<FontFamily> ff;
if (mFonts.Get(keyName, &ff) ||
mFontSubstitutes.Get(keyName, &ff) ||
mFontAliases.Get(keyName, &ff))
{
aAborted = !(*aCallback)(ff->Name(), aClosure);
} else {
aAborted = PR_FALSE;
}
return NS_OK;
}
static PRBool SimpleResolverCallback(const nsAString& aName, void* aClosure)
{
nsString *result = static_cast<nsString*>(aClosure);
result->Assign(aName);
return PR_FALSE;
}
nsresult
gfxAndroidPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
{
aFamilyName.Truncate();
PRBool aborted;
return ResolveFontName(aFontName, SimpleResolverCallback, &aFamilyName, aborted);
}
gfxFontGroup *
gfxAndroidPlatform::CreateFontGroup(const nsAString &aFamilies,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet)
{
return new gfxFT2FontGroup(aFamilies, aStyle);
}
FT_Library
gfxAndroidPlatform::GetFTLibrary()
{
return gPlatformFTLibrary;
}
FontFamily *
gfxAndroidPlatform::FindFontFamily(const nsAString& aName)
{
nsAutoString name(aName);
ToLowerCase(name);
nsRefPtr<FontFamily> ff;
if (!mFonts.Get(name, &ff) &&
!mFontSubstitutes.Get(name, &ff) &&
!mFontAliases.Get(name, &ff)) {
return nsnull;
}
return ff.get();
}
FontEntry *
gfxAndroidPlatform::FindFontEntry(const nsAString& aName, const gfxFontStyle& aFontStyle)
{
nsRefPtr<FontFamily> ff = FindFontFamily(aName);
if (!ff)
return nsnull;
return ff->FindFontEntry(aFontStyle);
}
static PLDHashOperator
FindFontForCharProc(nsStringHashKey::KeyType aKey,
nsRefPtr<FontFamily>& aFontFamily,
void* aUserArg)
{
FontSearch *data = (FontSearch*)aUserArg;
aFontFamily->FindFontForChar(data);
return PL_DHASH_NEXT;
}
already_AddRefed<gfxFont>
gfxAndroidPlatform::FindFontForChar(PRUint32 aCh, gfxFont *aFont)
{
// is codepoint with no matching font? return null immediately
if (mCodepointsWithNoFonts.test(aCh)) {
return nsnull;
}
FontSearch data(aCh, aFont);
// find fonts that support the character
mFonts.Enumerate(FindFontForCharProc, &data);
if (data.mBestMatch) {
nsRefPtr<gfxFT2Font> font =
gfxFT2Font::GetOrMakeFont(static_cast<FontEntry*>(data.mBestMatch.get()),
aFont->GetStyle());
gfxFont* ret = font.forget().get();
return already_AddRefed<gfxFont>(ret);
}
// no match? add to set of non-matching codepoints
mCodepointsWithNoFonts.set(aCh);
return nsnull;
}
PRBool
gfxAndroidPlatform::GetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList)
{
return mPrefFonts.Get(aKey, aFontEntryList);
}
void
gfxAndroidPlatform::SetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList)
{
mPrefFonts.Put(aKey, aFontEntryList);
}

View File

@ -48,7 +48,11 @@
#include "gfxWindowsPlatform.h"
#define gfxToolkitPlatform gfxWindowsPlatform
#include "gfxFT2FontList.h"
#elif defined(ANDROID)
#include "gfxAndroidPlatform.h"
#define gfxToolkitPlatform gfxAndroidPlatform
#endif
#include "gfxTypes.h"
#include "gfxFT2Fonts.h"
#include "gfxFT2FontBase.h"
@ -361,6 +365,8 @@ gfxFT2FontGroup::gfxFT2FontGroup(const nsAString& families,
LOGFONTW logFont;
if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont))
familyArray.AppendElement(nsDependentString(logFont.lfFaceName));
#elif defined(ANDROID)
familyArray.AppendElement(NS_LITERAL_STRING("Droid Sans"));
#else
#error "Platform not supported"
#endif

View File

@ -49,6 +49,8 @@
#include "gfxBeOSPlatform.h"
#elif defined(XP_OS2)
#include "gfxOS2Platform.h"
#elif defined(ANDROID)
#include "gfxAndroidPlatform.h"
#endif
#include "gfxAtoms.h"
@ -193,6 +195,8 @@ gfxPlatform::Init()
gPlatform = new gfxBeOSPlatform;
#elif defined(XP_OS2)
gPlatform = new gfxOS2Platform;
#elif defined(ANDROID)
gPlatform = new gfxAndroidPlatform;
#endif
if (!gPlatform)
return NS_ERROR_OUT_OF_MEMORY;