Closed sornbarang closed 6 months ago
Unfortunately, SM-L200 does not support Khmer font. However, you can print Khmer font by converting it to image data.
Here is a sample code for converting text to image data.
val settings = StarConnectionSettings(interfaceType, identifier)
val printer = StarPrinter(settings, applicationContext)
val textSize = 22
val printWidth = 576
val printText = "វិក័យប័ត្រ"
val typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
val paint = Paint()
paint.textSize = textSize.toFloat()
paint.typeface = typeface
val textPaint = TextPaint(paint)
val staticLayoutBuilder = StaticLayout.Builder.obtain(printText, 0, printText.length, textPaint, printWidth)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(0f, 1f)
.setIncludePad(false)
val staticLayout = staticLayoutBuilder.build()
val bitmap: Bitmap = Bitmap.createBitmap(staticLayout.width, staticLayout.height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)
canvas.translate(0F, 0F)
staticLayout.draw(canvas)
val builder = StarXpandCommandBuilder()
builder.addDocument(
DocumentBuilder()
.addPrinter(
PrinterBuilder()
.actionPrintImage(ImageParameter(bitmap, 576))
.actionFeedLine(1)
.actionCut(CutType.Partial)
)
)
val commands = builder.getCommands()
printer.openAsync().await()
printer.printAsync(commands).await()
Printing result:
I am closing this Issue. If you still have this issue, please reopen it.
Description
I can't print in Khmer font. example: វិក័យប័ត្រ
Your printer