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 String overlap when using Generator.row() method. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class Generator {

/// Cut the paper
///
/// [mode] is used to define the full or partial cut (if supported by the priner)
/// [mode] is used to define the full or partial cut (if supported by the printer)
List<int> cut({PosCutMode mode = PosCutMode.full}) {
List<int> bytes = [];
bytes += emptyLines(5);
Expand Down Expand Up @@ -446,7 +446,7 @@ class Generator {
return bytes;
}

/// Reverse feed for [n] lines (if supported by the priner)
/// Reverse feed for [n] lines (if supported by the printer)
List<int> reverseFeed(int n) {
List<int> bytes = [];
bytes += Uint8List.fromList(
Expand Down Expand Up @@ -542,16 +542,17 @@ class Generator {
final List<bool> isLexemeChinese = list[1];

// Print each lexeme using codetable OR kanji
int? colIndex = colInd;
for (var j = 0; j < lexemes.length; ++j) {
bytes += _text(
_encode(lexemes[j], isKanji: isLexemeChinese[j]),
styles: cols[i].styles,
colInd: colInd,
colInd: colIndex,
colWidth: cols[i].width,
isKanji: isLexemeChinese[j],
);
// Define the absolute position only once (we print one line only)
// colInd = null;
colIndex = null;
}
}
}
Expand All @@ -566,7 +567,7 @@ class Generator {

/// Print an image using (ESC *) command
///
/// [image] is an instanse of class from [Image library](https://pub.dev/packages/image)
/// [image] is an instance of class from [Image library](https://pub.dev/packages/image)
List<int> image(Image imgSrc, {PosAlign align = PosAlign.center}) {
List<int> bytes = [];
// Image alignment
Expand Down Expand Up @@ -613,7 +614,7 @@ class Generator {

/// Print an image using (GS v 0) obsolete command
///
/// [image] is an instanse of class from [Image library](https://pub.dev/packages/image)
/// [image] is an instance of class from [Image library](https://pub.dev/packages/image)
List<int> imageRaster(
Image image, {
PosAlign align = PosAlign.center,
Expand All @@ -628,7 +629,7 @@ class Generator {
final int widthPx = image.width;
final int heightPx = image.height;
final int widthBytes = (widthPx + 7) ~/ 8;
final List<int> resterizedData = _toRasterFormat(image);
final List<int> rasterizedData = _toRasterFormat(image);

if (imageFn == PosImageFn.bitImageRaster) {
// GS v 0
Expand All @@ -639,7 +640,7 @@ class Generator {
header.add(densityByte); // m
header.addAll(_intLowHigh(widthBytes, 2)); // xL xH
header.addAll(_intLowHigh(heightPx, 2)); // yL yH
bytes += List.from(header)..addAll(resterizedData);
bytes += List.from(header)..addAll(rasterizedData);
} else if (imageFn == PosImageFn.graphics) {
// 'GS ( L' - FN_112 (Image data)
final List<int> header1 = List.from(cRasterImg.codeUnits);
Expand All @@ -649,7 +650,7 @@ class Generator {
header1.addAll([49]); // c=49
header1.addAll(_intLowHigh(widthBytes, 2)); // xL xH
header1.addAll(_intLowHigh(heightPx, 2)); // yL yH
bytes += List.from(header1)..addAll(resterizedData);
bytes += List.from(header1)..addAll(rasterizedData);

// 'GS ( L' - FN_50 (Run print)
final List<int> header2 = List.from(cRasterImg.codeUnits);
Expand Down