mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Backed out 2 changesets (bug 736276) for reftest crashes on a CLOSED TREE.
Backed out changeset 1bd02a8da04f (bug 736276) Backed out changeset 120285554c44 (bug 736276)
This commit is contained in:
parent
b1e4956089
commit
46fedd529b
@ -924,11 +924,6 @@ public:
|
||||
CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aContext, const IntSize &aSize, SurfaceFormat aFormat);
|
||||
#endif
|
||||
|
||||
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
||||
static TemporaryRef<GlyphRenderingOptions>
|
||||
CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
|
||||
static TemporaryRef<DrawTarget>
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "DrawTargetSkia.h"
|
||||
#include "SourceSurfaceSkia.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#include "ScaledFontCairo.h"
|
||||
#include "skia/SkDevice.h"
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
@ -446,7 +445,7 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions *aRenderingOptions)
|
||||
const GlyphRenderingOptions*)
|
||||
{
|
||||
if (aFont->GetType() != FONT_MAC &&
|
||||
aFont->GetType() != FONT_SKIA &&
|
||||
@ -462,30 +461,7 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
|
||||
paint.mPaint.setTypeface(skiaFont->GetSkTypeface());
|
||||
paint.mPaint.setTextSize(SkFloatToScalar(skiaFont->mSize));
|
||||
paint.mPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
|
||||
if (aRenderingOptions && aRenderingOptions->GetType() == FONT_CAIRO) {
|
||||
switch (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetHinting()) {
|
||||
case FONT_HINTING_NONE:
|
||||
paint.mPaint.setHinting(SkPaint::kNo_Hinting);
|
||||
break;
|
||||
case FONT_HINTING_LIGHT:
|
||||
paint.mPaint.setHinting(SkPaint::kSlight_Hinting);
|
||||
break;
|
||||
case FONT_HINTING_NORMAL:
|
||||
paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
|
||||
break;
|
||||
case FONT_HINTING_FULL:
|
||||
paint.mPaint.setHinting(SkPaint::kFull_Hinting);
|
||||
break;
|
||||
}
|
||||
|
||||
if (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetAutoHinting()) {
|
||||
paint.mPaint.setAutohinted(true);
|
||||
}
|
||||
} else {
|
||||
paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint16_t> indices;
|
||||
std::vector<SkPoint> offsets;
|
||||
indices.resize(aBuffer.mNumGlyphs);
|
||||
|
@ -7,15 +7,14 @@
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
#include "DrawTargetCairo.h"
|
||||
#include "ScaledFontCairo.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_SKIA
|
||||
#include "DrawTargetSkia.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
#define USE_SKIA_FREETYPE
|
||||
#include "ScaledFontCairo.h"
|
||||
#include "ScaledFontFreetype.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -298,10 +297,20 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
|
||||
return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE)
|
||||
#ifdef USE_SKIA
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
case NATIVE_FONT_SKIA_FONT_FACE:
|
||||
{
|
||||
return new ScaledFontFreetype(static_cast<FontOptions*>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_CAIRO
|
||||
case NATIVE_FONT_CAIRO_FONT_FACE:
|
||||
{
|
||||
return new ScaledFontCairo(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize);
|
||||
ScaledFontBase* fontBase = new ScaledFontBase(aSize);
|
||||
fontBase->SetCairoScaledFont(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont));
|
||||
return fontBase;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
@ -450,19 +459,6 @@ Factory::CreateSkiaDrawTargetForFBO(unsigned int aFBOID, GrContext *aGrContext,
|
||||
}
|
||||
#endif // USE_SKIA_GPU
|
||||
|
||||
#ifdef USE_SKIA_FREETYPE
|
||||
TemporaryRef<GlyphRenderingOptions>
|
||||
Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting)
|
||||
{
|
||||
RefPtr<GlyphRenderingOptionsCairo> options =
|
||||
new GlyphRenderingOptionsCairo();
|
||||
|
||||
options->SetHinting(aHinting);
|
||||
options->SetAutoHinting(aAutoHinting);
|
||||
return options;
|
||||
}
|
||||
#endif
|
||||
|
||||
TemporaryRef<DrawTarget>
|
||||
Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ CPPSRCS = \
|
||||
Blur.cpp \
|
||||
Scale.cpp \
|
||||
ScaledFontBase.cpp \
|
||||
ScaledFontCairo.cpp \
|
||||
DrawTargetDual.cpp \
|
||||
ImageScaling.cpp \
|
||||
SourceSurfaceRawData.cpp \
|
||||
@ -74,8 +73,10 @@ CPPSRCS += \
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),$(findstring $(MOZ_WIDGET_TOOLKIT),android gtk2 gonk qt))
|
||||
CPPSRCS += \
|
||||
ScaledFontFreetype.cpp \
|
||||
$(NULL)
|
||||
DEFINES += -DMOZ_ENABLE_FREETYPE
|
||||
OS_CXXFLAGS += $(CAIRO_FT_CFLAGS)
|
||||
endif
|
||||
|
||||
DEFINES += -DSK_A32_SHIFT=24 -DSK_R32_SHIFT=16 -DSK_G32_SHIFT=8 -DSK_B32_SHIFT=0
|
||||
|
@ -28,7 +28,7 @@ ScaledFontBase::~ScaledFontBase()
|
||||
#ifdef USE_SKIA
|
||||
SkSafeUnref(mTypeface);
|
||||
#endif
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
cairo_scaled_font_destroy(mScaledFont);
|
||||
#endif
|
||||
}
|
||||
@ -39,7 +39,7 @@ ScaledFontBase::ScaledFontBase(Float aSize)
|
||||
#ifdef USE_SKIA
|
||||
mTypeface = nullptr;
|
||||
#endif
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
mScaledFont = nullptr;
|
||||
#endif
|
||||
}
|
||||
@ -106,7 +106,7 @@ ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBu
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
void
|
||||
ScaledFontBase::SetCairoScaledFont(cairo_scaled_font_t* font)
|
||||
{
|
||||
|
@ -8,15 +8,10 @@
|
||||
|
||||
#include "2D.h"
|
||||
|
||||
// Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
|
||||
#if defined(USE_SKIA) || defined(USE_CAIRO)
|
||||
#define USE_CAIRO_SCALED_FONT
|
||||
#endif
|
||||
|
||||
#ifdef USE_SKIA
|
||||
#include "skia/SkTypeface.h"
|
||||
#endif
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
#include "cairo.h"
|
||||
#endif
|
||||
|
||||
@ -44,7 +39,7 @@ public:
|
||||
// Not true, but required to instantiate a ScaledFontBase.
|
||||
virtual FontType GetType() const { return FONT_SKIA; }
|
||||
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
|
||||
void SetCairoScaledFont(cairo_scaled_font_t* font);
|
||||
#endif
|
||||
@ -54,7 +49,7 @@ protected:
|
||||
#ifdef USE_SKIA
|
||||
SkTypeface* mTypeface;
|
||||
#endif
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#ifdef USE_CAIRO
|
||||
cairo_scaled_font_t* mScaledFont;
|
||||
#endif
|
||||
Float mSize;
|
||||
|
@ -1,59 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* 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/. */
|
||||
|
||||
#include "ScaledFontCairo.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#include "gfxFont.h"
|
||||
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include "cairo-ft.h"
|
||||
#endif
|
||||
|
||||
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
||||
#include "skia/SkTypeface.h"
|
||||
#include "skia/SkTypeface_cairo.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef struct FT_FaceRec_* FT_Face;
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
// On Linux and Android our "platform" font is a cairo_scaled_font_t and we use
|
||||
// an SkFontHost implementation that allows Skia to render using this.
|
||||
// This is mainly because FT_Face is not good for sharing between libraries, which
|
||||
// is a requirement when we consider runtime switchable backends and so on
|
||||
ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize)
|
||||
: ScaledFontBase(aSize)
|
||||
{
|
||||
mScaledFont = aScaledFont;
|
||||
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
||||
cairo_font_face_t* fontFace = cairo_scaled_font_get_font_face(aScaledFont);
|
||||
FT_Face face = cairo_ft_scaled_font_lock_face(aScaledFont);
|
||||
|
||||
int style = SkTypeface::kNormal;
|
||||
|
||||
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
|
||||
style |= SkTypeface::kItalic;
|
||||
|
||||
if (face->style_flags & FT_STYLE_FLAG_BOLD)
|
||||
style |= SkTypeface::kBold;
|
||||
|
||||
bool isFixedWidth = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
|
||||
cairo_ft_scaled_font_unlock_face(aScaledFont);
|
||||
|
||||
mTypeface = SkCreateTypefaceFromCairoFont(fontFace, (SkTypeface::Style)style, isFixedWidth);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef MOZILLA_GFX_SCALEDFONTCAIRO_H_
|
||||
#define MOZILLA_GFX_SCALEDFONTCAIRO_H_
|
||||
|
||||
#include "ScaledFontBase.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class ScaledFontCairo : public ScaledFontBase
|
||||
{
|
||||
public:
|
||||
|
||||
ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize);
|
||||
};
|
||||
|
||||
// We need to be able to tell Skia whether or not to use
|
||||
// hinting when rendering text, so that the glyphs it renders
|
||||
// are the same as what layout is expecting. At the moment, only
|
||||
// Skia uses this class when rendering with FreeType, as gfxFT2Font
|
||||
// is the only gfxFont that honours gfxPlatform::FontHintingEnabled().
|
||||
class GlyphRenderingOptionsCairo : public GlyphRenderingOptions
|
||||
{
|
||||
public:
|
||||
GlyphRenderingOptionsCairo()
|
||||
: mHinting(FONT_HINTING_NORMAL)
|
||||
, mAutoHinting(false)
|
||||
{
|
||||
}
|
||||
|
||||
void SetHinting(FontHinting aHinting) { mHinting = aHinting; }
|
||||
void SetAutoHinting(bool aAutoHinting) { mAutoHinting = aAutoHinting; }
|
||||
FontHinting GetHinting() const { return mHinting; }
|
||||
bool GetAutoHinting() const { return mAutoHinting; }
|
||||
virtual FontType GetType() const { return FONT_CAIRO; }
|
||||
private:
|
||||
FontHinting mHinting;
|
||||
bool mAutoHinting;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */
|
53
gfx/2d/ScaledFontFreetype.cpp
Normal file
53
gfx/2d/ScaledFontFreetype.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* 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/. */
|
||||
|
||||
#include "ScaledFontFreetype.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#include "gfxFont.h"
|
||||
|
||||
#ifdef USE_SKIA
|
||||
#include "skia/SkTypeface.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
#ifdef USE_SKIA
|
||||
static SkTypeface::Style
|
||||
fontStyleToSkia(FontStyle aStyle)
|
||||
{
|
||||
switch (aStyle) {
|
||||
case FONT_STYLE_NORMAL:
|
||||
return SkTypeface::kNormal;
|
||||
case FONT_STYLE_ITALIC:
|
||||
return SkTypeface::kItalic;
|
||||
case FONT_STYLE_BOLD:
|
||||
return SkTypeface::kBold;
|
||||
case FONT_STYLE_BOLD_ITALIC:
|
||||
return SkTypeface::kBoldItalic;
|
||||
}
|
||||
|
||||
gfxWarning() << "Unknown font style";
|
||||
return SkTypeface::kNormal;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Ideally we want to use FT_Face here but as there is currently no way to get
|
||||
// an SkTypeface from an FT_Face we do this.
|
||||
ScaledFontFreetype::ScaledFontFreetype(FontOptions* aFont, Float aSize)
|
||||
: ScaledFontBase(aSize)
|
||||
{
|
||||
#ifdef USE_SKIA
|
||||
mTypeface = SkTypeface::CreateFromName(aFont->mName.c_str(), fontStyleToSkia(aFont->mStyle));
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
24
gfx/2d/ScaledFontFreetype.h
Normal file
24
gfx/2d/ScaledFontFreetype.h
Normal file
@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef MOZILLA_GFX_SCALEDFONTFREETYPE_H_
|
||||
#define MOZILLA_GFX_SCALEDFONTFREETYPE_H_
|
||||
|
||||
#include "ScaledFontBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
class ScaledFontFreetype : public ScaledFontBase
|
||||
{
|
||||
public:
|
||||
|
||||
ScaledFontFreetype(FontOptions* aFont, Float aSize);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_GFX_SCALEDFONTFREETYPE_H_ */
|
@ -88,14 +88,6 @@ enum FontStyle
|
||||
FONT_STYLE_BOLD_ITALIC
|
||||
};
|
||||
|
||||
enum FontHinting
|
||||
{
|
||||
FONT_HINTING_NONE,
|
||||
FONT_HINTING_LIGHT,
|
||||
FONT_HINTING_NORMAL,
|
||||
FONT_HINTING_FULL
|
||||
};
|
||||
|
||||
enum CompositionOp { OP_OVER, OP_ADD, OP_ATOP, OP_OUT, OP_IN, OP_SOURCE, OP_DEST_IN, OP_DEST_OUT, OP_DEST_OVER, OP_DEST_ATOP, OP_XOR,
|
||||
OP_MULTIPLY, OP_SCREEN, OP_OVERLAY, OP_DARKEN, OP_LIGHTEN, OP_COLOR_DODGE, OP_COLOR_BURN, OP_HARD_LIGHT, OP_SOFT_LIGHT, OP_DIFFERENCE, OP_EXCLUSION, OP_HUE, OP_SATURATION, OP_COLOR, OP_LUMINOSITY, OP_COUNT };
|
||||
enum ExtendMode { EXTEND_CLAMP, EXTEND_REPEAT, EXTEND_REFLECT };
|
||||
|
@ -299,15 +299,14 @@ CPPSRCS += \
|
||||
SkFontHost_mac_coretext.cpp \
|
||||
SkStream_mac.cpp \
|
||||
SkTime_Unix.cpp \
|
||||
SkThread_pthread.cpp \
|
||||
$(NULL)
|
||||
DEFINES += -DSK_USE_POSIX_THREADS=1
|
||||
endif
|
||||
|
||||
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += \
|
||||
SkDebug_android.cpp \
|
||||
SkFontHost_cairo.cpp \
|
||||
SkFontHost_android_old.cpp \
|
||||
SkFontHost_FreeType.cpp \
|
||||
SkFontHost_FreeType_common.cpp \
|
||||
SkFontHost_tables.cpp \
|
||||
SkMMapStream.cpp \
|
||||
@ -315,33 +314,27 @@ CPPSRCS += \
|
||||
SkThread_pthread.cpp \
|
||||
$(NULL)
|
||||
|
||||
OS_CXXFLAGS += $(CAIRO_FT_CFLAGS)
|
||||
DEFINES += -DSK_USE_POSIX_THREADS=1
|
||||
EXPORTS_skia += \
|
||||
include/ports/SkTypeface_cairo.h \
|
||||
$(NULL)
|
||||
|
||||
OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(CAIRO_FT_CFLAGS)
|
||||
else
|
||||
CPPSRCS += \
|
||||
SkDebug_stdio.cpp \
|
||||
SkThread_none.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += \
|
||||
SkFontHost_cairo.cpp \
|
||||
SkFontHost_FreeType.cpp \
|
||||
SkFontHost_FreeType_common.cpp \
|
||||
SkFontHost_linux.cpp \
|
||||
SkFontHost_tables.cpp \
|
||||
SkTime_Unix.cpp \
|
||||
SkMMapStream.cpp \
|
||||
SkOSFile.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_skia += \
|
||||
include/ports/SkTypeface_cairo.h \
|
||||
$(NULL)
|
||||
|
||||
OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(CAIRO_FT_CFLAGS)
|
||||
OS_CXXFLAGS += $(MOZ_PANGO_CFLAGS)
|
||||
endif
|
||||
|
||||
ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
|
||||
@ -364,9 +357,6 @@ endif
|
||||
|
||||
ifeq (Linux,$(OS_TARGET))
|
||||
DEFINES += -DSK_USE_POSIX_THREADS=1
|
||||
CPPSRCS += \
|
||||
SkThread_pthread.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
|
||||
@ -375,7 +365,6 @@ CPPSRCS += \
|
||||
SkFontHost_tables.cpp \
|
||||
SkFontHost_sandbox_none.cpp \
|
||||
SkTime_win.cpp \
|
||||
SkThread_win.cpp \
|
||||
$(NULL)
|
||||
DEFINES += -DSKIA_IMPLEMENTATION=1 -DGR_IMPLEMENTATION=1
|
||||
endif
|
||||
|
@ -1,11 +0,0 @@
|
||||
#ifndef SkTypeface_cairo_DEFINED
|
||||
#define SkTypeface_cairo_DEFINED
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "SkTypeface.h"
|
||||
|
||||
SK_API extern SkTypeface* SkCreateTypefaceFromCairoFont(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth);
|
||||
|
||||
#endif
|
||||
|
@ -1,382 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "cairo.h"
|
||||
#include "cairo-ft.h"
|
||||
|
||||
#include "SkFontHost_FreeType_common.h"
|
||||
|
||||
#include "SkAdvancedTypefaceMetrics.h"
|
||||
#include "SkFontHost.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkScalerContext.h"
|
||||
#include "SkTypefaceCache.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
static cairo_user_data_key_t kSkTypefaceKey;
|
||||
|
||||
class SkScalerContext_CairoFT : public SkScalerContext_FreeType_Base {
|
||||
public:
|
||||
SkScalerContext_CairoFT(const SkDescriptor* desc);
|
||||
virtual ~SkScalerContext_CairoFT();
|
||||
|
||||
protected:
|
||||
virtual unsigned generateGlyphCount() SK_OVERRIDE;
|
||||
virtual uint16_t generateCharToGlyph(SkUnichar uniChar) SK_OVERRIDE;
|
||||
virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
|
||||
virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
|
||||
virtual void generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend) SK_OVERRIDE;
|
||||
virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
|
||||
virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
|
||||
SkPaint::FontMetrics* my) SK_OVERRIDE;
|
||||
virtual SkUnichar generateGlyphToChar(uint16_t glyph) SK_OVERRIDE;
|
||||
private:
|
||||
cairo_scaled_font_t* fScaledFont;
|
||||
uint32_t fLoadGlyphFlags;
|
||||
};
|
||||
|
||||
class CairoLockedFTFace {
|
||||
public:
|
||||
CairoLockedFTFace(cairo_scaled_font_t* scaledFont)
|
||||
: fScaledFont(scaledFont)
|
||||
, fFace(cairo_ft_scaled_font_lock_face(scaledFont))
|
||||
{}
|
||||
|
||||
~CairoLockedFTFace()
|
||||
{
|
||||
cairo_ft_scaled_font_unlock_face(fScaledFont);
|
||||
}
|
||||
|
||||
FT_Face getFace()
|
||||
{
|
||||
return fFace;
|
||||
}
|
||||
|
||||
private:
|
||||
cairo_scaled_font_t* fScaledFont;
|
||||
FT_Face fFace;
|
||||
};
|
||||
|
||||
class SkCairoFTTypeface : public SkTypeface {
|
||||
public:
|
||||
static SkTypeface* CreateTypeface(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth) {
|
||||
SkASSERT(fontFace != NULL);
|
||||
SkASSERT(cairo_font_face_get_type(fontFace) == CAIRO_FONT_TYPE_FT);
|
||||
|
||||
SkFontID newId = SkTypefaceCache::NewFontID();
|
||||
|
||||
return SkNEW_ARGS(SkCairoFTTypeface, (fontFace, style, newId, isFixedWidth));
|
||||
}
|
||||
|
||||
cairo_font_face_t* getFontFace() {
|
||||
return fFontFace;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
SkCairoFTTypeface(cairo_font_face_t* fontFace, SkTypeface::Style style, SkFontID id, bool isFixedWidth)
|
||||
: SkTypeface(style, id, isFixedWidth)
|
||||
, fFontFace(fontFace)
|
||||
{
|
||||
cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, this, NULL);
|
||||
cairo_font_face_reference(fFontFace);
|
||||
}
|
||||
|
||||
~SkCairoFTTypeface()
|
||||
{
|
||||
cairo_font_face_set_user_data(fFontFace, &kSkTypefaceKey, NULL, NULL);
|
||||
cairo_font_face_destroy(fFontFace);
|
||||
}
|
||||
|
||||
cairo_font_face_t* fFontFace;
|
||||
};
|
||||
|
||||
SkTypeface* SkCreateTypefaceFromCairoFont(cairo_font_face_t* fontFace, SkTypeface::Style style, bool isFixedWidth)
|
||||
{
|
||||
SkTypeface* typeface = reinterpret_cast<SkTypeface*>(cairo_font_face_get_user_data(fontFace, &kSkTypefaceKey));
|
||||
|
||||
if (typeface) {
|
||||
typeface->ref();
|
||||
} else {
|
||||
typeface = SkCairoFTTypeface::CreateTypeface(fontFace, style, isFixedWidth);
|
||||
SkTypefaceCache::Add(typeface, style);
|
||||
}
|
||||
|
||||
return typeface;
|
||||
}
|
||||
|
||||
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
|
||||
const char famillyName[],
|
||||
SkTypeface::Style style)
|
||||
{
|
||||
SkDEBUGFAIL("SkFontHost::FindTypeface unimplemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream*)
|
||||
{
|
||||
SkDEBUGFAIL("SkFontHost::CreateTypeface unimplemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkTypeface* SkFontHost::CreateTypefaceFromFile(char const*)
|
||||
{
|
||||
SkDEBUGFAIL("SkFontHost::CreateTypefaceFromFile unimplemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
|
||||
uint32_t fontID,
|
||||
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
|
||||
const uint32_t* glyphIDs,
|
||||
uint32_t glyphIDsCount)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkFontHost::FilterRec(SkScalerContext::Rec* rec) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkStream* SkFontHost::OpenStream(uint32_t uniqueID)
|
||||
{
|
||||
SkDEBUGFAIL("SkFontHost::OpenStream unimplemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length,
|
||||
int32_t* index) {
|
||||
SkDebugf("SkFontHost::GetFileName unimplemented\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream)
|
||||
{
|
||||
SkDEBUGFAIL("SkFontHost::Serialize unimplemented");
|
||||
}
|
||||
|
||||
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
|
||||
SkDEBUGFAIL("SkFontHost::Deserialize unimplemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool isLCD(const SkScalerContext::Rec& rec) {
|
||||
switch (rec.fMaskFormat) {
|
||||
case SkMask::kLCD16_Format:
|
||||
case SkMask::kLCD32_Format:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
SkScalerContext_CairoFT::SkScalerContext_CairoFT(const SkDescriptor* desc)
|
||||
: SkScalerContext_FreeType_Base(desc)
|
||||
{
|
||||
SkCairoFTTypeface* typeface = static_cast<SkCairoFTTypeface*>(SkTypefaceCache::FindByID(fRec.fFontID));
|
||||
|
||||
SkMatrix matrix;
|
||||
fRec.getSingleMatrix(&matrix);
|
||||
|
||||
cairo_font_face_t* fontFace = typeface->getFontFace();
|
||||
|
||||
cairo_matrix_t fontMatrix, ctMatrix;
|
||||
cairo_matrix_init(&fontMatrix, matrix.getScaleX(), matrix.getSkewY(), matrix.getSkewX(), matrix.getScaleY(), 0.0, 0.0);
|
||||
cairo_matrix_init_scale(&ctMatrix, 1.0, 1.0);
|
||||
|
||||
// We need to ensure that the font options match for hinting, as generateMetrics()
|
||||
// uses the fScaledFont which uses these font options
|
||||
cairo_font_options_t *fontOptions = cairo_font_options_create();
|
||||
|
||||
FT_Int32 loadFlags = FT_LOAD_DEFAULT;
|
||||
|
||||
if (SkMask::kBW_Format == fRec.fMaskFormat) {
|
||||
// See http://code.google.com/p/chromium/issues/detail?id=43252#c24
|
||||
loadFlags = FT_LOAD_TARGET_MONO;
|
||||
if (fRec.getHinting() == SkPaint::kNo_Hinting) {
|
||||
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_NONE);
|
||||
loadFlags = FT_LOAD_NO_HINTING;
|
||||
}
|
||||
} else {
|
||||
switch (fRec.getHinting()) {
|
||||
case SkPaint::kNo_Hinting:
|
||||
loadFlags = FT_LOAD_NO_HINTING;
|
||||
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_NONE);
|
||||
break;
|
||||
case SkPaint::kSlight_Hinting:
|
||||
loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT
|
||||
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_SLIGHT);
|
||||
break;
|
||||
case SkPaint::kNormal_Hinting:
|
||||
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_MEDIUM);
|
||||
if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) {
|
||||
loadFlags = FT_LOAD_FORCE_AUTOHINT;
|
||||
}
|
||||
break;
|
||||
case SkPaint::kFull_Hinting:
|
||||
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_FULL);
|
||||
if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) {
|
||||
loadFlags = FT_LOAD_FORCE_AUTOHINT;
|
||||
}
|
||||
if (isLCD(fRec)) {
|
||||
if (SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag)) {
|
||||
loadFlags = FT_LOAD_TARGET_LCD_V;
|
||||
} else {
|
||||
loadFlags = FT_LOAD_TARGET_LCD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SkDebugf("---------- UNKNOWN hinting %d\n", fRec.getHinting());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fScaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctMatrix, fontOptions);
|
||||
|
||||
if ((fRec.fFlags & SkScalerContext::kEmbeddedBitmapText_Flag) == 0) {
|
||||
loadFlags |= FT_LOAD_NO_BITMAP;
|
||||
}
|
||||
|
||||
// Always using FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH to get correct
|
||||
// advances, as fontconfig and cairo do.
|
||||
// See http://code.google.com/p/skia/issues/detail?id=222.
|
||||
loadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
|
||||
|
||||
fLoadGlyphFlags = loadFlags;
|
||||
}
|
||||
|
||||
SkScalerContext_CairoFT::~SkScalerContext_CairoFT()
|
||||
{
|
||||
cairo_scaled_font_destroy(fScaledFont);
|
||||
}
|
||||
|
||||
SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc)
|
||||
{
|
||||
return SkNEW_ARGS(SkScalerContext_CairoFT, (desc));
|
||||
}
|
||||
|
||||
SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
uint32_t SkFontHost::GetUnitsPerEm(SkFontID fontID) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned SkScalerContext_CairoFT::generateGlyphCount()
|
||||
{
|
||||
CairoLockedFTFace faceLock(fScaledFont);
|
||||
return faceLock.getFace()->num_glyphs;
|
||||
}
|
||||
|
||||
uint16_t SkScalerContext_CairoFT::generateCharToGlyph(SkUnichar uniChar)
|
||||
{
|
||||
CairoLockedFTFace faceLock(fScaledFont);
|
||||
return SkToU16(FT_Get_Char_Index(faceLock.getFace(), uniChar));
|
||||
}
|
||||
|
||||
void SkScalerContext_CairoFT::generateAdvance(SkGlyph* glyph)
|
||||
{
|
||||
generateMetrics(glyph);
|
||||
}
|
||||
|
||||
void SkScalerContext_CairoFT::generateMetrics(SkGlyph* glyph)
|
||||
{
|
||||
SkASSERT(fScaledFont != NULL);
|
||||
cairo_text_extents_t extents;
|
||||
cairo_glyph_t cairoGlyph = { glyph->getGlyphID(fBaseGlyphCount), 0.0, 0.0 };
|
||||
cairo_scaled_font_glyph_extents(fScaledFont, &cairoGlyph, 1, &extents);
|
||||
|
||||
glyph->fAdvanceX = SkDoubleToFixed(extents.x_advance);
|
||||
glyph->fAdvanceY = SkDoubleToFixed(extents.y_advance);
|
||||
glyph->fWidth = SkToU16(SkScalarCeil(extents.width));
|
||||
glyph->fHeight = SkToU16(SkScalarCeil(extents.height));
|
||||
glyph->fLeft = SkToS16(SkScalarCeil(extents.x_bearing));
|
||||
glyph->fTop = SkToS16(SkScalarCeil(extents.y_bearing));
|
||||
glyph->fLsbDelta = 0;
|
||||
glyph->fRsbDelta = 0;
|
||||
}
|
||||
|
||||
void SkScalerContext_CairoFT::generateImage(const SkGlyph& glyph, SkMaskGamma::PreBlend* maskPreBlend)
|
||||
{
|
||||
SkASSERT(fScaledFont != NULL);
|
||||
CairoLockedFTFace faceLock(fScaledFont);
|
||||
FT_Face face = faceLock.getFace();
|
||||
|
||||
FT_Error err = FT_Load_Glyph(face, glyph.getGlyphID(fBaseGlyphCount), fLoadGlyphFlags);
|
||||
|
||||
if (err != 0) {
|
||||
memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight);
|
||||
return;
|
||||
}
|
||||
|
||||
generateGlyphImage(face, glyph, maskPreBlend);
|
||||
}
|
||||
|
||||
void SkScalerContext_CairoFT::generatePath(const SkGlyph& glyph, SkPath* path)
|
||||
{
|
||||
SkASSERT(fScaledFont != NULL);
|
||||
CairoLockedFTFace faceLock(fScaledFont);
|
||||
FT_Face face = faceLock.getFace();
|
||||
|
||||
SkASSERT(&glyph && path);
|
||||
|
||||
uint32_t flags = fLoadGlyphFlags;
|
||||
flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline
|
||||
flags &= ~FT_LOAD_RENDER; // don't scan convert (we just want the outline)
|
||||
|
||||
FT_Error err = FT_Load_Glyph(face, glyph.getGlyphID(fBaseGlyphCount), flags);
|
||||
|
||||
if (err != 0) {
|
||||
path->reset();
|
||||
return;
|
||||
}
|
||||
|
||||
generateGlyphPath(face, glyph, path);
|
||||
}
|
||||
|
||||
void SkScalerContext_CairoFT::generateFontMetrics(SkPaint::FontMetrics* mx,
|
||||
SkPaint::FontMetrics* my)
|
||||
{
|
||||
}
|
||||
|
||||
SkUnichar SkScalerContext_CairoFT::generateGlyphToChar(uint16_t glyph)
|
||||
{
|
||||
SkASSERT(fScaledFont != NULL);
|
||||
CairoLockedFTFace faceLock(fScaledFont);
|
||||
FT_Face face = faceLock.getFace();
|
||||
|
||||
FT_UInt glyphIndex;
|
||||
SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex);
|
||||
while (glyphIndex != 0) {
|
||||
if (glyphIndex == glyph) {
|
||||
return charCode;
|
||||
}
|
||||
charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID,
|
||||
SkFontID origFontID) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
@ -322,13 +322,16 @@ TemporaryRef<ScaledFont>
|
||||
gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
|
||||
if (aTarget->GetType() == BACKEND_CAIRO) {
|
||||
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
nativeFont.mFont = NULL;
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_FT2, "Expecting Freetype font");
|
||||
nativeFont.mType = NATIVE_FONT_SKIA_FONT_FACE;
|
||||
nativeFont.mFont = static_cast<gfxFT2FontBase*>(aFont)->GetFontOptions();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "prinit.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
||||
// rounding and truncation functions for a Freetype floating point number
|
||||
// (FT26Dot6) stored in a 32bit integer with high 26 bits for the integer
|
||||
@ -660,21 +659,3 @@ gfxFT2Font::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA
|
||||
mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions>
|
||||
gfxFT2Font::GetGlyphRenderingOptions()
|
||||
{
|
||||
mozilla::gfx::FontHinting hinting;
|
||||
|
||||
if (gfxPlatform::GetPlatform()->FontHintingEnabled()) {
|
||||
hinting = mozilla::gfx::FONT_HINTING_NORMAL;
|
||||
} else {
|
||||
hinting = mozilla::gfx::FONT_HINTING_NONE;
|
||||
}
|
||||
|
||||
// We don't want to force the use of the autohinter over the font's built in hints
|
||||
return mozilla::gfx::Factory::CreateCairoGlyphRenderingOptions(hinting, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -68,10 +68,6 @@ public: // new functions
|
||||
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
#ifdef USE_SKIA
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool ShapeText(gfxContext *aContext,
|
||||
const PRUnichar *aText,
|
||||
|
@ -777,10 +777,6 @@ public:
|
||||
return mPangoFont;
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool ShapeText(gfxContext *aContext,
|
||||
const PRUnichar *aText,
|
||||
@ -3235,36 +3231,3 @@ ApplyGdkScreenFontOptions(FcPattern *aPattern)
|
||||
}
|
||||
|
||||
#endif // MOZ_WIDGET_GTK2
|
||||
|
||||
#ifdef USE_SKIA
|
||||
mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions>
|
||||
gfxFcFont::GetGlyphRenderingOptions()
|
||||
{
|
||||
cairo_scaled_font_t *scaled_font = CairoScaledFont();
|
||||
cairo_font_options_t *options = cairo_font_options_create();
|
||||
cairo_scaled_font_get_font_options(scaled_font, options);
|
||||
cairo_hint_style_t hint_style = cairo_font_options_get_hint_style(options);
|
||||
cairo_font_options_destroy(options);
|
||||
|
||||
mozilla::gfx::FontHinting hinting;
|
||||
|
||||
switch (hint_style) {
|
||||
case CAIRO_HINT_STYLE_NONE:
|
||||
hinting = mozilla::gfx::FONT_HINTING_NONE;
|
||||
break;
|
||||
case CAIRO_HINT_STYLE_SLIGHT:
|
||||
hinting = mozilla::gfx::FONT_HINTING_LIGHT;
|
||||
break;
|
||||
case CAIRO_HINT_STYLE_FULL:
|
||||
hinting = mozilla::gfx::FONT_HINTING_FULL;
|
||||
break;
|
||||
default:
|
||||
hinting = mozilla::gfx::FONT_HINTING_NORMAL;
|
||||
break;
|
||||
}
|
||||
|
||||
// We don't want to force the use of the autohinter over the font's built in hints
|
||||
return mozilla::gfx::Factory::CreateCairoGlyphRenderingOptions(hinting, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -758,13 +758,13 @@ TemporaryRef<ScaledFont>
|
||||
gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
|
||||
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
|
||||
if (aTarget->GetType() == BACKEND_CAIRO) {
|
||||
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
nativeFont.mFont = NULL;
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont());
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_FT2, "Expecting Freetype font");
|
||||
nativeFont.mType = NATIVE_FONT_SKIA_FONT_FACE;
|
||||
nativeFont.mFont = static_cast<gfxFT2FontBase*>(aFont)->GetFontOptions();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user