зеркало из https://github.com/mozilla/gecko-dev.git
[PATCH 2/2] Bug 736276 - Rename ScaledFontFreeType to ScaledFontCairo, and use Skia's API to create an SkTypeface from a cairo_scaled_font_t r=jrmuizel
This commit is contained in:
Родитель
d8a5053d03
Коммит
fd8ac1eae7
|
@ -924,6 +924,11 @@ 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,6 +6,7 @@
|
|||
#include "DrawTargetSkia.h"
|
||||
#include "SourceSurfaceSkia.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#include "ScaledFontCairo.h"
|
||||
#include "skia/SkDevice.h"
|
||||
|
||||
#ifdef USE_SKIA_GPU
|
||||
|
@ -445,7 +446,7 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
|
|||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions*)
|
||||
const GlyphRenderingOptions *aRenderingOptions)
|
||||
{
|
||||
if (aFont->GetType() != FONT_MAC &&
|
||||
aFont->GetType() != FONT_SKIA &&
|
||||
|
@ -461,7 +462,30 @@ 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,14 +7,15 @@
|
|||
|
||||
#ifdef USE_CAIRO
|
||||
#include "DrawTargetCairo.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#include "ScaledFontCairo.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_SKIA
|
||||
#include "DrawTargetSkia.h"
|
||||
#include "ScaledFontBase.h"
|
||||
#ifdef MOZ_ENABLE_FREETYPE
|
||||
#include "ScaledFontFreetype.h"
|
||||
#define USE_SKIA_FREETYPE
|
||||
#include "ScaledFontCairo.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -297,20 +298,10 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
|
|||
return new ScaledFontMac(static_cast<CGFontRef>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
#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
|
||||
#if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE)
|
||||
case NATIVE_FONT_CAIRO_FONT_FACE:
|
||||
{
|
||||
ScaledFontBase* fontBase = new ScaledFontBase(aSize);
|
||||
fontBase->SetCairoScaledFont(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont));
|
||||
return fontBase;
|
||||
return new ScaledFontCairo(static_cast<cairo_scaled_font_t*>(aNativeFont.mFont), aSize);
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
|
@ -459,6 +450,19 @@ 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,6 +28,7 @@ CPPSRCS = \
|
|||
Blur.cpp \
|
||||
Scale.cpp \
|
||||
ScaledFontBase.cpp \
|
||||
ScaledFontCairo.cpp \
|
||||
DrawTargetDual.cpp \
|
||||
ImageScaling.cpp \
|
||||
SourceSurfaceRawData.cpp \
|
||||
|
@ -73,10 +74,8 @@ 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
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_scaled_font_destroy(mScaledFont);
|
||||
#endif
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ ScaledFontBase::ScaledFontBase(Float aSize)
|
|||
#ifdef USE_SKIA
|
||||
mTypeface = nullptr;
|
||||
#endif
|
||||
#ifdef USE_CAIRO
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
mScaledFont = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBu
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
void
|
||||
ScaledFontBase::SetCairoScaledFont(cairo_scaled_font_t* font)
|
||||
{
|
||||
|
|
|
@ -8,10 +8,15 @@
|
|||
|
||||
#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
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
#include "cairo.h"
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +44,7 @@ public:
|
|||
// Not true, but required to instantiate a ScaledFontBase.
|
||||
virtual FontType GetType() const { return FONT_SKIA; }
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
|
||||
void SetCairoScaledFont(cairo_scaled_font_t* font);
|
||||
#endif
|
||||
|
@ -49,7 +54,7 @@ protected:
|
|||
#ifdef USE_SKIA
|
||||
SkTypeface* mTypeface;
|
||||
#endif
|
||||
#ifdef USE_CAIRO
|
||||
#ifdef USE_CAIRO_SCALED_FONT
|
||||
cairo_scaled_font_t* mScaledFont;
|
||||
#endif
|
||||
Float mSize;
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- 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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- 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_ */
|
|
@ -1,53 +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 "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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,24 +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_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,6 +88,14 @@ 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 };
|
||||
|
|
|
@ -322,16 +322,13 @@ TemporaryRef<ScaledFont>
|
|||
gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
{
|
||||
NativeFont nativeFont;
|
||||
if (aTarget->GetType() == BACKEND_CAIRO) {
|
||||
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
|
||||
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = NULL;
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont());
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#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
|
||||
|
@ -659,3 +660,21 @@ 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,6 +68,10 @@ 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,6 +777,10 @@ public:
|
|||
return mPangoFont;
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool ShapeText(gfxContext *aContext,
|
||||
const PRUnichar *aText,
|
||||
|
@ -3231,3 +3235,36 @@ 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) {
|
||||
|
||||
if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
|
||||
nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
|
||||
nativeFont.mFont = NULL;
|
||||
return Factory::CreateScaledFontWithCairo(nativeFont, aFont->GetAdjustedSize(), aFont->GetCairoScaledFont());
|
||||
nativeFont.mFont = aFont->GetCairoScaledFont();
|
||||
return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
|
||||
}
|
||||
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());
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче