SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1#pragma once
2
7
8#include "image.h"
9#include "image/font/imstb_truetype.h"
10#include <string>
11
12namespace satdump
13{
14 namespace image
15 {
23 {
24 protected:
25 struct char_el
26 {
27 int char_nb;
28 int glyph_nb;
29 unsigned char *bitmap;
30 int cx0, cx1, cy0, cy1, advance, lsb, w, h, ix0, ix1, iy0, iy1, size;
31 };
32
33 struct font_info
34 {
35 struct stbtt_fontinfo fontp;
36 std::string path;
37 int x0, x1, y0, y1, asc, dsc, lg, wdh, hht;
38 std::vector<char_el> chars;
39 };
40
41 protected:
42 // font rendering stuff
43 font_info font;
44 bool has_font = false;
45 uint8_t *ttf_buffer;
46
47 public:
49
54 void init_font(std::string font_path);
55
59 void init_font();
60
65 bool font_ready() { return has_font; }
66
77 int draw_text(Image &img, int xs0, int ys0, std::vector<double> color, int size, std::string text);
78 };
79 } // namespace image
80} // namespace satdump
Definition image.h:17
Text image drawer, used to draw arbitrary text onto an image. This needs to be its own class as the f...
Definition text.h:23
void init_font()
Init with the default font.
Definition text.cpp:61
int draw_text(Image &img, int xs0, int ys0, std::vector< double > color, int size, std::string text)
Draw text onto an image.
Definition text.cpp:63
bool font_ready()
Is the font ready?
Definition text.h:65
Core Image class.