Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/thebes/gfxFT2FontBase.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
5
6
#ifndef GFX_FT2FONTBASE_H
7
#define GFX_FT2FONTBASE_H
8
9
#include "cairo.h"
10
#include "gfxContext.h"
11
#include "gfxFont.h"
12
#include "mozilla/gfx/2D.h"
13
#include "mozilla/gfx/UnscaledFontFreeType.h"
14
#include "nsDataHashtable.h"
15
#include "nsHashKeys.h"
16
17
class gfxFT2FontBase : public gfxFont {
18
public:
19
    gfxFT2FontBase(const RefPtr<mozilla::gfx::UnscaledFontFreeType>& aUnscaledFont,
20
                   cairo_scaled_font_t *aScaledFont,
21
                   gfxFontEntry *aFontEntry,
22
                   const gfxFontStyle *aFontStyle);
23
    virtual ~gfxFT2FontBase();
24
25
    uint32_t GetGlyph(uint32_t aCharCode);
26
    void GetGlyphExtents(uint32_t aGlyph,
27
                         cairo_text_extents_t* aExtents);
28
    virtual uint32_t GetSpaceGlyph() override;
29
0
    virtual bool ProvidesGetGlyph() const override { return true; }
30
    virtual uint32_t GetGlyph(uint32_t unicode,
31
                              uint32_t variation_selector) override;
32
0
    virtual bool ProvidesGlyphWidths() const override { return true; }
33
    virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget,
34
                                  uint16_t aGID) override;
35
36
    virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
37
38
0
    virtual FontType GetType() const override { return FONT_TYPE_FT2; }
39
40
    static void SetupVarCoords(FT_MM_Var* aMMVar,
41
                               const nsTArray<gfxFontVariation>& aVariations,
42
                               nsTArray<FT_Fixed>* aCoords);
43
44
private:
45
    uint32_t GetCharExtents(char aChar, cairo_text_extents_t* aExtents);
46
    uint32_t GetCharWidth(char aChar, gfxFloat* aWidth);
47
48
    // Get advance of a single glyph from FreeType, and return true;
49
    // or return false if we should fall back to getting the glyph
50
    // extents from cairo instead.
51
    bool GetFTGlyphAdvance(uint16_t aGID, int32_t* aWidth);
52
53
    void InitMetrics();
54
55
protected:
56
    virtual const Metrics& GetHorizontalMetrics() override;
57
58
    uint32_t mSpaceGlyph;
59
    Metrics mMetrics;
60
    bool    mEmbolden;
61
62
    // For variation/multiple-master fonts, this will be an array of the values
63
    // for each axis, as specified by mStyle.variationSettings (or the font's
64
    // default for axes not present in variationSettings). Values here are in
65
    // freetype's 16.16 fixed-point format, and clamped to the valid min/max
66
    // range reported by the face.
67
    nsTArray<FT_Fixed> mCoords;
68
69
    mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,int32_t>> mGlyphWidths;
70
};
71
72
#endif /* GFX_FT2FONTBASE_H */