зеркало из https://github.com/mozilla/gecko-dev.git
b=366870, add font/glyph selection test framework, r=stuart
This commit is contained in:
Родитель
525913688b
Коммит
01a30217c8
|
@ -10,9 +10,8 @@ MODULE = thebes
|
|||
|
||||
DIRS = public src
|
||||
|
||||
# disabled until vlad fixes the tests to link against the right thing on non-windows
|
||||
#ifdef ENABLE_TESTS
|
||||
#TOOL_DIRS += test
|
||||
#endif
|
||||
ifdef ENABLE_TESTS
|
||||
TOOL_DIRS += test
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -27,6 +27,8 @@ EXPORTS = gfxASurface.h \
|
|||
gfxTextRunCache.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS += gfxFontTest.h
|
||||
|
||||
ifdef MOZ_ENABLE_GLITZ
|
||||
REQUIRES += glitz
|
||||
EXPORTS += gfxGlitzSurface.h
|
||||
|
|
|
@ -64,12 +64,16 @@ public:
|
|||
|
||||
ATSUStyle GetATSUStyle() { return mATSUStyle; }
|
||||
|
||||
virtual nsString GetUniqueName();
|
||||
|
||||
protected:
|
||||
const gfxFontStyle *mFontStyle;
|
||||
|
||||
ATSUFontID mATSUFontID;
|
||||
ATSUStyle mATSUStyle;
|
||||
|
||||
nsString mUniqueName;
|
||||
|
||||
cairo_font_face_t *mFontFace;
|
||||
cairo_scaled_font_t *mScaledFont;
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ public:
|
|||
const nsString& GetName() const { return mName; }
|
||||
const gfxFontStyle *GetStyle() const { return mStyle; }
|
||||
|
||||
virtual nsString GetUniqueName() { return GetName(); }
|
||||
|
||||
struct Metrics {
|
||||
gfxFloat xHeight;
|
||||
gfxFloat superscriptOffset;
|
||||
|
@ -238,6 +240,7 @@ class THEBES_API gfxTextRun {
|
|||
THEBES_INLINE_DECL_REFCOUNTING(gfxTextRun)
|
||||
|
||||
public:
|
||||
gfxTextRun() : mIsRTL(PR_FALSE) { }
|
||||
virtual ~gfxTextRun() {}
|
||||
|
||||
virtual void Draw(gfxContext *aContext, gfxPoint pt) = 0;
|
||||
|
|
|
@ -380,6 +380,8 @@ public:
|
|||
void UpdateCTM(const gfxMatrix& aMatrix);
|
||||
gfxFloat GetAdjustedSize() { MakeHFONT(); return mAdjustedSize; }
|
||||
|
||||
virtual nsString GetUniqueName();
|
||||
|
||||
protected:
|
||||
HFONT MakeHFONT();
|
||||
cairo_font_face_t *MakeCairoFontFace();
|
||||
|
|
|
@ -26,10 +26,11 @@ CPPSRCS = \
|
|||
gfxContext.cpp \
|
||||
gfxImageSurface.cpp \
|
||||
gfxFont.cpp \
|
||||
gfxRect.cpp \
|
||||
gfxSkipChars.cpp \
|
||||
gfxRect.cpp \
|
||||
gfxSkipChars.cpp \
|
||||
gfxTextRunCache.cpp \
|
||||
gfxPlatform.cpp \
|
||||
gfxPlatform.cpp \
|
||||
gfxFontTest.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_TREE_CAIRO
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "gfxContext.h"
|
||||
#include "gfxAtsuiFonts.h"
|
||||
|
||||
#include "gfxFontTest.h"
|
||||
|
||||
#include "cairo-atsui.h"
|
||||
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
@ -180,6 +182,12 @@ gfxAtsuiFont::gfxAtsuiFont(ATSUFontID fontID,
|
|||
cairo_font_options_destroy(fontOptions);
|
||||
}
|
||||
|
||||
nsString
|
||||
gfxAtsuiFont::GetUniqueName()
|
||||
{
|
||||
return gfxQuartzFontCache::SharedFontCache()->GetPostscriptNameForFontID(mATSUFontID);
|
||||
}
|
||||
|
||||
float
|
||||
gfxAtsuiFont::GetCharWidth(PRUnichar c)
|
||||
{
|
||||
|
@ -515,6 +523,12 @@ gfxAtsuiTextRun::Draw(gfxContext *aContext, gfxPoint pt)
|
|||
}
|
||||
|
||||
gfxAtsuiFont *font = mGroup->FindFontFor(runFontID);
|
||||
|
||||
if (gfxFontTestStore::CurrentStore()) {
|
||||
gfxFontTestStore::CurrentStore()->AddItem(font->GetUniqueName(),
|
||||
cairoGlyphs.glyphs, numGlyphs);
|
||||
}
|
||||
|
||||
cairo_set_scaled_font (cr, font->CairoScaledFont());
|
||||
cairo_show_glyphs (cr, cairoGlyphs.glyphs, numGlyphs);
|
||||
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
PRBool ResolveFontName(const nsAString& aFontName,
|
||||
nsAString& aResolvedFontName);
|
||||
void UpdateFontList() { InitFontList(); }
|
||||
|
||||
const nsString& GetPostscriptNameForFontID(ATSUFontID fid);
|
||||
|
||||
private:
|
||||
static gfxQuartzFontCache *sSharedFontCache;
|
||||
|
||||
|
|
|
@ -754,3 +754,15 @@ gfxQuartzFontCache::ResolveFontName(const nsAString& aFontName,
|
|||
aResolvedFontName = fe->Name();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
const nsString&
|
||||
gfxQuartzFontCache::GetPostscriptNameForFontID(ATSUFontID fid)
|
||||
{
|
||||
nsRefPtr<FontEntry> fe;
|
||||
|
||||
if (!mFontIDTable.Get(PRUint32(fid), &fe)) {
|
||||
return NS_LITERAL_STRING("INVALID_FONT");
|
||||
}
|
||||
|
||||
return fe->Name();
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include "gfxGlitzSurface.h"
|
||||
#endif
|
||||
|
||||
#include "gfxFontTest.h"
|
||||
|
||||
#include "nsUnicodeRange.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
|
@ -424,6 +426,36 @@ gfxWindowsFont::FillLogFont(gfxFloat aSize, PRInt16 aWeight)
|
|||
}
|
||||
|
||||
|
||||
nsString
|
||||
gfxWindowsFont::GetUniqueName()
|
||||
{
|
||||
nsString uniqueName;
|
||||
|
||||
// make sure this exists, because we're going to read its fields
|
||||
MakeHFONT();
|
||||
|
||||
// start with the family name
|
||||
uniqueName.Assign(mName);
|
||||
|
||||
// append the weight code
|
||||
if (mLogFont.lfWeight != 400) {
|
||||
uniqueName.AppendLiteral(":");
|
||||
uniqueName.AppendInt(mLogFont.lfWeight);
|
||||
}
|
||||
|
||||
// append italic?
|
||||
if (mLogFont.lfItalic)
|
||||
uniqueName.AppendLiteral(":Italic");
|
||||
|
||||
if (mLogFont.lfUnderline)
|
||||
uniqueName.AppendLiteral(":Underline");
|
||||
|
||||
if (mLogFont.lfStrikeOut)
|
||||
uniqueName.AppendLiteral(":StrikeOut");
|
||||
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* class gfxWindowsFontGroup
|
||||
|
@ -1347,6 +1379,10 @@ TRY_AGAIN_HOPE_FOR_THE_BEST_2:
|
|||
}
|
||||
}
|
||||
|
||||
gfxWindowsFont *GetCurrentFont() {
|
||||
return mCurrentFont;
|
||||
}
|
||||
|
||||
void SelectFont() {
|
||||
if (mFontSelected)
|
||||
return;
|
||||
|
@ -1684,6 +1720,11 @@ SCRIPT_PLACE:
|
|||
GetWorldTransform(aDC, ¤txform);
|
||||
SetWorldTransform(aDC, &savedxform);
|
||||
|
||||
if (gfxFontTestStore::CurrentStore()) {
|
||||
gfxFontTestStore::CurrentStore()->AddItem(item->GetCurrentFont()->GetUniqueName(),
|
||||
cglyphs, nglyphs);
|
||||
}
|
||||
|
||||
cairo_show_glyphs(cr, cglyphs, nglyphs);
|
||||
|
||||
SetWorldTransform(aDC, ¤txform);
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
# The Original Code is Oracle Corporation code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Oracle Corporation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# Mozilla Corporation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
|
||||
# Vladimir Vukicevic <vladimir@pobox.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -50,20 +50,42 @@ REQUIRES = \
|
|||
string \
|
||||
thebes \
|
||||
cairo \
|
||||
pref \
|
||||
thebes \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
MAIN_CPPSRCS = \
|
||||
gfxSurfaceRefCountTest.cpp \
|
||||
gfxFontSelectionTest.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = $(MAIN_CPPSRCS)
|
||||
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),cocoa)
|
||||
CMMSRCS = gfxTestCocoaHelper.mm
|
||||
HELPER_OBJS = gfxTestCocoaHelper.$(OBJ_SUFFIX)
|
||||
EXTRA_DEPS += gfxTestCocoaHelper.$(OBJ_SUFFIX)
|
||||
endif
|
||||
|
||||
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
|
||||
|
||||
LIBS = \
|
||||
EXTRA_LDOPS += $(TK_LIBS)
|
||||
|
||||
LIBS = $(HELPER_OBJS) \
|
||||
$(LIBS_DIR) \
|
||||
$(XPCOM_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(DEPTH)/dist/lib/thebes.lib \
|
||||
$(call EXPAND_MOZLIBNAME,thebes) \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),windows)
|
||||
_OS_LIBS += usp10
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),cocoa)
|
||||
OS_LIBS += -framework Cocoa
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
Загрузка…
Ссылка в новой задаче