1 #pragma once
2 
3 #include <mbgl/text/glyph.hpp>
4 
5 namespace mbgl {
6 
7 /*
8     Given a font stack and a glyph ID, platform-specific implementations of
9     LocalGlyphRasterizer will decide which, if any, local fonts to use and
10     then generate a matching glyph object with a greyscale rasterization of
11     the glyph and appropriate metrics. GlyphManager will then use TinySDF to
12     transform the rasterized bitmap into an SDF.
13 
14     The JS equivalent of this functionality will only generate glyphs in the
15     'CJK Unified Ideographs' and 'Hangul Syllables' ranges, for which it can
16     get away with rendering a fixed 30px square image and GlyphMetrics of:
17 
18         width: 24,
19         height: 24,
20         left: 0,
21         top: -8,
22         advance: 24
23 
24     The JS equivalent also uses heuristic evaluation of the font stack name
25     to control the font-weight it uses during rasterization.
26 
27     It is left to platform-specific implementation to decide how best to
28     map a FontStack to a particular rasterization.
29 
30     The default implementation simply refuses to rasterize any glyphs.
31 */
32 
33 class LocalGlyphRasterizer {
34 public:
35     virtual ~LocalGlyphRasterizer();
36     LocalGlyphRasterizer(const optional<std::string> fontFamily = optional<std::string>());
37 
38     // virtual so that test harness can override platform-specific behavior
39     virtual bool canRasterizeGlyph(const FontStack&, GlyphID);
40     virtual Glyph rasterizeGlyph(const FontStack&, GlyphID);
41 private:
42     class Impl;
43     std::unique_ptr<Impl> impl;
44 };
45 
46 } // namespace mbgl
47