Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
typeface_stb.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
6#define FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/fml/mapping.h"
10#include "flutter/third_party/stb/stb_truetype.h"
13
14namespace impeller {
15
16class TypefaceSTB final : public Typeface,
17 public BackendCast<TypefaceSTB, Typeface> {
18 public:
19 // "Typical" conversion from font Points to Pixels.
20 // This assumes a constant pixels per em.
21 static constexpr float kPointsToPixels = 96.0 / 72.0;
22
23 explicit TypefaceSTB(std::unique_ptr<fml::Mapping> typeface_mapping);
24
25 ~TypefaceSTB() override;
26
27 // |Typeface|
28 bool IsValid() const override;
29
30 // |Comparable<Typeface>|
31 std::size_t GetHash() const override;
32
33 // |Comparable<Typeface>|
34 bool IsEqual(const Typeface& other) const override;
35
36 const uint8_t* GetTypefaceFile() const;
37 const stbtt_fontinfo* GetFontInfo() const;
38
39 private:
40 std::unique_ptr<fml::Mapping> typeface_mapping_;
41 std::unique_ptr<stbtt_fontinfo> font_info_;
42 bool is_valid_ = false;
43
44 TypefaceSTB(const TypefaceSTB&) = delete;
45
46 TypefaceSTB& operator=(const TypefaceSTB&) = delete;
47};
48
49} // namespace impeller
50
51#endif // FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
bool IsValid() const override
const stbtt_fontinfo * GetFontInfo() const
std::size_t GetHash() const override
static constexpr float kPointsToPixels
bool IsEqual(const Typeface &other) const override
const uint8_t * GetTypefaceFile() const
A typeface, usually obtained from a font-file, on disk describes the intrinsic properties of the font...
Definition typeface.h:20