-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
+: Add new method for set character's size. #273
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,36 @@ namespace ESCPOS_NET.Emitters | |
public abstract partial class BaseCommandEmitter : ICommandEmitter | ||
{ | ||
/* Character Commands */ | ||
/// <summary> | ||
/// Select print mode(s) | ||
/// </summary> | ||
/// <param name="style"></param> | ||
/// <returns></returns> | ||
public virtual byte[] SetStyles(PrintStyle style) => new byte[] { Cmd.ESC, Chars.StyleMode, (byte)style }; | ||
|
||
/// <summary> | ||
/// Select character size. Please reference <see cref="https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=34"/> | ||
/// Value from 0 to 7, 0 for normal size. | ||
/// </summary> | ||
/// <param name="widthMagnification">Enlargement in horizontal direction.</param> | ||
/// <param name="heightMagnification">Enlargement in vertical direction.</param> | ||
/// <returns></returns> | ||
public virtual byte[] SetSize(byte widthMagnification, byte heightMagnification) | ||
{ | ||
if (widthMagnification > 7) widthMagnification = 7; | ||
if (heightMagnification > 7) heightMagnification = 7; | ||
|
||
return [Cmd.GS, Chars.SizeMode, (byte)(widthMagnification * 0x10 + heightMagnification)]; | ||
} | ||
|
||
/// <summary> | ||
/// Select character size. Please reference <see cref="https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=34"/> | ||
/// Set both width and height magnification in same value. | ||
/// </summary> | ||
/// <param name="magnification">Enlargement in both horizontal and vertical direction.</param> | ||
/// <returns></returns> | ||
public virtual byte[] SetSize(byte magnification) => SetSize(magnification, magnification); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If new commands are introduced we need new Unit Tests, or at least include them in the Console Test Suite |
||
|
||
public virtual byte[] LeftAlign() => new byte[] { Cmd.ESC, Chars.Alignment, (byte)Align.Left }; | ||
|
||
public virtual byte[] CenterAlign() => new byte[] { Cmd.ESC, Chars.Alignment, (byte)Align.Center }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
{ | ||
public static class Chars | ||
{ | ||
public static readonly byte StyleMode = 0x21; | ||
public static readonly byte StyleMode = 0x21;/**ASCII Char: !*/ | ||
public static readonly byte SizeMode = StyleMode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if they are always the same, I don't see why use a new one just for SizeMode, let's keep using the StyleMode char also for the Size command |
||
public static readonly byte Alignment = 0x61; | ||
public static readonly byte ReversePrintMode = 0x42; | ||
public static readonly byte RightCharacterSpacing = 0x20; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we actually have enums for the magnification parameters? I see 7 is the maximum, but what is the minimum acceptable value for magnification? Does magnification = 1 means it's a regular-sized print?
Perhaps we want to add some validation, like the ones that exist for Barcode commands, in order to prevent users to use out of range magnification values. What do you think?