• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Using Barcode Fonts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Barcode Fonts

    I was wondering if there's a simple way to be able to use barcode fonts (e.g. Libre Barcode 128) in a Valence widget. I want to be able to display an order number as a barcode in one of my apps so it can be scanned.

  • #2
    From behaviors on startup, add an execute script that will load the fonts and add a new CSS for styling your value into a barcode.

    Startup > Execute Script
    Code:
    // get the barcode font via google
    //
    const link = document.createElement('link');
    link.href = 'https://fonts.googleapis.com/css?family=Libre+Barcode+128&display=swap';
    link.rel = 'stylesheet';
    document.head.appendChild(link);
    
    // add the barcode css
    //
    const style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = `.libre-barcode-128-regular {
      font-family: "Libre Barcode 128", system-ui;
      font-weight: 400;
      font-style: normal;
    }`;
    document.head.appendChild(style);
    
    success();
    Then for example in a grid custom formatter return the value with the class of 'libre-barcode-128-regular':
    Code:
    return `<div class="libre-barcode-128-regular">${v}</div>`;

    Comment


    • #3
      Did this work for you?

      Comment

      Working...
      X