summaryrefslogtreecommitdiff
path: root/include/mbgl/text/glyph.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-07-16 18:53:56 -0700
committerKonstantin Käfer <mail@kkaefer.com>2014-07-16 18:53:56 -0700
commit4ea281c750c5afcc68f2832bb42d98a1cbce6735 (patch)
tree60bc7d3ccba2c54859e2e023997cc027cc67aea7 /include/mbgl/text/glyph.hpp
parentc1a64dc5fa73b54cc5de77629781dfc74302a1e7 (diff)
downloadqtlocation-mapboxgl-4ea281c750c5afcc68f2832bb42d98a1cbce6735.tar.gz
rename llmr => mbgl
Diffstat (limited to 'include/mbgl/text/glyph.hpp')
-rw-r--r--include/mbgl/text/glyph.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp
new file mode 100644
index 0000000000..899c8fffee
--- /dev/null
+++ b/include/mbgl/text/glyph.hpp
@@ -0,0 +1,61 @@
+#ifndef MBGL_TEXT_GLYPH
+#define MBGL_TEXT_GLYPH
+
+#include <mbgl/util/rect.hpp>
+
+#include <cstdint>
+#include <vector>
+#include <map>
+
+namespace mbgl {
+
+typedef std::pair<uint16_t, uint16_t> GlyphRange;
+
+// Note: this only works for the BMP
+GlyphRange getGlyphRange(char32_t glyph);
+
+struct GlyphMetrics {
+ operator bool() const {
+ return width == 0 && height == 0 && advance == 0;
+ }
+
+ // Glyph metrics.
+ uint32_t width = 0;
+ uint32_t height = 0;
+ int32_t left = 0;
+ int32_t top = 0;
+ uint32_t advance = 0;
+
+};
+
+struct Glyph {
+ inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {}
+ inline explicit Glyph(const Rect<uint16_t> &rect,
+ const GlyphMetrics &metrics)
+ : rect(rect), metrics(metrics) {}
+
+ operator bool() const {
+ return !metrics && !rect;
+ }
+
+ const Rect<uint16_t> rect;
+ const GlyphMetrics metrics;
+};
+
+typedef std::map<uint32_t, Glyph> GlyphPositions;
+
+class GlyphPlacement {
+public:
+ inline explicit GlyphPlacement(uint32_t face, uint32_t glyph, uint32_t x, uint32_t y)
+ : face(face), glyph(glyph), x(x), y(y) {}
+
+ uint32_t face = 0;
+ uint32_t glyph = 0;
+ int32_t x = 0;
+ int32_t y = 0;
+};
+
+typedef std::vector<GlyphPlacement> Shaping;
+}
+
+#endif