Generate labels with pangocairo (#8)
All checks were successful
Build ptprnt / build (push) Successful in 3m41s
All checks were successful
Build ptprnt / build (push) Successful in 3m41s
Goal of this PR is to have some basic labels generated with pangocairo - size of the canvas should be matching the input text and grow/shrink accordingly - basic formatting options like fontsize and align should be working Reviewed-on: moritz/ptouch-prnt#8
This commit was merged in pull request #8.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
ptrnt - print labels on linux
|
||||
Copyright (C) 2023 Moritz Martinius
|
||||
Copyright (C) 2023-2024 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
|
||||
@@ -20,21 +20,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
#include "libusb.h"
|
||||
#include "libusbwrap/LibUsbTypes.hpp"
|
||||
#include "libusbwrap/interface/IUsbDevice.hpp"
|
||||
|
||||
namespace libusbwrap {
|
||||
|
||||
struct usbDevice_deleter {
|
||||
void operator()(libusb_device* dev_ptr) const {
|
||||
if (nullptr != dev_ptr) {
|
||||
libusb_unref_device(dev_ptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using usbDevice_ptr = std::unique_ptr<libusb_device, usbDevice_deleter>;
|
||||
|
||||
class UsbDevice : public IUsbDevice {
|
||||
public:
|
||||
explicit UsbDevice(libusb_context* ctx, libusb_device* dev);
|
||||
explicit UsbDevice(libusb_context* ctx, usbDevice_ptr dev);
|
||||
~UsbDevice() override;
|
||||
|
||||
// delete copy ctor and assignment
|
||||
UsbDevice(const UsbDevice&) = delete;
|
||||
UsbDevice& operator=(UsbDevice&) = delete;
|
||||
UsbDevice(const UsbDevice&) = delete;
|
||||
UsbDevice& operator=(const UsbDevice&) = delete;
|
||||
UsbDevice(UsbDevice&&) = delete;
|
||||
UsbDevice& operator=(UsbDevice&&) = delete;
|
||||
|
||||
bool open() override;
|
||||
void close() override;
|
||||
@@ -43,8 +56,7 @@ class UsbDevice : public IUsbDevice {
|
||||
bool detachKernelDriver(int interfaceNo) override;
|
||||
bool claimInterface(int interfaceNo) override;
|
||||
bool releaseInterface(int interfaceNo) override;
|
||||
bool bulkTransfer(uint8_t endpoint, std::vector<uint8_t>& data, int* tx,
|
||||
unsigned int timeout) override;
|
||||
bool bulkTransfer(uint8_t endpoint, const std::vector<uint8_t>& data, int* tx, unsigned int timeout) override;
|
||||
|
||||
// getters
|
||||
const usbId getUsbId() override;
|
||||
@@ -58,9 +70,9 @@ class UsbDevice : public IUsbDevice {
|
||||
|
||||
private:
|
||||
libusb_context* mLibusbCtx{nullptr};
|
||||
libusb_device* mLibusbDev{nullptr};
|
||||
usbDevice_ptr mLibusbDev{nullptr};
|
||||
libusb_device_handle* mLibusbDevHandle{nullptr};
|
||||
libusb_device_descriptor mLibusbDevDesc;
|
||||
libusb_device_descriptor mLibusbDevDesc{0};
|
||||
std::atomic<bool> mIsOpen = false;
|
||||
Error mLastError = Error::SUCCESS;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user