Using Native Fonts with a Loftware NiceLabel Driver
If you are printing to a device using a Loftware NiceLabel driver, you cannot select a native font from the device in Label Design
- Configure the fields on the label template to use the device's native font.
- In Label Design
- Select each fixed text, variable text, and/or barcode field, and in the Properties pane, select Native for Send Field As.
- For each fixed text, variable text, and/or barcode field, on the Home tab, select the same TrueType font.
Example
On the Home tab, select TrueType > Arial for all fields.
- Save the label template.
- In Label Design
- Add a print stream script to map the Loftware-specified font to the native device font.
- In Devices
- On the Advanced tab, select Enabled for Advanced Troubleshooting. The Print Stream Scripting panel is displayed.
- In the Print Stream Scripting panel, select the Apply Script check box.
- Copy and paste the following into the Script field, replacing FONT NAME IN LOFTWARE and NATIVE FONT NAME ON DEVICE with the appropriate values.
Important: The fontNameLoftware value must exactly match the name of the font selected in Label Design
CopyLOG.info("STARTING FONT REPLACEMENT PSS");
var stream = PRINTSTREAM.getRawStream();
var stringStream = new java.lang.String(stream);
var fontNameSpectrum = "FONT NAME IN LOFTWARE";
var fontNameDevice = "NATIVE FONT NAME ON DEVICE";
if(stringStream.indexOf(fontSearchMarker) != -1){
LOG.info("Editing font name.");
stringStream = stringStream.replace(fontNameSpectrum, fontNameDevice);
PRINTSTREAM.setResultStream(stringStream.getBytes());
}
LOG.info(stringStream);Example
If you selected Arial for the font in Label Design
CopyLOG.info("STARTING FONT REPLACEMENT PSS");
var stream = PRINTSTREAM.getRawStream();
var stringStream = new java.lang.String(stream);
var fontNameSpectrum = "Arial";
var fontNameDevice = "9 high International";
if(stringStream.indexOf(fontSearchMarker) != -1){
LOG.info("Editing font name.");
stringStream = stringStream.replace(fontNameSpectrum, fontNameDevice);
PRINTSTREAM.setResultStream(stringStream.getBytes());
}
LOG.info(stringStream); - Save the device.
- In Devices