lsnes rr2-β23
[lsnes.git] / include / library / framebuffer-font2.hpp
blob0f55943aa87986a549c4b4a57e874db4cdcc38b9
1 #ifndef _library__framebuffer_font2__hpp__included__
2 #define _library__framebuffer_font2__hpp__included__
4 #include <vector>
5 #include <cstdint>
6 #include <functional>
7 #include <cstdlib>
8 #include <iostream>
9 #include <stdexcept>
10 #include <map>
11 #include "framebuffer.hpp"
13 namespace framebuffer
15 struct font2
17 public:
18 struct glyph
20 glyph();
21 glyph(std::istream& s);
22 unsigned width;
23 unsigned height;
24 unsigned stride;
25 std::vector<uint32_t> fglyph; //Bitpacked, element breaks between rows.
26 void render(fb<false>& fb, int32_t x, int32_t y, color fg, color bg, color hl) const;
27 void render(fb<true>& fb, int32_t x, int32_t y, color fg, color bg, color hl) const;
28 void render(uint8_t* buf, size_t stride, uint32_t u, uint32_t v, uint32_t w, uint32_t h) const;
30 font2();
31 font2(const std::string& file);
32 font2(struct font& bfont);
33 void add(const std::u32string& key, const glyph& fglyph) throw(std::bad_alloc);
34 std::u32string best_ligature_match(const std::u32string& codepoints, size_t start) const
35 throw(std::bad_alloc);
36 const glyph& lookup_glyph(const std::u32string& key) const throw();
37 unsigned get_rowadvance() const throw() { return rowadvance; }
38 std::pair<uint32_t, uint32_t> get_metrics(const std::u32string& str, uint32_t xalign) const;
39 void for_each_glyph(const std::u32string& str, uint32_t xalign, std::function<void(uint32_t x, uint32_t y,
40 const glyph& g)> cb) const;
41 private:
42 std::map<std::u32string, glyph> glyphs;
43 unsigned rowadvance;
46 #endif