Implement Label printing interface for PrinterDriver
Some checks failed
Build ptprnt / build (push) Failing after 32s
Some checks failed
Build ptprnt / build (push) Failing after 32s
This commit is contained in:
@@ -97,9 +97,9 @@ int PtouchPrint::run() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto label = graphics::Label();
|
||||
auto label = std::make_unique<graphics::Label>(printer->getPrinterInfo().pixelLines);
|
||||
std::string labelText{};
|
||||
|
||||
// TODO: refactor
|
||||
for (const auto& [cmd, value] : mCommands) {
|
||||
switch (cmd) {
|
||||
case CliCmdType::Text:
|
||||
@@ -111,11 +111,11 @@ int PtouchPrint::run() {
|
||||
break;
|
||||
case CliCmdType::Font:
|
||||
spdlog::debug("Setting font to {}", value);
|
||||
label.setFontFamily(value);
|
||||
label->setFontFamily(value);
|
||||
break;
|
||||
case CliCmdType::FontSize:
|
||||
spdlog::debug("Setting font size to {}", std::stod(value));
|
||||
label.setFontSize(std::stod(value));
|
||||
label->setFontSize(std::stod(value));
|
||||
break;
|
||||
case CliCmdType::HAlign:
|
||||
spdlog::debug("Setting text horizontal alignment to {}", value);
|
||||
@@ -123,9 +123,9 @@ int PtouchPrint::run() {
|
||||
auto hPos = HALignPositionMap.find(value);
|
||||
if (hPos == HALignPositionMap.end()) {
|
||||
spdlog::warn("Invalid horizontal alignment specified!");
|
||||
label.setHAlign(HAlignPosition::UNKNOWN);
|
||||
label->setHAlign(HAlignPosition::UNKNOWN);
|
||||
} else {
|
||||
label.setHAlign(hPos->second);
|
||||
label->setHAlign(hPos->second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -135,9 +135,9 @@ int PtouchPrint::run() {
|
||||
auto vPos = VALignPositionMap.find(value);
|
||||
if (vPos == VALignPositionMap.end()) {
|
||||
spdlog::warn("Invalid verical alignment specified!");
|
||||
label.setVAlign(VAlignPosition::UNKNOWN);
|
||||
label->setVAlign(VAlignPosition::UNKNOWN);
|
||||
} else {
|
||||
label.setVAlign(vPos->second);
|
||||
label->setVAlign(vPos->second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -148,13 +148,13 @@ int PtouchPrint::run() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!printer->print()) {
|
||||
label->create(labelText);
|
||||
label->writeToPng("./testlabel.png");
|
||||
if (!printer->printLabel(std::move(label))) {
|
||||
spdlog::error("An error occured while printing");
|
||||
return -1;
|
||||
}
|
||||
|
||||
label.create(labelText, 128);
|
||||
label.writeToPng("./testlabel.png");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@ void PtouchPrint::setupLogger(spdlog::level::level_enum lvl) {
|
||||
spdlog::set_default_logger(logger);
|
||||
}
|
||||
|
||||
// TODO: CLI parsing should be a seperate class/file
|
||||
void PtouchPrint::setupCliParser() {
|
||||
auto printVersion = [this](std::size_t) {
|
||||
fmt::print("ptprnt version: {}\n", mVersionString);
|
||||
|
||||
Reference in New Issue
Block a user