1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_
7 #define MOZILLA_GFX_SCALEDFONTBASE_H_
11 // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
12 #if defined(USE_SKIA) || defined(USE_CAIRO)
13 #define USE_CAIRO_SCALED_FONT
17 #include "skia/SkPath.h"
18 #include "skia/SkTypeface.h"
20 #ifdef USE_CAIRO_SCALED_FONT
29 class ScaledFontBase
: public ScaledFont
32 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase
)
33 explicit ScaledFontBase(Float aSize
);
34 virtual ~ScaledFontBase();
36 virtual TemporaryRef
<Path
> GetPathForGlyphs(const GlyphBuffer
&aBuffer
, const DrawTarget
*aTarget
);
38 virtual void CopyGlyphsToBuilder(const GlyphBuffer
&aBuffer
, PathBuilder
*aBuilder
, BackendType aBackendType
, const Matrix
*aTransformHint
);
40 float GetSize() { return mSize
; }
43 virtual SkTypeface
* GetSkTypeface() { return mTypeface
; }
46 // Not true, but required to instantiate a ScaledFontBase.
47 virtual FontType
GetType() const { return FontType::SKIA
; }
49 #ifdef USE_CAIRO_SCALED_FONT
50 cairo_scaled_font_t
* GetCairoScaledFont() { return mScaledFont
; }
51 void SetCairoScaledFont(cairo_scaled_font_t
* font
);
55 friend class DrawTargetSkia
;
57 SkTypeface
* mTypeface
;
58 SkPath
GetSkiaPathForGlyphs(const GlyphBuffer
&aBuffer
);
60 #ifdef USE_CAIRO_SCALED_FONT
61 cairo_scaled_font_t
* mScaledFont
;
69 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */