As I can see in documentation: ZebraPrinterFactory.createLinkOsPrinter(ZebraPrinter genericPrinter, PrinterLanguage language)
This method will not query the printer for its control language and will use a language value that you provided. So you need to be sure your printer is configured to use ZPL language.
You can check it and set to ZPL with following SGD commands:
! U1 getvar "device.languages"
! U1 setvar "device.languages" "zpl"
You may need to read Best Practices For Printing document that covers such kind of issues.
Software Engineer, Kutir Mobility
Posted on behalf of Zebra Technologies
Thanks Dmitry. I didn't realize printer is not in zpl mode. Below code now works for me. Thanks for your quick reply.
SGD.SET("device.languages", "zpl", connection);
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.createLinkOsPrinter(printer, PrinterLanguage.ZPL);
InputStream stream = getAssets().open("myfont.ttf");