anastaciocintra / escpos-coffee

Java library for ESC/POS printer
https://anastaciocintra.github.io/escpos-coffee
MIT License
282 stars 74 forks source link

Need to open getter for Style properties #68

Closed OumaSyuu closed 3 years ago

OumaSyuu commented 3 years ago

Hi, I want to know is it possible to open getter for Style properties:

    private FontName fontName;
    private boolean bold;
    private Underline underline;
    private FontSize fontWidth;
    private FontSize fontHeight;
    private Justification justification;
    private boolean defaultLineSpacing;
    private int lineSpacing;
    private ColorMode colorMode;

I have got pos printers that support Chinese characters. And the underline setting is not working on Chinese characters(need to write command "FS-"). Ive tried to override getConfigBytes with custom style class, but I cant access the underline property.

OumaSyuu commented 3 years ago

Plus, some of the printers are behaving weird with style setting(justification setting not working). I want to do some adaptations with custom style and no reflection.

anastaciocintra commented 3 years ago

Hi @OumaSyuu, Good question. Unfortunately, my printer (epson TM-T20)haven't the feature to print Chinese characters, in the past I've testing(sandbox) FS command without success.


public class Chinese {
    int FS = 0x1c;

    void exec(EscPos escpos) throws IOException {
        /**
        public function textChinese(string $str = "")
        {
            $this -> connector -> write(self::FS . "&");
            $str = \UConverter::transcode($str, "GBK", "UTF-8");
            $this -> buffer -> writeTextRaw((string)$str);
            $this -> connector -> write(self::FS . ".");
        }
         **/
        escpos.write(FS).write("&");
        String text = "艾德蒙 AOC E2450SWH 23.6吋 LED液晶寬螢幕特價$ 19900\n\n";
        byte [] x = text.getBytes("BIG5");
        escpos.write(x,0,x.length);
        escpos.write(FS).write(".");
        escpos.feed(5).cut(EscPos.CutMode.FULL);
    }

Plus, some of the printers are behaving weird with style setting

Ok, some printers can't recognize the textStyle commands, you can try the textprintmodestyle. text print mode style class / more explanation

Ive tried to override getConfigBytes with custom style class, but I cant access the underline property.

Hey, you found one architectural problem. I need to transform the attributes in protect instead of privates ! I'll do the corrections to the next release. And then you will be able to make your own inherited style commands.

anastaciocintra commented 3 years ago

released... v4.1.0

OumaSyuu commented 3 years ago

Thanks for help. It works.