Bug 1728955: part 6) Log result of Windows' `OleSetClipboardResult`. r=masayuki
[gecko.git] / gfx / thebes / gfxMacFont.h
blob3d7157b957897b1712516e98928952dc4650fbf6
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 GFX_MACFONT_H
7 #define GFX_MACFONT_H
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxFont.h"
11 #include <ApplicationServices/ApplicationServices.h>
13 #include "mozilla/gfx/UnscaledFontMac.h"
15 class MacOSFontEntry;
17 class gfxMacFont : public gfxFont {
18 public:
19 gfxMacFont(const RefPtr<mozilla::gfx::UnscaledFontMac>& aUnscaledFont, MacOSFontEntry* aFontEntry,
20 const gfxFontStyle* aFontStyle);
22 virtual ~gfxMacFont();
24 CGFontRef GetCGFontRef() const { return mCGFont; }
26 /* override Measure to add padding for antialiasing */
27 RunMetrics Measure(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
28 BoundingBoxType aBoundingBoxType, DrawTarget* aDrawTargetForTightBoundingBox,
29 Spacing* aSpacing, mozilla::gfx::ShapedTextFlags aOrientation) override;
31 // We need to provide hinted (non-linear) glyph widths if using a font
32 // with embedded color bitmaps (Apple Color Emoji), as Core Text renders
33 // the glyphs with non-linear scaling at small pixel sizes.
34 bool ProvidesGlyphWidths() const override {
35 return mVariationFont || mFontEntry->HasFontTable(TRUETYPE_TAG('s', 'b', 'i', 'x'));
38 int32_t GetGlyphWidth(uint16_t aGID) override;
40 bool GetGlyphBounds(uint16_t aGID, gfxRect* aBounds, bool aTight) override;
42 already_AddRefed<mozilla::gfx::ScaledFont> GetScaledFont(
43 mozilla::gfx::DrawTarget* aTarget) override;
45 bool ShouldRoundXOffset(cairo_t* aCairo) const override;
47 void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
48 FontCacheSizes* aSizes) const override;
49 void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
50 FontCacheSizes* aSizes) const override;
52 FontType GetType() const override { return FONT_TYPE_MAC; }
54 // Helper to create a CTFont from a CGFont, with optional font descriptor
55 // (for features), and copying any variations that were set on the CGFont.
56 // This is public so that gfxCoreTextShaper can also use it.
57 static CTFontRef CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize,
58 bool aInstalledFont,
59 CTFontDescriptorRef aFontDesc = nullptr);
61 protected:
62 const Metrics& GetHorizontalMetrics() override { return mMetrics; }
64 // override to prefer CoreText shaping with fonts that depend on AAT
65 bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText, uint32_t aOffset, uint32_t aLength,
66 Script aScript, nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
67 gfxShapedText* aShapedText) override;
69 void InitMetrics();
70 void InitMetricsFromPlatform();
72 // Get width and glyph ID for a character; uses aConvFactor
73 // to convert font units as returned by CG to actual dimensions
74 gfxFloat GetCharWidth(CFDataRef aCmap, char16_t aUniChar, uint32_t* aGlyphID,
75 gfxFloat aConvFactor);
77 // a strong reference to the CoreGraphics font
78 CGFontRef mCGFont;
80 // a Core Text font reference, created only if we're using CT to measure
81 // glyph widths; otherwise null.
82 CTFontRef mCTFont;
84 mozilla::UniquePtr<gfxFontShaper> mCoreTextShaper;
86 Metrics mMetrics;
87 nscolor mFontSmoothingBackgroundColor;
89 bool mVariationFont; // true if font has OpenType variations
92 #endif /* GFX_MACFONT_H */