You may change the text styles within your receipt. The LinePrinter class gets information about the printer functions from the commands and attributes file specified in the LinePrinter constructor. If the loaded printer settings do not contain information on how to perform a font style command, the command is ignored without generating an error. This allows you to make calls regardless of the printer you are connected to.
The LinePrinter class supports these methods to set font styles:
public void setBold(Boolean enabled) throws LinePrinterException public void setCompress(Boolean enabled) throws LinePrinterException public void setDoubleHigh(Boolean enabled) throws LinePrinterException public void setDoubleWide(Boolean enabled) throws LinePrinterException public void setItalic(Boolean enabled) throws LinePrinterException public void setStrikeout(Boolean enabled) throws LinePrinterException public void setUnderline(Boolean enabled) throws LinePrinterException
The effect of the font styles depends on how the font style settings are defined and the printer capability. For example, the font style settings in the next code sample are extracted from the standard printer_profiles.JSON file included with the Printing SDK:
"DEFAULTS":
{
"BoldIsFont": true, "BoldOff": "[0x1b,0x77,!]",
"BoldOn": "[0x1b,0x77,0x6D]",
"CompressDotsHigh": 12, "CompressIsFont": true,
"CompressOff": "[0x1b,0x77,!]", "CompressOn": "[0x1b,0x77,0x42]",
"DoubleHighDotsHigh": 32, "DoubleHighIsFont": false,
"DoubleHighMask": 16, "DoubleHighOff": "[0x1b,!,0x10]",
"DoubleHighOn": "[0x1b,!,0x10]",
"DoubleWideDotsHigh": 16, "DoubleWideHighPrefix": "[0x1b,!]",
"DoubleWideIsFont": false,
"DoubleWideMask": 32, "DoubleWideOff": "[0x1b,!,0x20]",
"DoubleWideOn": "[0x1b,!,0x20]"
}
Note the boldface settings which determine whether the font is implemented using a separate font or as a font attribute. In this example Bold and Compress are defined as font styles, and Double High and Double Wide as font attributes. You may combine a font style with different font attributes but you cannot combine multiple font styles. For example, if you call setBold(true) followed by setCompress(true), the font style will be set to Compress because there can only be one font style at a time. However, you may combine the Bold font style with Double High and Double Wide attributes like the following code snippet demonstrates:
// lp is an instance of LinePrinter object. lp.setBold(true); lp.setDoubleHigh(true); lp.setDoubleWide(true);