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

Possible to print more font sizes between 1x and 2x #6

Open
TidemannNorli opened this issue Mar 29, 2021 · 1 comment
Open

Possible to print more font sizes between 1x and 2x #6

TidemannNorli opened this issue Mar 29, 2021 · 1 comment

Comments

@TidemannNorli
Copy link

Hi, I was wondering if it is possible to print more text sizes between 1x and 2x with the correct aspect ratio.

The font size steps are extremely big.
2x font size (^^^) is about as big as I will ever print. Therefore it would be really nice to be able to print 1.5x

Could I achieve this by setting the default text size to 0.5x?

Then I would have the following result:
(none) = 0.5x
^^^ = 1x
^^^^ = 1.5x
^^^^^ = 2x
^^^^^^ = 2.5x
^^^^^^^ = 3x

Where in the code can I change this? I tried setting "textScale" to 0.5x but with no luck

Optimally I would want the following font sizes:
1x
1.25x
1.5x
1.75x
2x
2.5x
3x

Do you have support for this, or any tips?

Thanks

@receiptline
Copy link
Owner

Hello!

Yes, the character sizes in receiptline are a bit strange compared to modern technology.
However, 50-year-old technology such as double width and double height characters are still in use in receipt printers.

So I will tell you how to modify receiptline.js to your desired specifications.
This will only work for SVG output.

If you want to print this SVG, convert it to PNG and then convert it to a printer command.
See example receipt/en_print_svg.js.

Line 592:

// w = printer.command.measureText(text[j], printer.encoding) * (wh < 2 ? wh + 1 : wh - 1);
w = printer.command.measureText(text[j], printer.encoding) * [ 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5 ][wh];

Line 608:

// height = Math.max(height, wh < 3 ? wh : wh - 1);
height = Math.max(height, [ 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5 ][wh]);

Line 1016-1017:

// const w = wh < 2 ? wh + 1 : wh - 1;
// const h = wh < 3 ? wh : wh - 1;
const w = [ 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5 ][wh];
const h = w;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants