summaryrefslogtreecommitdiff
path: root/src/mbgl/text/glyph_set.hpp
blob: 5df639396a28e609ea7c65093dec1e2bc6ccda2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include <mbgl/text/bidi.hpp>
#include <mbgl/text/glyph.hpp>
#include <mbgl/util/geometry.hpp>

struct hb_font_t;

namespace mbgl {

class GlyphSet {
public:
    void insert(uint32_t id, SDFGlyph&&);
    const std::map<uint32_t, SDFGlyph>& getSDFs() const;
    const Shaping getShaping(const std::u16string& string,
                             float maxWidth,
                             float lineHeight,
                             float horizontalAlign,
                             float verticalAlign,
                             float justify,
                             float spacing,
                             const Point<float>& translate,
                             BiDi& bidi,
                             hb_font_t* localFont) const;

private:
    std::vector<std::pair<char16_t,double>> getClusterWidths(const std::u16string& logicalInput, const float spacing) const;
    
    float determineAverageLineWidth(const std::vector<std::pair<char16_t,double>>& clusters, float maxWidth) const;
    std::set<std::size_t> determineLineBreaks(const std::vector<std::pair<char16_t,double>>& clusters, float maxWidth) const;

    void shapeLines(Shaping& shaping,
                    const std::vector<std::u16string>& lines,
                    const float spacing,
                    float lineHeight,
                    float horizontalAlign,
                    float verticalAlign,
                    float justify,
                    const Point<float>& translate,
                    hb_font_t* localFont) const;

    std::map<uint32_t, SDFGlyph> sdfs;
};

} // end namespace mbgl