Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <utility>
|
|
#include <cstdint>
|
|
#include <unordered_set>
|
|
#include <mln/util/hash.hpp>
|
|
#include <mln/util/font_stack.hpp>
|
|
|
|
namespace mln {
|
|
|
|
enum GlyphIDType : uint16_t {
|
|
FontPBF = 0x00,
|
|
};
|
|
|
|
GlyphIDType genNewGlyphIDType(const std::string &url,
|
|
const FontStack &fontStack,
|
|
const std::vector<std::pair<uint32_t, uint32_t>> &pairs);
|
|
|
|
class GlyphRange {
|
|
public:
|
|
uint16_t first = 0;
|
|
uint16_t second = 0;
|
|
|
|
GlyphIDType type = GlyphIDType::FontPBF;
|
|
|
|
GlyphRange(uint32_t first_, uint32_t second_, GlyphIDType type_ = FontPBF);
|
|
|
|
bool operator==(const GlyphRange &other) const;
|
|
bool operator<(const GlyphRange &other) const;
|
|
};
|
|
|
|
constexpr uint32_t GLYPHS_PER_GLYPH_RANGE = 256;
|
|
constexpr uint32_t GLYPH_RANGES_PER_FONT_STACK = 256;
|
|
// Verified against i18n::glyphRangeIsEntirelyLocallyGenerated by
|
|
// i18n.GlyphRangeLocalGenerationCountMatchesConstant.
|
|
constexpr uint32_t NON_IDEOGRAPH_GLYPH_RANGES_PER_FONT_STACK = 97;
|
|
|
|
} // end namespace mln
|
|
|
|
namespace std {
|
|
|
|
template <>
|
|
struct hash<mln::GlyphRange> {
|
|
std::size_t operator()(const mln::GlyphRange &range) const { return mln::util::hash(range.first, range.second); }
|
|
};
|
|
|
|
} // namespace std
|