ESC-POS-USB-NET icon indicating copy to clipboard operation
ESC-POS-USB-NET copied to clipboard

How to change font size?

Open crossknight opened this issue 3 years ago • 1 comments

I am not sure how to change the font size of the printer.

crossknight avatar Apr 08 '21 22:04 crossknight

Hello, I know it's a little late but I wrote a simple extension class that achieve the font size setting (@mtmsuhail could be interesting to see this implemented)

public static class PrinterExtensions
{
	[Flags]
	public enum PrintStyle
	{
		HeightNormal = 0x00,
		Height2X = 0x01,
		Height3X = 0x02,
		Height4X = 0x03,
		Height5X = 0x04,
		Height6X = 0x05,
		Height7X = 0x06,
		Height8X = 0x07,
		WidthNormal = 0x00,
		Width2X = 0x10,
		Width3X = 0x20,
		Width4X = 0x30,
		Width5X = 0x40,
		Width6X = 0x50,
		Width7X = 0x60,
		Width8X = 0x70,
	};

	public static void SetStyle(this Printer printer, PrintStyle style)
	{
		printer.Append(new byte[] { 0x1D, 0x21, (byte)style });
	}
}

you can then use it like this:

Printer printer = new Printer("FooBar");
printer.SetStyle(PrintStyle.Height2X | PrintStyle.Width2X);

Source

informagico avatar Jan 16 '24 17:01 informagico