From 894d252aaf0470112c4c07398d867cad76a95313 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Tue, 3 May 2022 10:02:26 +0530 Subject: [PATCH 01/16] Update generator.dart --- lib/src/generator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 6b464a6..1755c7b 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -559,7 +559,7 @@ class Generator { bytes += emptyLines(1); if (isNextRow) { - row(nextRow); + bytes += row(nextRow); } return bytes; } From f0123e9294f059a2288871f28d4b4e86c6d7f02a Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Tue, 3 May 2022 10:06:55 +0530 Subject: [PATCH 02/16] Update pubspec.yaml --- pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec.yaml b/pubspec.yaml index 5db09d0..2f1f242 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,7 @@ name: esc_pos_utils description: Basic Flutter/Dart classes for ESC/POS printing. Ticket class generates ESC/POS commands that can be sent to a thermal printer. version: 1.1.0 +publish_to: none homepage: https://github.com/andrey-ushakov/esc_pos_utils environment: From c1b2d9b561cf568b92f9bc9d602a08e44590cbf0 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Thu, 5 May 2022 13:40:50 +0530 Subject: [PATCH 03/16] Update generator.dart --- lib/src/generator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 1755c7b..3ab4e97 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -556,7 +556,7 @@ class Generator { } } - bytes += emptyLines(1); + //bytes += emptyLines(1); if (isNextRow) { bytes += row(nextRow); From 66b812d91951d42842510e90e5291e8bb063f03f Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Fri, 6 May 2022 17:13:58 +0530 Subject: [PATCH 04/16] Update generator.dart --- lib/src/generator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 3ab4e97..1755c7b 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -556,7 +556,7 @@ class Generator { } } - //bytes += emptyLines(1); + bytes += emptyLines(1); if (isNextRow) { bytes += row(nextRow); From 29e3be8ac7e7c1a6751147692f0f1eff1ca116f7 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Mon, 20 Jun 2022 19:49:11 +0530 Subject: [PATCH 05/16] Update generator.dart --- lib/src/generator.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 1755c7b..ba5a2eb 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -349,6 +349,7 @@ class Generator { int? maxCharsPerLine, }) { List bytes = []; + text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); if (!containsChinese) { bytes += _text( _encode(text, isKanji: containsChinese), From 6a7df3abc3656a51c6109dc5e3f6efa6a564b65b Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:07:31 +0530 Subject: [PATCH 06/16] Update generator.dart --- lib/src/generator.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index ba5a2eb..ec75aad 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -73,6 +73,7 @@ class Generator { .replaceAll("»", '"') .replaceAll(" ", ' ') .replaceAll("•", '.'); + text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); if (!isKanji) { return latin1.encode(text); } else { From 611336f0878774964e3f2aff03edd3cf343c2cd4 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Sun, 26 Mar 2023 02:01:59 +0530 Subject: [PATCH 07/16] soft wrap --- lib/src/generator.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index ec75aad..4668cf7 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -489,6 +489,12 @@ class Generator { int realCharactersNb = encodedToPrint.length; if (realCharactersNb > maxCharactersNb) { // Print max possible and split to the next row + try { + while(String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb))[String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb)).length-1]!=" ") + { + maxCharactersNb--; + } + } catch (e) {} Uint8List encodedToPrintNextRow = encodedToPrint.sublist(maxCharactersNb); encodedToPrint = encodedToPrint.sublist(0, maxCharactersNb); From 5bbfae3b7106894b3bd768b9f72b29bf43870972 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Fri, 5 May 2023 10:20:56 +0530 Subject: [PATCH 08/16] * changes --- lib/src/generator.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 4668cf7..d6705ab 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -493,6 +493,11 @@ class Generator { while(String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb))[String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb)).length-1]!=" ") { maxCharactersNb--; + if(maxCharactersNb==0) + { + maxCharactersNb = ((toPos - fromPos) / charWidth).floor(); + break; + } } } catch (e) {} Uint8List encodedToPrintNextRow = From af8f273c66dbc81dd66bb61d2cf0a10dc39c18ed Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Sat, 23 Sep 2023 00:36:59 +0530 Subject: [PATCH 09/16] * chineese fix --- lib/src/generator.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index d6705ab..bcbfff5 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -73,10 +73,11 @@ class Generator { .replaceAll("»", '"') .replaceAll(" ", ' ') .replaceAll("•", '.'); - text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); + if (!isKanji) { return latin1.encode(text); } else { + text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); return Uint8List.fromList(gbk_bytes.encode(text)); } } @@ -350,8 +351,8 @@ class Generator { int? maxCharsPerLine, }) { List bytes = []; - text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); if (!containsChinese) { + text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); bytes += _text( _encode(text, isKanji: containsChinese), styles: styles, From bee2ae541af1150e1ea33e1e8a851fff775fd128 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:50:05 +0530 Subject: [PATCH 10/16] * chineese fix --- lib/src/generator.dart | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index bcbfff5..e9aea90 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -73,11 +73,12 @@ class Generator { .replaceAll("»", '"') .replaceAll(" ", ' ') .replaceAll("•", '.'); - + if (!isKanji) { + text = text.replaceAll( + RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); return latin1.encode(text); } else { - text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); return Uint8List.fromList(gbk_bytes.encode(text)); } } @@ -85,6 +86,9 @@ class Generator { List _getLexemes(String text) { final List lexemes = []; final List isLexemeChinese = []; + if (text.isEmpty) { + return []; + } int start = 0; int end = 0; bool curLexemeChinese = _isChinese(text[0]); @@ -352,7 +356,8 @@ class Generator { }) { List bytes = []; if (!containsChinese) { - text=text.replaceAll(RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); + text = text.replaceAll( + RegExp('[^A-Za-z0-9!"#\$%&\'\n()*+,./:;<=>?@\^_`{|}~-]'), ' '); bytes += _text( _encode(text, isKanji: containsChinese), styles: styles, @@ -491,14 +496,18 @@ class Generator { if (realCharactersNb > maxCharactersNb) { // Print max possible and split to the next row try { - while(String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb))[String.fromCharCodes(encodedToPrint.sublist(0,maxCharactersNb)).length-1]!=" ") - { - maxCharactersNb--; - if(maxCharactersNb==0) - { + while (String.fromCharCodes( + encodedToPrint.sublist(0, maxCharactersNb))[ + String.fromCharCodes( + encodedToPrint.sublist(0, maxCharactersNb)) + .length - + 1] != + " ") { + maxCharactersNb--; + if (maxCharactersNb == 0) { maxCharactersNb = ((toPos - fromPos) / charWidth).floor(); break; - } + } } } catch (e) {} Uint8List encodedToPrintNextRow = @@ -552,8 +561,8 @@ class Generator { // Print current row final list = _getLexemes(toPrint); - final List lexemes = list[0]; - final List isLexemeChinese = list[1]; + final List lexemes = list.isEmpty ? [] : list[0]; + final List isLexemeChinese = list.isEmpty ? [] : list[1]; // Print each lexeme using codetable OR kanji for (var j = 0; j < lexemes.length; ++j) { @@ -829,8 +838,8 @@ class Generator { }) { List bytes = []; final list = _getLexemes(text); - final List lexemes = list[0]; - final List isLexemeChinese = list[1]; + final List lexemes = list.isEmpty ? [] : list[0]; + final List isLexemeChinese = list.isEmpty ? [] : list[1]; // Print each lexeme using codetable OR kanji int? colInd = 0; From 074a6ffa48184349a34a7f1c01562f8c04b4b839 Mon Sep 17 00:00:00 2001 From: ramdasoutlogics <84704644+ramdasoutlogics@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:00:16 +1300 Subject: [PATCH 11/16] * changes --- lib/src/generator.dart | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index e9aea90..6fdcfd8 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -12,7 +12,6 @@ import 'package:hex/hex.dart'; import 'package:image/image.dart'; import 'package:gbk_codec/gbk_codec.dart'; import 'package:esc_pos_utils/esc_pos_utils.dart'; -import 'enums.dart'; import 'commands.dart'; class Generator { @@ -485,11 +484,11 @@ class Generator { _colIndToPosition(colInd + cols[i].width) - spaceBetweenRows; int maxCharactersNb = ((toPos - fromPos) / charWidth).floor(); - if (!cols[i].containsChinese) { + if (true) { // CASE 1: containsChinese = false Uint8List encodedToPrint = cols[i].textEncoded != null ? cols[i].textEncoded! - : _encode(cols[i].text); + : _encode(cols[i].text, isKanji: true); // If the col's content is too long, split it to the next row int realCharactersNb = encodedToPrint.length; @@ -516,6 +515,7 @@ class Generator { isNextRow = true; nextRow.add(PosColumn( textEncoded: encodedToPrintNextRow, + containsChinese: true, width: cols[i].width, styles: cols[i].styles)); } else { @@ -524,12 +524,11 @@ class Generator { text: '', width: cols[i].width, styles: cols[i].styles)); } // end rows splitting - bytes += _text( - encodedToPrint, - styles: cols[i].styles, - colInd: colInd, - colWidth: cols[i].width, - ); + bytes += _text(encodedToPrint, + styles: cols[i].styles, + colInd: colInd, + colWidth: cols[i].width, + isKanji: true); } else { // CASE 1: containsChinese = true // Split text into multiple lines if it too long From 6ccb72ca656b0b656d828f7b678913f003c169f7 Mon Sep 17 00:00:00 2001 From: ramdas Date: Mon, 18 Dec 2023 21:22:16 +1300 Subject: [PATCH 12/16] * fix --- lib/src/enums.dart | 13 +++++++++---- lib/src/generator.dart | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/src/enums.dart b/lib/src/enums.dart index ac2f602..26c9d76 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -7,8 +7,11 @@ */ enum PosAlign { left, center, right } + enum PosCutMode { full, partial } + enum PosFontType { fontA, fontB } + enum PosDrawer { pin2, pin5 } /// Choose image printing function @@ -33,12 +36,14 @@ class PosTextSize { } class PaperSize { - const PaperSize._internal(this.value); + const PaperSize._internal(this.value, this.custom); final int value; - static const mm58 = PaperSize._internal(1); - static const mm80 = PaperSize._internal(2); + final int? custom; + static const mm58 = PaperSize._internal(1, null); + static const mm80 = PaperSize._internal(2, null); - int get width => value == PaperSize.mm58.value ? 372 : 558; + int get width => + (custom != null ? custom! : (value == PaperSize.mm58.value ? 372 : 558)); } class PosBeepDuration { diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 6fdcfd8..b792771 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -484,7 +484,7 @@ class Generator { _colIndToPosition(colInd + cols[i].width) - spaceBetweenRows; int maxCharactersNb = ((toPos - fromPos) / charWidth).floor(); - if (true) { + if (!cols[i].containsChinese) { // CASE 1: containsChinese = false Uint8List encodedToPrint = cols[i].textEncoded != null ? cols[i].textEncoded! From 271a02d27b1785b62f70660b5e5f6dff3b3952ad Mon Sep 17 00:00:00 2001 From: ramdas Date: Mon, 18 Dec 2023 21:31:53 +1300 Subject: [PATCH 13/16] * fixes --- lib/src/enums.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 26c9d76..bb68efa 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -36,11 +36,11 @@ class PosTextSize { } class PaperSize { - const PaperSize._internal(this.value, this.custom); + PaperSize._internal(this.value); final int value; - final int? custom; - static const mm58 = PaperSize._internal(1, null); - static const mm80 = PaperSize._internal(2, null); + int? custom; + static var mm58 = PaperSize._internal(1); + static var mm80 = PaperSize._internal(2); int get width => (custom != null ? custom! : (value == PaperSize.mm58.value ? 372 : 558)); From 10ac08a5e656e22680ecaa7cd9b20dc42bd2310e Mon Sep 17 00:00:00 2001 From: ramdas Date: Thu, 28 Dec 2023 19:17:10 +1300 Subject: [PATCH 14/16] * printfix --- example/example.dart | 2 +- lib/src/capability_profile.dart | 1 - lib/src/generator.dart | 12 ++++++------ test/esc_pos_utils_test.dart | 2 -- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/example/example.dart b/example/example.dart index 85c0a1c..2ca13ad 100644 --- a/example/example.dart +++ b/example/example.dart @@ -42,7 +42,7 @@ Future main() async { width: 3, styles: PosStyles(align: PosAlign.center, underline: true), ), - ]); + ], false); bytes += generator.text('Text size 200%', styles: PosStyles( diff --git a/lib/src/capability_profile.dart b/lib/src/capability_profile.dart index 019bae2..c899362 100644 --- a/lib/src/capability_profile.dart +++ b/lib/src/capability_profile.dart @@ -7,7 +7,6 @@ */ import 'dart:convert' show json; -import 'dart:convert' show utf8; import 'package:flutter/services.dart' show rootBundle; class CodePage { diff --git a/lib/src/generator.dart b/lib/src/generator.dart index b792771..9850de5 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -466,7 +466,7 @@ class Generator { /// /// A row contains up to 12 columns. A column has a width between 1 and 12. /// Total width of columns in one row must be equal 12. - List row(List cols) { + List row(List cols, bool containChineese) { List bytes = []; final isSumValid = cols.fold(0, (int sum, col) => sum + col.width) == 12; if (!isSumValid) { @@ -488,7 +488,7 @@ class Generator { // CASE 1: containsChinese = false Uint8List encodedToPrint = cols[i].textEncoded != null ? cols[i].textEncoded! - : _encode(cols[i].text, isKanji: true); + : _encode(cols[i].text, isKanji: containChineese); // If the col's content is too long, split it to the next row int realCharactersNb = encodedToPrint.length; @@ -515,7 +515,7 @@ class Generator { isNextRow = true; nextRow.add(PosColumn( textEncoded: encodedToPrintNextRow, - containsChinese: true, + containsChinese: containChineese, width: cols[i].width, styles: cols[i].styles)); } else { @@ -528,7 +528,7 @@ class Generator { styles: cols[i].styles, colInd: colInd, colWidth: cols[i].width, - isKanji: true); + isKanji: containChineese); } else { // CASE 1: containsChinese = true // Split text into multiple lines if it too long @@ -549,7 +549,7 @@ class Generator { isNextRow = true; nextRow.add(PosColumn( text: toPrintNextRow, - containsChinese: true, + containsChinese: containChineese, width: cols[i].width, styles: cols[i].styles)); } else { @@ -581,7 +581,7 @@ class Generator { bytes += emptyLines(1); if (isNextRow) { - bytes += row(nextRow); + bytes += row(nextRow, containChineese); } return bytes; } diff --git a/test/esc_pos_utils_test.dart b/test/esc_pos_utils_test.dart index f50dbae..2f6b825 100644 --- a/test/esc_pos_utils_test.dart +++ b/test/esc_pos_utils_test.dart @@ -1,7 +1,5 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:esc_pos_utils/esc_pos_utils.dart'; - void main() { test('Tests not implemented', () { expect(1, 1); From 2dbde2115ad9cdab0d313689ce4450210803e007 Mon Sep 17 00:00:00 2001 From: ramdas Date: Wed, 17 Jan 2024 14:36:57 +1300 Subject: [PATCH 15/16] * pos util fix --- lib/src/generator.dart | 53 +++++++++---- pubspec.lock | 169 +++++++++++++++++++++++++++-------------- pubspec.yaml | 2 +- 3 files changed, 152 insertions(+), 72 deletions(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 9850de5..8386d25 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -149,17 +149,23 @@ class Generator { final int heightPx = image.height; // Create a black bottom layer - final biggerImage = copyResize(image, width: widthPx, height: heightPx); - fill(biggerImage, 0); + final biggerImage = copyResize(image, + width: widthPx, height: heightPx, interpolation: Interpolation.linear); + //fill(biggerImage, color: ColorRgb8(0, 0, 0)); + fill(biggerImage, color: ColorRgb8(0, 0, 0)); // Insert source image into bigger one - drawImage(biggerImage, image, dstX: 0, dstY: 0); + compositeImage(biggerImage, image, dstX: 0, dstY: 0); int left = 0; final List> blobs = []; while (left < widthPx) { - final Image slice = copyCrop(biggerImage, left, 0, lineHeight, heightPx); - final Uint8List bytes = slice.getBytes(format: Format.luminance); + final Image slice = copyCrop(biggerImage, + x: left, y: 0, width: lineHeight, height: heightPx); + if (slice.numChannels > 2) grayscale(slice); + final imgBinary = + (slice.numChannels > 1) ? slice.convert(numChannels: 1) : slice; + final bytes = imgBinary.getBytes(); blobs.add(bytes); left += lineHeight; } @@ -178,7 +184,7 @@ class Generator { // R/G/B channels are same -> keep only one channel final List oneChannelBytes = []; - final List buffer = image.getBytes(format: Format.rgba); + final List buffer = image.getBytes(); for (int i = 0; i < buffer.length; i += 4) { oneChannelBytes.add(buffer[i]); } @@ -589,20 +595,35 @@ class Generator { /// Print an image using (ESC *) command /// /// [image] is an instanse of class from [Image library](https://pub.dev/packages/image) - List image(Image imgSrc, {PosAlign align = PosAlign.center}) { + List image(Image imgSrc, + {PosAlign align = PosAlign.center, bool isDoubleDensity = true}) { List bytes = []; // Image alignment - bytes += setStyles(PosStyles().copyWith(align: align)); + bytes += setStyles(const PosStyles().copyWith(align: align)); + + Image image; + if (!isDoubleDensity) { + int size = 558 ~/ 2; + if (_paperSize == PaperSize.mm58) { + size = 375 ~/ 2; + } else if (_paperSize == PaperSize.mm80) { + size = 503 ~/ 2; + } - final Image image = Image.from(imgSrc); // make a copy - const bool highDensityHorizontal = true; - const bool highDensityVertical = true; + image = + copyResize(imgSrc, width: size, interpolation: Interpolation.linear); + } else { + image = Image.from(imgSrc); // make a copy + } + + bool highDensityHorizontal = isDoubleDensity; + bool highDensityVertical = isDoubleDensity; invert(image); - flip(image, Flip.horizontal); - final Image imageRotated = copyRotate(image, 270); + flipHorizontal(image); + final Image imageRotated = copyRotate(image, angle: 270); - const int lineHeight = highDensityVertical ? 3 : 1; + int lineHeight = highDensityVertical ? 3 : 1; final List> blobs = _toColumnFormat(imageRotated, lineHeight * 8); // Compress according to line density @@ -614,7 +635,7 @@ class Generator { } final int heightPx = imageRotated.height; - const int densityByte = + int densityByte = (highDensityHorizontal ? 1 : 0) + (highDensityVertical ? 32 : 0); final List header = List.from(cBitImg.codeUnits); @@ -622,7 +643,7 @@ class Generator { header.addAll(_intLowHigh(heightPx, 2)); // Adjust line spacing (for 16-unit line feeds): ESC 3 0x10 (HEX: 0x1b 0x33 0x10) - bytes += [27, 51, 16]; + bytes += [27, 51, 0]; for (int i = 0; i < blobs.length; ++i) { bytes += List.from(header) ..addAll(blobs[i]) diff --git a/pubspec.lock b/pubspec.lock index 3447480..4b16d40 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,72 +5,82 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.4.10" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "3.1.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" csslib: dependency: transitive description: name: csslib - url: "https://pub.dartlang.org" + sha256: f857285c8dc0b4f2f77b49a1c083ff8c75223a7549de20f3e607df58cf497a43 + url: "https://pub.dev" source: hosted version: "0.17.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -85,58 +95,90 @@ packages: dependency: "direct main" description: name: gbk_codec - url: "https://pub.dartlang.org" + sha256: "3af5311fc9393115e3650ae6023862adf998051a804a08fb804f042724999f61" + url: "https://pub.dev" source: hosted version: "0.4.0" hex: dependency: "direct main" description: name: hex - url: "https://pub.dartlang.org" + sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a" + url: "https://pub.dev" source: hosted version: "0.2.0" html: dependency: transitive description: name: html - url: "https://pub.dartlang.org" + sha256: bfef906cbd4e78ef49ae511d9074aebd1d2251482ef601a280973e8b58b51bbf + url: "https://pub.dev" source: hosted version: "0.15.0" image: dependency: "direct main" description: name: image - url: "https://pub.dartlang.org" + sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" + url: "https://pub.dev" + source: hosted + version: "4.1.4" + js: + dependency: transitive + description: + name: js + sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" + url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "0.7.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.10.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29" + url: "https://pub.dev" source: hosted - version: "4.3.0" + version: "3.7.4" sky_engine: dependency: transitive description: flutter @@ -146,64 +188,81 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.4.3" + version: "0.6.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "0.3.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "6.5.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=3.2.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2f1f242..437b569 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: sdk: flutter hex: ^0.2.0 gbk_codec: ^0.4.0 - image: ^3.0.2 + image: ^4.0.9 dev_dependencies: flutter_test: From 0a7c8e26e998c8b9824a371bc17611b0c68796a7 Mon Sep 17 00:00:00 2001 From: ramdas Date: Mon, 5 Feb 2024 13:59:00 +1300 Subject: [PATCH 16/16] * fix --- lib/src/generator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 8386d25..aa5915c 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -490,7 +490,7 @@ class Generator { _colIndToPosition(colInd + cols[i].width) - spaceBetweenRows; int maxCharactersNb = ((toPos - fromPos) / charWidth).floor(); - if (!cols[i].containsChinese) { + if (true) { // CASE 1: containsChinese = false Uint8List encodedToPrint = cols[i].textEncoded != null ? cols[i].textEncoded!