Now I know how to do it. I had to apply reverse engineering and de-compile an .apk from the market, using dex2jar on Linux and then opening the jar with java de-compiler... Try this...When you write this command:
out.write(str.getBytes(),0,str.getBytes().length);
you are sending to the method a byte[] array. You can modify the format by sending another byte[] array before sending the real byte[] array...
The default format byte[] array is this:
byte[] arrayOfByte1 = { 27, 33, 0 };
So u can try this:
byte[] format = { 27, 33, 0 };
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
These lines will print the default format text, but if you try below code,
byte[] format = { 27, 33, 0 };
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
it will print text in bold style... You can try these other format arrays:
// Bold
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
// Height
format[2] = ((byte)(0x10 | arrayOfByte1[2]));
// Width
format[2] = ((byte) (0x20 | arrayOfByte1[2]));
// Underline
format[2] = ((byte)(0x80 | arrayOfByte1[2]));
// Small
format[2] = ((byte)(0x1 | arrayOfByte1[2]));
Also you can combine it, then if you like little and bold text, uncomment these array assignments, for example:
byte[] format = { 27, 33, 0 };
// Bold
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
// Height
format[2] = ((byte)(0x10 | arrayOfByte1[2]));
// Width
format[2] = ((byte) (0x20 | arrayOfByte1[2]));
// Underline
// format[2] = ((byte)(0x80 | arrayOfByte1[2]));
// Small
// format[2] = ((byte)(0x1 | arrayOfByte1[2]));
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
This last code prints que biggest text size.