diff --git a/src/examples/node/index.ts b/src/examples/node/index.ts index 4a9540a..4c0a802 100644 --- a/src/examples/node/index.ts +++ b/src/examples/node/index.ts @@ -6,29 +6,6 @@ import { NodeType, parse, HTMLElement } from "node-html-parser" import fontkit from "fontkit" export default async () => { - // const rootNode = parse("Some cool text first u Other remaining u cool asd asd qwe") - // rootNode.childNodes.forEach(node => { - // if(node.nodeType == NodeType.TEXT_NODE) { - // console.log("T (", node.innerText, ")") - // } else if(node.nodeType == NodeType.ELEMENT_NODE) { - // const casted = node as HTMLElement - // console.log() - // console.log(casted.rawTagName, " ----> ") - - // casted.childNodes.forEach((element) => { - // if(element.nodeType == NodeType.TEXT_NODE) { - // console.log("T (", element.innerText, ")") - // } else if(element.nodeType == NodeType.ELEMENT_NODE) { - // const casted2 = element as HTMLElement - // console.log(casted2.rawTagName, " (", element.innerText, ")") - // } - // }) - - // console.log(casted.rawTagName, " <---- ") - // console.log() - // } - // }) - const printers = await PrinterService.getPrinters() console.log("Printers", printers) @@ -36,11 +13,11 @@ export default async () => { const printer = printers[0] const fontName = "roboto" - const testText = "Hello 4 from the other side noooooooo not really" + const testText = "Exciting things are coming to label-printer" const fontSize = 25 const textX = 10 const textY = 10 - const textWidth = 180 + const textWidth = 250 const fontRegular = fs.readFileSync(__dirname+"/Roboto-Regular.ttf").buffer const fontBold = fs.readFileSync(__dirname+"/Roboto-Bold.ttf").buffer diff --git a/src/labels/fields/Text.ts b/src/labels/fields/Text.ts index e9afdf0..6ab6bd0 100644 --- a/src/labels/fields/Text.ts +++ b/src/labels/fields/Text.ts @@ -57,7 +57,7 @@ export default class Text extends LabelField { constructor(content: string, x: number, y: number, formatted: boolean = true) { super() - this.content = content + this.content = content.replace("\n", "") // Newline can break text generation this.x = x this.y = y this.formatted = formatted