diff --git a/src/graphics/Label.cpp b/src/graphics/Label.cpp index 1908ff0..3f68d58 100644 --- a/src/graphics/Label.cpp +++ b/src/graphics/Label.cpp @@ -36,7 +36,6 @@ #include "pango/pango-font.h" #include "pango/pango-layout.h" #include "pango/pango-types.h" -#include "pango/pangocairo.h" namespace ptprnt::graphics { @@ -61,16 +60,12 @@ Label::Label(const uint16_t heightPixel) : Label(heightPixel, std::make_shared cairoWrapper) - : mCairoWrapper(std::move(cairoWrapper)), - mPrinterHeight(heightPixel) { + : mCairoWrapper(std::move(cairoWrapper)), mPrinterHeight(heightPixel) { // Initialize resources in correct order with RAII // Pass wrapper to deleter so cleanup uses the wrapper GObjectDeleter deleter; deleter.wrapper = mCairoWrapper; - mFontMap = std::unique_ptr( - mCairoWrapper->pango_cairo_font_map_new(), - deleter - ); + mFontMap = std::unique_ptr(mCairoWrapper->pango_cairo_font_map_new(), deleter); } std::vector Label::getRaw() const { @@ -183,8 +178,6 @@ bool Label::create(const std::string& labelText) { mLayoutHeight /= PANGO_SCALE; spdlog::debug("Layout width: {}, height: {}", mLayoutWidth, mLayoutHeight); - //auto alignedWidth = mLayoutWidth + (8 - (mLayoutWidth % 8)); - //spdlog::debug("Aligned Layout width: {}, height: {}", alignedWidth, mLayoutHeight); // Clean up temporary resources mCairoWrapper->g_object_unref(tempPangoLyt); @@ -202,19 +195,13 @@ bool Label::create(const std::string& labelText) { gobjectDeleter.wrapper = mCairoWrapper; mSurface = std::unique_ptr( - mCairoWrapper->cairo_image_surface_create(CAIRO_FORMAT_A8, mLayoutWidth, mPrinterHeight), - surfaceDeleter - ); + mCairoWrapper->cairo_image_surface_create(CAIRO_FORMAT_A8, mLayoutWidth, mPrinterHeight), surfaceDeleter); cairo_t* cr = mCairoWrapper->cairo_create(mSurface.get()); - mCairoCtx = std::unique_ptr(cr, cairoDeleter); - mPangoCtx = std::unique_ptr( - mCairoWrapper->pango_cairo_create_context(cr), - gobjectDeleter - ); - mPangoLyt = std::unique_ptr( - mCairoWrapper->pango_layout_new(mPangoCtx.get()), - gobjectDeleter - ); + mCairoCtx = std::unique_ptr(cr, cairoDeleter); + mPangoCtx = + std::unique_ptr(mCairoWrapper->pango_cairo_create_context(cr), gobjectDeleter); + mPangoLyt = + std::unique_ptr(mCairoWrapper->pango_layout_new(mPangoCtx.get()), gobjectDeleter); // Configure final layout with same settings configureLayout(mPangoLyt.get(), labelText, regularFont); @@ -273,9 +260,8 @@ bool Label::append(const ILabel& other, uint32_t spacingPx) { // Create new surface with extended width CairoSurfaceDeleter surfaceDeleter; surfaceDeleter.wrapper = mCairoWrapper; - auto newSurface = std::unique_ptr( - mCairoWrapper->cairo_image_surface_create(CAIRO_FORMAT_A8, newWidth, height), - surfaceDeleter); + auto newSurface = std::unique_ptr( + mCairoWrapper->cairo_image_surface_create(CAIRO_FORMAT_A8, newWidth, height), surfaceDeleter); if (mCairoWrapper->cairo_surface_status(newSurface.get()) != CAIRO_STATUS_SUCCESS) { spdlog::error("Failed to create new surface for appended label");