anastaciocintra / escpos-coffee

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

fontsize #45

Closed deividnn closed 4 years ago

deividnn commented 4 years ago

boa tarde,consigo criar um fontsize menor que os atuais? passei um valor diferente e retornou

java.lang.IllegalArgumentException: No enum constant com.github.anastaciocintra.escpos.Style.FontSize.

anastaciocintra commented 4 years ago

Hi @deividnn, you can change font sizes by setFontSize and setFontName.

for me, it works, except Font_C configuration, my printer does not recognize Font_C:

import com.github.anastaciocintra.escpos.EscPos;
import com.github.anastaciocintra.escpos.Style;

import java.io.IOException;

public class TextSize implements Exec {
    @Override
    public void exec(EscPos escpos) throws IOException {

        Style style = new Style();

        escpos.writeLF("printing with default font");
        style.setFontName(Style.FontName.Font_B);
        escpos.writeLF(style, "printing with Font_B, it is smaller then Font_A");
        style.setFontName(Style.FontName.Font_C);
        escpos.writeLF(style,"You can print whith Font_C to see what happens");

        escpos.writeLF("Configuring some sizes combination");
        escpos.writeLF("you can make 7x7 different combinations");

        style.setFontName(Style.FontName.Font_A_Default);
        escpos.writeLF("Using Font A");
        style.setFontSize(Style.FontSize._1, Style.FontSize._1);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._1, Style.FontSize._2);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._2, Style.FontSize._1);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._2, Style.FontSize._2);
        escpos.write(style,"H");

        escpos.feed(5);

        escpos.writeLF("Using Font B");
        style.setFontName(Style.FontName.Font_B);
        style.setFontSize(Style.FontSize._1, Style.FontSize._1);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._1, Style.FontSize._2);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._2, Style.FontSize._1);
        escpos.write(style,"H");
        style.setFontSize(Style.FontSize._2, Style.FontSize._2);
        escpos.write(style,"H");

        escpos.feed(5).cut(EscPos.CutMode.FULL);
        escpos.close();
    }
}

20200906_142710

deividnn commented 4 years ago

thanks i'll test