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

ESC Epson printer language support #470

Open
ysard opened this issue Feb 20, 2025 · 2 comments
Open

ESC Epson printer language support #470

ysard opened this issue Feb 20, 2025 · 2 comments

Comments

@ysard
Copy link

ysard commented Feb 20, 2025

Hello, I'm currently studying your code for emulating the Epson ESC/P
to compare it with my own project (https://github.com/ysard/escapy).
PS: I find your way of implementing dot intensity in Draft / NLQ mode very elegant ;)

I've found 3 things that sound curious about ESC commands
(I suppose we're both using the Epson ESC/P Reference Manual from December 1997 (?)).

  • ESC D for tabs definition is supposed to end with a NULL byte, not 0x01.
    It's a variable-size command with up to 32 possible values; the last character is an end marker.

    Concerned line:

    printf("\x1b\x44\x03\x05\x07\x09\x0b\x0d\x0f\x11\x13\x15\x17\x19\x1B\x1D\x1F\x21\x23\x01");

  • ESC R and ESC I:
    The epson doc specifies that the accepted parameters are 0 or 1, not 0, 1, 48, 49 (decimal values of “0” and “1”).
    Here I'm uncertain whether 48 and 49 should be supported but when it is the case for other commands,
    the documentation is precise on this subject (e.g. ESC t).

    However, you're using the values of “0” and “1” here:

    printf("\x1b" "R" "0");

    #define EXTENDED_ON "\x1b" "I1"
    #define EXTENDED_OFF "\x1b" "I0"

  • You don't exit from the condensed mode explicitly prior to the PICA/ESC P commands, which set the character pitch to 1/10.
    Exiting condensed mode would actually have resulted in a return to 1/10 pitch.
    In my program, this is equivalent to remaining in condensed mode but with character pitch at 1/10
    (for me, condensed mode is a boolean independent of character pitch), the render is obviously wrong on my side.
    How do you think the programs of the time behaved on this point (explicit exit or not?)?

    printf("CONDENSED"
    PICA POS_C20 CONDENSE "Draft Regular"
    PICA POS_C40 CONDENSE ITALIC_ON "Draft Italic" ITALIC_OFF
    PICA POS_C60 CONDENSE NLQ_ON "Near Letter Quality" NLQ_OFF
    PICA "\n\r");

Unfortunately I don't have access to a real machine to test these hypotheses...
Did you test the rendering of your test code on a real printer?

Thanks for reading.

@rgc2000
Copy link
Contributor

rgc2000 commented Feb 20, 2025

Hi, I am the author of the virtual printer in Ultimate devices and I will process your query.
I don't have an EPSON printer but I have a Commodore MPS-1230 printer that can be configured to use EPSON commands. This is why I implemented the EPSON commands. As the main document, I used the MPS-1230 reference manual to implement all documented EPSON commands. There may be errors in the Commodore MPS-1230 Reference Manual.

You can take a look at the virtual printer documentation. All implemented ESC codes are documented for each instruction set. https://github.com/GideonZ/1541ultimate/blob/master/doc/ultimate_printer.pdf

  • ESC D : I will check this, EPSON code is expecting 0 as end of tab definition, so this may be an error in the epsontest.c file
  • ESC R and ESC I : It is my personal decision to accept the values ​​0 and 1 as well as the characters "0" and "1" because it was not clear in the documentation. I thought it wouldn't hurt (and it is easier to test).
  • condensed mode : According to EPSON documentation, ESC P restores the Pica print pitch (10 chars/inch) but does not clear the condensed or doublewidth modes. It looks like this is no the beahviour of my implementation where condensed mode is cleared (but not doublewidth mode). So maybe I have to change this but this will be a bit painfull as condensed is a pitch and not a mode in my code.

@ysard
Copy link
Author

ysard commented Feb 20, 2025

Thank you for your prompt reply; indeed, documentation can be lax by omission on certain points.
It would be ideal to see how ESC programs behave on real machines, but here again, implementations can vary greatly from model to model, especially before the ESC/P and ESC/P2 standards.

For ESC D, the docs seem uniform. Parsing stops when a value smaller than the previous one is encountered, but the null character is still required.

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