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
30793c63
Commit
30793c63
authored
Jun 12, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8 text sizes for height and width
parent
35f1a446
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
example.dart
example/example.dart
+2
-0
printer.dart
lib/src/printer.dart
+17
-15
No files found.
example/example.dart
View file @
30793c63
...
...
@@ -11,6 +11,8 @@ main() {
printer
.
println
(
'Align left'
,
align:
PosTextAlign
.
left
);
printer
.
println
(
'Align center'
,
align:
PosTextAlign
.
center
);
printer
.
println
(
'Align right'
,
align:
PosTextAlign
.
right
);
printer
.
println
(
'Text size 2'
,
height:
PosTextSize
.
size2
,
width:
PosTextSize
.
size2
);
printer
.
cut
();
...
...
lib/src/printer.dart
View file @
30793c63
...
...
@@ -5,18 +5,20 @@ import 'commands.dart';
enum
PosTextAlign
{
left
,
center
,
right
}
enum
PosCutMode
{
normal
,
partial
,
full
}
class
PosTextSizeHeight
{
final
value
;
const
PosTextSizeHeight
.
_internal
(
this
.
value
);
static
const
normal
=
const
PosTextSizeHeight
.
_internal
(
0x00
);
static
const
double
=
const
PosTextSizeHeight
.
_internal
(
0x10
);
}
class
PosTextSize
{
final
int
value
;
const
PosTextSize
.
_internal
(
this
.
value
);
static
const
size1
=
const
PosTextSize
.
_internal
(
1
);
static
const
size2
=
const
PosTextSize
.
_internal
(
2
);
static
const
size3
=
const
PosTextSize
.
_internal
(
3
);
static
const
size4
=
const
PosTextSize
.
_internal
(
4
);
static
const
size5
=
const
PosTextSize
.
_internal
(
5
);
static
const
size6
=
const
PosTextSize
.
_internal
(
6
);
static
const
size7
=
const
PosTextSize
.
_internal
(
7
);
static
const
size8
=
const
PosTextSize
.
_internal
(
8
);
class
PosTextSizeWidth
{
final
value
;
const
PosTextSizeWidth
.
_internal
(
this
.
value
);
static
const
normal
=
const
PosTextSizeWidth
.
_internal
(
0x00
);
static
const
double
=
const
PosTextSizeWidth
.
_internal
(
0x20
);
static
int
decSize
(
PosTextSize
height
,
PosTextSize
width
)
=>
16
*
(
width
.
value
-
1
)
+
(
height
.
value
-
1
);
}
/// Abstract printer.
...
...
@@ -62,8 +64,8 @@ class Printer {
bool
reverse
=
false
,
bool
underline
=
false
,
PosTextAlign
align
=
PosTextAlign
.
left
,
PosTextSize
Height
height
=
PosTextSizeHeight
.
normal
,
PosTextSize
Width
width
=
PosTextSizeWidth
.
normal
,
PosTextSize
height
=
PosTextSize
.
size1
,
PosTextSize
width
=
PosTextSize
.
size1
,
int
linesAfter
=
0
,
})
{
_socket
.
write
(
bold
?
cBoldOn
:
cBoldOff
);
...
...
@@ -73,10 +75,10 @@ class Printer {
?
cAlignLeft
:
(
align
==
PosTextAlign
.
center
?
cAlignCenter
:
cAlignRight
));
//
Fon
t size
//
Tex
t size
_socket
.
add
(
Uint8List
.
fromList
(
List
.
from
(
cSize
ESCn
.
codeUnits
)..
add
(
height
.
value
+
width
.
value
),
List
.
from
(
cSize
GSn
.
codeUnits
)..
add
(
PosTextSize
.
decSize
(
height
,
width
)
),
),
);
...
...
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