Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esc_pos_print_plus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
esc_pos_print_plus
Commits
2ecf35a0
Commit
2ecf35a0
authored
Sep 14, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added printlnMixedKanji method
parent
e634b71b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
example.dart
example/example.dart
+6
-0
printer.dart
lib/src/printer.dart
+44
-0
No files found.
example/example.dart
View file @
2ecf35a0
...
...
@@ -57,6 +57,12 @@ void main() {
final
List
<
int
>
barData
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0
,
4
];
printer
.
printBarcode
(
Barcode
.
upcA
(
barData
));
// Print mixed (chinese + latin) text. Only for printers supporting Kanji mode
// printer.printlnMixedKanji(
// 'hello ! 中文字 # world @ éphémère &',
// styles: PosStyles(codeTable: PosCodeTable.westEur),
// );
printer
.
cut
();
printer
.
disconnect
();
});
...
...
lib/src/printer.dart
View file @
2ecf35a0
...
...
@@ -161,6 +161,50 @@ class Printer {
reset
();
}
/// Prints one line of styled mixed (chinese and latin symbols) text
void
printlnMixedKanji
(
String
text
,
{
PosStyles
styles
=
const
PosStyles
(),
int
linesAfter
=
0
,
})
{
// Break text into lexemes
final
List
<
String
>
lexemes
=
[];
final
List
<
bool
>
isLexemeChinese
=
[];
bool
_isChinese
(
String
ch
)
{
return
ch
.
codeUnitAt
(
0
)
>
255
?
true
:
false
;
}
int
start
=
0
;
int
end
=
0
;
bool
curLexemeChinese
=
_isChinese
(
text
[
0
]);
for
(
var
i
=
1
;
i
<
text
.
length
;
++
i
)
{
if
(
curLexemeChinese
==
_isChinese
(
text
[
i
]))
{
end
+=
1
;
}
else
{
lexemes
.
add
(
text
.
substring
(
start
,
end
+
1
));
isLexemeChinese
.
add
(
curLexemeChinese
);
start
=
i
;
end
=
i
;
curLexemeChinese
=
!
curLexemeChinese
;
}
}
lexemes
.
add
(
text
.
substring
(
start
,
end
+
1
));
isLexemeChinese
.
add
(
curLexemeChinese
);
// Print each lexeme using codetable OR kanji
for
(
var
i
=
0
;
i
<
lexemes
.
length
;
++
i
)
{
_print
(
lexemes
[
i
],
styles:
styles
,
kanjiOff:
!
isLexemeChinese
[
i
],
);
}
_socket
.
writeln
();
emptyLines
(
linesAfter
);
reset
();
}
/// Print selected code table.
///
/// If [codeTable] is null, global code table is used.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment