small DisplayBuffer images and font update (#4044)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
NP v/d Spek
2023-01-11 02:55:02 +01:00
committed by GitHub
parent 1cf3424ebe
commit 86a8e1f4a6
4 changed files with 14 additions and 8 deletions
@@ -452,7 +452,7 @@ int Font::match_next_glyph(const char *str, int *match_length) {
}
void Font::measure(const char *str, int *width, int *x_offset, int *baseline, int *height) {
*baseline = this->baseline_;
*height = this->bottom_;
*height = this->height_;
int i = 0;
int min_x = 0;
bool has_char = false;
@@ -483,7 +483,7 @@ void Font::measure(const char *str, int *width, int *x_offset, int *baseline, in
*width = x - min_x;
}
const std::vector<Glyph> &Font::get_glyphs() const { return this->glyphs_; }
Font::Font(const GlyphData *data, int data_nr, int baseline, int bottom) : baseline_(baseline), bottom_(bottom) {
Font::Font(const GlyphData *data, int data_nr, int baseline, int height) : baseline_(baseline), height_(height) {
for (int i = 0; i < data_nr; ++i)
glyphs_.emplace_back(data + i);
}
@@ -527,6 +527,7 @@ int Image::get_height() const { return this->height_; }
ImageType Image::get_type() const { return this->type_; }
Image::Image(const uint8_t *data_start, int width, int height, ImageType type)
: width_(width), height_(height), type_(type), data_start_(data_start) {}
int Image::get_current_frame() const { return 0; }
bool Animation::get_pixel(int x, int y) const {
if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_)
+7 -3
View File
@@ -448,18 +448,20 @@ class Font {
* @param baseline The y-offset from the top of the text to the baseline.
* @param bottom The y-offset from the top of the text to the bottom (i.e. height).
*/
Font(const GlyphData *data, int data_nr, int baseline, int bottom);
Font(const GlyphData *data, int data_nr, int baseline, int height);
int match_next_glyph(const char *str, int *match_length);
void measure(const char *str, int *width, int *x_offset, int *baseline, int *height);
inline int get_baseline() { return this->baseline_; }
inline int get_height() { return this->height_; }
const std::vector<Glyph> &get_glyphs() const;
protected:
std::vector<Glyph> glyphs_;
int baseline_;
int bottom_;
int height_;
};
class Image {
@@ -473,6 +475,8 @@ class Image {
int get_height() const;
ImageType get_type() const;
virtual int get_current_frame() const;
protected:
int width_;
int height_;
@@ -489,7 +493,7 @@ class Animation : public Image {
Color get_grayscale_pixel(int x, int y) const override;
int get_animation_frame_count() const;
int get_current_frame() const;
int get_current_frame() const override;
void next_frame();
void prev_frame();