Virtual printer

Here you can discuss the development of patches.

Virtual printer

Postby Fizzban » 2004-2-15 @ 00:06

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
You do not have the required permissions to view the files attached to this post.
Last edited by Fizzban on 2004-2-15 @ 22:57, edited 2 times in total.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Fizzban » 2004-2-15 @ 12:39

Thanks.. :happyhappy:

BMP because SDL already has a "dump BMP image" function.. :)

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.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby mirekluza » 2004-2-15 @ 14:46

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
mirekluza
DOSBox Moderator
 
Posts: 1697
Joined: 2003-8-21 @ 04:19

Re: Virtual printer

Postby Fizzban » 2004-2-15 @ 16:05

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.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby mirekluza » 2004-2-15 @ 17:03

> Can you please give me some semigraphic symbols
Go to the PcWord documentation, file "keyboard.doc" and try to print the picture of keyboard which is there. The same goes for various big titles from the documentation.

Mirek
mirekluza
DOSBox Moderator
 
Posts: 1697
Joined: 2003-8-21 @ 04:19

Re: Virtual printer

Postby Fizzban » 2004-2-15 @ 23:07

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-2-17 @ 01:38, edited 2 times in total.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Fizzban » 2004-2-16 @ 19:03

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.. :lol:
Last edited by Fizzban on 2004-2-17 @ 01:38, edited 1 time in total.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby mirekluza » 2004-2-16 @ 19:25

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
mirekluza
DOSBox Moderator
 
Posts: 1697
Joined: 2003-8-21 @ 04:19

Re: Virtual printer

Postby Fizzban » 2004-2-16 @ 22:39

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..
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Fizzban » 2004-2-17 @ 01:37

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-2-17 @ 14:44, edited 1 time in total.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Stiletto » 2004-2-17 @ 02:02

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
User avatar
Stiletto
l33t
 
Posts: 4106
Joined: 2002-7-01 @ 21:57

Re: Virtual printer

Postby Fizzban » 2004-2-17 @ 03:04

Stiletto wrote: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! :happyhappy:
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Stiletto » 2004-2-17 @ 10:49

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
User avatar
Stiletto
l33t
 
Posts: 4106
Joined: 2002-7-01 @ 21:57

Re: Virtual printer

Postby Qbix » 2004-2-17 @ 10:57

I vote for a library :)
To make it easier maintanable.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10651
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Virtual printer

Postby Fizzban » 2004-2-17 @ 14:43

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-2-17 @ 23:50, edited 1 time in total.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Qbix » 2004-2-17 @ 15:13

hmmm not sure if it's a good idea to allow to host printing at all.
I think sticking to png in all cases is more approate.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10651
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Virtual printer

Postby Fizzban » 2004-2-17 @ 15:34

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

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.. :happyhappy:
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby Qbix » 2004-2-17 @ 15:43

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!
User avatar
Qbix
DOSBox Author
 
Posts: 10651
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Virtual printer

Postby Fizzban » 2004-2-17 @ 15:59

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.
User avatar
Fizzban
Newbie
 
Posts: 75
Joined: 2003-12-15 @ 10:36

Re: Virtual printer

Postby mirekluza » 2004-2-17 @ 18:34

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
mirekluza
DOSBox Moderator
 
Posts: 1697
Joined: 2003-8-21 @ 04:19

Next

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest