Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CJK(Chinese, Japanese, Korean) PosAlign.right bug. #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ttyniwa
Copy link

@ttyniwa ttyniwa commented Oct 17, 2021

Please merge #62 first.

Overview

The following code will be printed across two lines due to wrong alignment.

    bytes += ticket.row([
      PosColumn(
          text: 'R右R',
          width: 12,
          styles: PosStyles(align: PosAlign.right),
          containsCjk: true),

Test

The receipt on the right is before the bug was fixed.
left is after the bug fixed.
IMG_3421

Tested with below code.

  Future<List<int>> debugCjk(PaperSize paper, CapabilityProfile profile) async {
    final Generator ticket = Generator(paper, profile);
    List<int> bytes = [];

    bytes += ticket.text(
      '漢字ひらがなカタカナ',
      styles: PosStyles(
        align: PosAlign.center,
        height: PosTextSize.size2,
        width: PosTextSize.size2,
      ),
      containsCjk: true,
    );

    bytes += ticket.text(
      'L左L',
      styles: PosStyles(align: PosAlign.left),
      containsCjk: true,
    );
    bytes += ticket.text(
      'C中央C',
      styles: PosStyles(align: PosAlign.center),
      containsCjk: true,
    );
    bytes += ticket.text(
      'R右R',
      styles: PosStyles(align: PosAlign.right),
      containsCjk: true,
    );

    bytes += ticket.row([
      PosColumn(
          text: 'L左L',
          width: 4,
          styles: PosStyles(align: PosAlign.left),
          containsCjk: true),
      PosColumn(
          text: 'L左L',
          width: 4,
          styles: PosStyles(align: PosAlign.left),
          containsCjk: true),
      PosColumn(
          text: 'L左L',
          width: 4,
          styles: PosStyles(align: PosAlign.left),
          containsCjk: true),
    ]);
    bytes += ticket.row([
      PosColumn(
          text: 'C中央C',
          width: 4,
          styles: PosStyles(align: PosAlign.center),
          containsCjk: true),
      PosColumn(
          text: 'C中央C',
          width: 4,
          styles: PosStyles(align: PosAlign.center),
          containsCjk: true),
      PosColumn(
          text: 'C中央C',
          width: 4,
          styles: PosStyles(align: PosAlign.center),
          containsCjk: true),
    ]);
    bytes += ticket.row([
      PosColumn(
          text: 'R右R',
          width: 4,
          styles: PosStyles(align: PosAlign.right),
          containsCjk: true),
      PosColumn(
          text: 'R右R',
          width: 4,
          styles: PosStyles(align: PosAlign.right),
          containsCjk: true),
      PosColumn(
          text: 'R右R',
          width: 4,
          styles: PosStyles(align: PosAlign.right),
          containsCjk: true),
    ]);

    bytes += ticket.row([
      PosColumn(
          text: 'left', width: 4, styles: PosStyles(align: PosAlign.left)),
      PosColumn(
          text: 'left', width: 4, styles: PosStyles(align: PosAlign.left)),
      PosColumn(
          text: 'left', width: 4, styles: PosStyles(align: PosAlign.left)),
    ]);
    bytes += ticket.row([
      PosColumn(
          text: 'center', width: 4, styles: PosStyles(align: PosAlign.center)),
      PosColumn(
          text: 'center', width: 4, styles: PosStyles(align: PosAlign.center)),
      PosColumn(
          text: 'center', width: 4, styles: PosStyles(align: PosAlign.center)),
    ]);
    bytes += ticket.row([
      PosColumn(
          text: 'right', width: 4, styles: PosStyles(align: PosAlign.right)),
      PosColumn(
          text: 'right', width: 4, styles: PosStyles(align: PosAlign.right)),
      PosColumn(
          text: 'right', width: 4, styles: PosStyles(align: PosAlign.right)),
    ]);

    ticket.feed(1);
    ticket.cut();
    return bytes;
  }

@ttyniwa
Copy link
Author

ttyniwa commented Oct 22, 2021

@andrey-ushakov
Could you merge #62 & #63 and release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant