/* ptrnt - print labels on linux Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "LabelBuilder.hpp" #include #include "Label.hpp" namespace ptprnt::graphics { LabelBuilder::LabelBuilder(int printerHeight) : mPrinterHeight(printerHeight) { reset(); } ILabelBuilder& LabelBuilder::addText(const std::string& text) { if (!text.empty()) { if (!mAccumulatedText.empty()) { // Add a newline if the label already has some text accumulated mAccumulatedText += '\n'; } mAccumulatedText += text; spdlog::debug("LabelBuilder: Added text '{}', total length: {}", text, mAccumulatedText.length()); } return *this; } ILabelBuilder& LabelBuilder::setFontFamily(const std::string& fontFamily) { mCurrentFontFamily = fontFamily; spdlog::debug("LabelBuilder: Set font family to '{}'", fontFamily); return *this; } ILabelBuilder& LabelBuilder::setFontSize(double fontSize) { mCurrentFontSize = fontSize; spdlog::debug("LabelBuilder: Set font size to {}", fontSize); return *this; } ILabelBuilder& LabelBuilder::setHAlign(HAlignPosition hAlign) { mCurrentHAlign = hAlign; spdlog::debug("LabelBuilder: Set horizontal alignment to {}", static_cast(hAlign)); return *this; } ILabelBuilder& LabelBuilder::setVAlign(VAlignPosition vAlign) { mCurrentVAlign = vAlign; spdlog::debug("LabelBuilder: Set vertical alignment to {}", static_cast(vAlign)); return *this; } std::unique_ptr LabelBuilder::build() { spdlog::debug("LabelBuilder: Building label with text: '{}'", mAccumulatedText); auto label = std::make_unique