Got it almost working...

This commit is contained in:
2023-12-03 22:08:59 +01:00
parent 1163ae5745
commit 5a38600e2a
14 changed files with 128 additions and 74 deletions

View File

@@ -23,6 +23,11 @@
#include <cstdint>
#include <string>
#include <vector>
#include "cairo.h"
#include "pango/pango-font.h"
#include "pango/pango-types.h"
namespace ptprnt::graphics {
@@ -39,15 +44,21 @@ class Label {
Label(Label&&) = delete;
Label& operator=(Label&&) = delete;
uint8_t* getRaw();
void createLabel(const std::string& labelText);
std::vector<uint8_t> getRaw();
void create(const std::string& labelText, const uint16_t heightPixel);
void writeToPng(const std::string& file);
int getLayoutWidth();
int getLayoutHeight();
private:
// methods
uint8_t getNumLines(std::string_view str);
// members
PangoLayout* mLayout;
PangoFontDescription* mFontDescription;
cairo_surface_t* mSurface;
PangoContext* mPangoCtx{nullptr};
PangoLayout* mPangoLyt{nullptr};
PangoFontDescription* mPangoFontDesc{nullptr};
cairo_surface_t* mSurface{nullptr};
int mLayoutWidth = 0, mLayoutHeight = 0;
int mPrinterHeight = 0;
};
} // namespace ptprnt::graphics