VOGONS

Common searches


Virtual printer

Topic actions

  • This topic is locked. You cannot reply or edit posts.

First post, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

I proudly present: The beta version of my dot-matrix printer emulation..

Main features:

  • Support for most ESC/P commands
  • Sans Serif, Roman, Courier and script font
  • Bold, italic, superscript, subscript, condensed, double-width, double-height
  • Different font sizes
  • Underline, strikethrough, overscore (single, double, broken score)
  • Bit graphics from 60x60 to 360x360 dpi

It does not emulate a specific printer but picking any 24-pin printer from EPSON should work.

The emulation uses Freetype2 and GPL'ed TrueType-fonts to "print" the text. It creates a surface in the main memory that acts as page. At the default settings, this is a 8.5''x11'' page at 360 dpi leading to a surface size of around 11.5 MB. This shouldn't be a problem but if you are low on RAM, try to reduce the dpi setting in dosbox.conf to 240 or 180 dpi.

Attached is a compiled version of the printer-enabled DOSBOX and its sources. If you want to compile it for yourself, you must download and install the FreeType2 library. The configure-script created by autogen.sh will automatically find and use it.

Currently, as soon as one page is done, it will be dumped as page.bmp in the DOSBOX directory. Of course, in the future I plan to send it directly to an actual printer.

EDIT: See my posting below for the files

Attachments

  • Filename
    page.png
    File size
    20.84 KiB
    Downloads
    734 downloads
    File license
    Fair use/fair dealing exception
Last edited by Fizzban on 2004-02-15, 22:57. Edited 2 times in total.

Reply 2 of 150, by mirekluza

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

I have tried to use the provided binary with the following results (three failures, one partiall success). But at least two of these failures are caused by the fact that DOSBOX does not support printing device (LPT1) - so it does not even get to printing.

Games
-----
Dungeon Hack
- printing of level map (there is button "Print" when map is shown)
- nothing, it just corrupted screen a bit, BMP was not generated

Bolo Adventures III
- choosing "Upgrade", "Registration", "Print Form"
- error "Device unavailable in module BOLO3 ..."
- it probably needs PRN or LPT1 device which is not in DOSBOX

Freeware/shareware wordprocessors
---------------------------------
Breeze
- error "Cannot open printer"
- in DOSBOX: "Warning: file creation failed: c:\dosbox\BREEZE\LPT1"

PcWord 1.90 (from TaliSoft)
- here I had a partiall success
- when using "print document" (I think ALT z) BMP file was generated. I just do not know how the program decided which page from the whole document will be prented (I would expect the first or the last one, but the PAGE.BMP contained something from the middle of the document)
- semigraphic symbols are not ok (national characters are printed instead)
- the attempt to use "print project" (ALT w) brutally crashed DOSBOX (SDL parachute ...). Sometimes I had to restart the whole computer (Windows 98 ), because any attempt to run any program ended with error that there is not enough memory.

Mirek

Reply 3 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

Thanks for tests, mirekluza..

Dungeon Hack isn't sending any data to printer, either. Also, in the debug window, I see a lot of "INT10:Unhandled mode 10 for scroll" error messages. Not sure what scrolling has to do with printing but this is probably corrupting the screen. I guess the game is also using LPT1 for printing so this seems to be a top-priority to get the printer working in most programs..

About PcWord: The printer creates page.bmp as soon as a page is full or the program sends a Form Feed. That's why you are getting something in the middle of the document. If you turn "Use form feed to terminate page" on in the printer settings, you will see the last page. I will add a hotkey that allow "ejection" of the currently printed page. There is unfortunally no way to automatically decide if the program is done with printing.

The program doesn't crash here if I try to print a project. Can you please give me some semigraphic symbols that don't work so I can take a closer look? The printer basically just send the ASCII chars to FreeType for rendering, I haven't implemented handling of self-defined characters or different charsets yet.

Reply 5 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

A few small updates:

  • Added support for different codepages. This solves the problem with semi-graphic symbols and allows printing of some foreign texts
  • For now, the key ALT-F8 is the "Eject current page" key. This forces DOSBOX to save the internal buffer to a BMP, then clear the page. Helps with programs that does not send a Form Feed after finishing with the print job.
  • Output now goes to page1.bmp, page2.bmp etc.
Last edited by Fizzban on 2004-02-17, 01:38. Edited 2 times in total.

Reply 6 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

Another small update:

  • Implemented the LPT1/PRN device and the DOS function "Print character".
  • Started to implement ESC/P2 commands

Breeze and Bolo Adventures III are now working nicely. Dungeon Hack isn't sending any data to the printer through any of the four available ways (BIOS, DOS, direct write to PORT, LPT device), so I guess the problem is the unhandeled scrolling command. Will try to debug that later..

Attached is the compiled version. Source code will follow later. With anon CVS down, I lost track of the changes I made.. 🤣

Last edited by Fizzban on 2004-02-17, 01:38. Edited 1 time in total.

Reply 7 of 150, by mirekluza

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

You are very quick ... 😀 I spent the whole day at work so I only now download the current version ...
Anyway, just a comment before any testing: If it works as you wrote then it starts to be already really usefull. I do not know how it is with possibility of platform independend printing, but even without that it could be usefull to have it in DOSBOX as it is now (making image files). There is just one thing which would have to be taken care off - using some other format instead of BMP (too big). I think that for screenshots "libpng" is used, perhaps you could use it as well.

Mirek

Reply 8 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie
mirekluza wrote:

There is just one thing which would have to be taken care off - using some other format instead of BMP (too big). I think that for screenshots "libpng" is used, perhaps you could use it as well.

Good suggestion.. I did a little Copy&Paste and the printer now outputs nice (and small) PNG images..

Reply 9 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

Next update:

  • Implemented virtually all ESC/P commands
  • Implemented most ESC/P2 commands
  • Page output is in PNG format now

The features that are now missing to get a complete emulation of a 48-pin EPSON matrix printer are the definition of own characters, raster and TIFF graphics and (maybe) colors..

Last edited by Fizzban on 2004-02-17, 14:44. Edited 1 time in total.

Reply 10 of 150, by Stiletto

User metadata
Rank l33t++
Rank
l33t++
Fizzban wrote:

Yes, there is no way to forward the data to the printer in an OS-indepent way. I'm currently looking for a GPL-library that has support for different OSes.

Great job!

If you want source to look at and not necessarily a library, I recomment the following projects:
UAE - Universal Amiga Emulator
Basilisk II - 68k Macintosh Emulator

I believe both of those have printer output code for Unix, Mac, and Win32 in their code. If you're interested, I'll find you the exact links.

"I see a little silhouette-o of a man, Scaramouche, Scaramouche, will you
do the Fandango!" - Queen

Stiletto

Reply 11 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie
Stiletto wrote:
If you want source to look at and not necessarily a library, I recomment the following projects: UAE - Universal Amiga Emulator […]
Show full quote

If you want source to look at and not necessarily a library, I recomment the following projects:
UAE - Universal Amiga Emulator
Basilisk II - 68k Macintosh Emulator

I believe both of those have printer output code for Unix, Mac, and Win32 in their code. If you're interested, I'll find you the exact links.

Yes, I am very interested! But I already found the URLs via Google so don't worry looking them up.. 😀

Thanks a lot of the tip! 😁

Reply 12 of 150, by Stiletto

User metadata
Rank l33t++
Rank
l33t++

No problem.

Of course, the Mac used a serial port for printing instead of a parallel port, but hopefully you should get some ideas. And this details what advanced features people are looking for in UAE's emulation. FWIW, I think this feature will be difficult to maintain. Good luck!

"I see a little silhouette-o of a man, Scaramouche, Scaramouche, will you
do the Fandango!" - Queen

Stiletto

Reply 14 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

Update: The newest version of the printer is able to send the data directly to an actual printer under Win32 (where this is easy to realize). For the other OSes, it will PNG output unless I find a good printing library.

The default output method is png image creation, direct printing needs to be set up in the dosbox.conf. DOSBOX will then display a print dialog as soon as you start printing.

Last edited by Fizzban on 2004-02-17, 23:50. Edited 1 time in total.

Reply 16 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

Mmh, host printing is surely one of the most tricky features of the virtual printer so just discarding it is a tempting idea.. 🤣

On the other hand, the support for Win32 is already there and it should work fine on all windows versions from Win98 on so I do really see the point to remove it. Printing under LINUX and MacOS is much harder, so I will not implement the support for now.

Yeah, I know, this may lead to questions like "Why is there no direct printing under my OS?" but we have the "It's open-source. If you want it, just implement it" answer for that.. 😁

Reply 17 of 150, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Q: Why isn't Virtual Printer support included in the CVS.

A: Adding printing directly to the printer will give a lot headaches.
(especially if the result isn't what they expect).
DosBox goal is to be an emulator with as little contact with the host hardware as possible so as to maintain compatibility across all platforms.

Water flows down the stream
How to ask questions the smart way!

Reply 18 of 150, by Fizzban

User metadata
Rank Newbie
Rank
Newbie

IMHO, the direct printing option isn't really hurting the emulation concept of DOSBOX.

Probably my description was misleading here: Even with direct printing on, the virtual printer does not directly forward the printer commands he gets to the actual printer. It still creates the page as image and after this is done, it just sends the bitmap to the printer.

Basically, this just adds a little comfort, so people don't have to take the PNGs, resize them and print them (nothing more is done by the direct printing option).

Trying to convert ESC/P(2) commands to commands the target printer understands would be madness. I never intended any kind of virtualization.

Reply 19 of 150, by mirekluza

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

IMHO the direct Windows printing is good (although I do not need it personally - I do not have printer). Occasionaly somebody complains here about not being able to do it.
It is possible to add big warning to config file/documentation that the output does need to be precisely as with the DOS printer.
Well, but I understand that people who use non-Windows system (as QBIX with Linux 😀 ) will complain. But it is probable that sooner or later somebody adds support for Linux as well.

Anyway, when it will be integrated into normal CVS? I usually compile CVS snapshot and I am too lazy to add patches to it 😀 😀 😀.
There is already one other addition which kept separately from regular CVS (MT-32 - legal problems with Roland).

Mirek