Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kemkriszt committed Jan 18, 2024
1 parent d1f3c23 commit f5e680e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
27 changes: 2 additions & 25 deletions src/examples/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,18 @@ import { NodeType, parse, HTMLElement } from "node-html-parser"
import fontkit from "fontkit"

export default async () => {
// const rootNode = parse("Some cool text <u>first u <font name='font2'>Other</font> remaining u</u> cool asd <s>asd</s> <font size='12'>qwe<font>")
// 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)

if(printers.length > 0) {
const printer = printers[0]

const fontName = "roboto"
const testText = "Hello 4 <b>from</b> <u>the <b>other</b> side</u> <i>noooooooo</i> not <i><b>really</b></i>"
const testText = "<i>Exciting</i> 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
Expand Down
2 changes: 1 addition & 1 deletion src/labels/fields/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5e680e

Please sign in to comment.