Here's my 60 cents worth. Note this is a long message, there is text
also after the code.
Here are my routines to print Euro characters on HP deskjet
series printers. First the soft font approach. It is presented
as a test program. You can edit it to produce the actual code
needed. For simplicity I have put the bitmaps of all the different
fonts in same array. You may of course edit it to include only
those that you need.
The bitmaps for following fonts are included:
Proportional 8 points
Proportional 10 points
Proportional 12 points
Fixed 12 points 10 Cpi portrait (a
Fixed 12 points 10 Cpi landscape (b
a) works also with 20 and 5 CPI (double width) as well as 6 points
b) works also with 20 CPI and 6 & 24 points (double height)
Note printing with 16.67 CPI is not directly supported. If you
20 CPI is used for the euro character. To compensate for this
Eur17 constant is defined, this prints euro (@ 20 CPI) and then
moves the print head to simulate 16.67 CPI. The result is pretty
good.
The widths of the proportional characters are 24, 30 and 36 dots
(1/300") respectively.
The bitmaps were obtained from HP www site and converted from
Laserjet to Deskjet with routines provided in Jetpak11.
If the printer does not support soft fonts, then a lower case e
is printed instead. Note, however, that the printer has to be
Deskjet (or HP in general) or unpredictable results can occur.
Note that you need to download the fonts only once after you
have turned the printer on though loading them more often does not
hurt.
After the euro character is printed the character set is reset
into the default one (as specified with the dip switches).
Eurosoft.pas:
--------------------------------------------------------------
Uses printer;
Const Asize=1589;
EuroArr:Array[1..ASize] of byte = (
{ Proportional 8 points, Font ID 1001 (49,48,48,49) }
{ Font ID }
27,42,99,49,48,48,49,68,27,41,115,49,49,51,87,0,72,5,0,0,0,0,48,0,
46,0,50,0,1,1,15,0,32,0,133,0,60,0,0,0,46,4,0,2,0,1,2,0,160,0,68,
0,32,0,127,0,85,170,160,255,255,255,255,69,117,114,111,32,83,105,
103,110,32,32,32,32,32,32,32,2,88,1,44,2,1,0,1,0,20,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,32,40,74,69,84,76,50,68,32,99,111,110,118,
101,114,115,105,111,110,41,32,27,42,99,49,48,49,69,27,40,115,49,
50,52,87,5,0,6,0,46,0,2,0,48,0,48,0,48,0,48,0,48,16,48,24,56,0,56,
0,56,0,56,0,56,0,120,0,120,0,120,0,120,0,120,0,120,0,120,0,56,0,
56,0,56,0,40,0,8,0,8,64,24,192,24,192,31,192,63,240,64,184,248,1,
64,2,152,220,7,24,198,6,24,199,12,24,195,12,24,195,24,24,193,128,
24,24,193,128,24,24,193,128,24,24,193,128,24,24,193,128,24,24,193,
128,24,24,193,128,12,24,131,12,24,3,14,16,7,7,14,2,27,42,99,53,70,
{ Proportional 10 points, Font ID 1002 }
27,42,99,49,48,48,50,68,27,41,115,49,49,51,87,0,72,5,0,0,0,0,47,0,
58,0,50,0,1,1,15,0,44,0,166,0,76,0,0,0,46,4,0,2,0,1,2,0,200,0,84,
0,32,0,127,0,170,170,160,255,255,255,255,69,117,114,111,32,83,105,
103,110,32,32,32,32,32,32,32,2,88,1,44,2,1,0,1,0,20,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,32,40,74,69,84,76,50,68,32,99,111,110,118,
101,114,115,105,111,110,41,32,27,42,99,49,48,49,69,27,40,115,49,
55,54,87,5,0,6,0,58,0,2,0,16,0,24,0,24,0,24,0,24,0,56,8,56,8,56,
40,56,40,56,32,60,0,60,0,60,0,60,0,124,0,124,0,124,0,124,0,124,0,
124,0,124,0,124,0,124,0,60,0,60,0,60,0,44,0,40,0,8,0,65,1,199,1,
199,1,199,1,255,3,255,192,4,11,255,224,20,43,199,240,16,8,101,199,
116,8,8,241,199,52,8,1,225,199,22,1,193,199,14,3,193,199,7,3,129,
199,7,7,129,199,7,128,7,1,199,3,128,7,1,199,3,128,7,1,199,3,128,7,
1,199,3,128,7,1,199,3,128,7,1,199,3,128,7,1,199,3,128,3,129,199,7,
128,3,129,196,7,3,129,192,15,1,193,192,14,1,225,30,240,60,96,27,
42,99,53,70,
{ Proportional 12 points, Font ID 1003 }
27,42,99,49,48,48,51,68,27,41,115,49,49,51,87,0,72,5,0,0,0,0,47,0,
68,0,50,0,1,1,15,0,52,0,200,0,88,0,0,0,46,4,0,2,0,2,3,0,240,0,100,
0,32,0,127,0,0,170,160,255,255,255,255,69,117,114,111,32,83,105,
103,110,32,32,32,32,32,32,32,2,88,1,44,5,2,1,2,0,20,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,32,40,74,69,84,76,50,68,32,99,111,110,118,
101,114,115,105,111,110,41,32,27,42,99,49,48,49,69,27,40,115,50,
50,50,87,5,0,6,0,68,0,4,0,24,0,24,0,24,0,24,0,24,0,24,24,24,60,60,
36,60,60,60,36,60,36,60,0,60,0,60,0,60,0,60,0,60,0,126,0,126,0,
126,0,126,0,126,0,126,0,126,0,126,0,126,0,60,0,60,0,44,0,44,0,44,
0,36,0,36,0,4,0,4,8,28,56,28,56,28,56,31,248,63,252,64,2,191,253,
1,64,2,128,2,188,61,64,1,128,6,92,58,96,8,128,1,16,23,28,56,232,8,
16,22,28,56,104,8,16,52,28,56,44,120,28,56,30,112,28,56,14,240,28,
56,15,224,28,56,7,224,28,56,7,1,192,28,56,3,128,1,192,28,56,3,128,
1,192,28,56,3,128,1,192,28,56,3,128,1,192,28,56,3,128,1,192,28,56,
3,128,1,192,28,56,3,128,1,192,28,56,3,128,1,224,28,56,7,128,224,
28,56,7,224,28,32,7,240,28,15,112,28,15,120,24,30,60,62,62,124,24,
27,42,99,53,70,
{ Fixed 10 CPI, Portrait, Font ID 1004 }
27,42,99,49,48,48,52,68,27,41,115,49,49,51,87,0,72,5,0,0,0,0,48,0,
58,0,50,0,0,1,15,0,120,0,166,0,76,0,0,0,46,4,0,2,0,1,2,0,200,0,
120,0,32,0,127,0,170,170,160,255,255,255,255,69,117,114,111,32,83,
105,103,110,32,32,32,32,32,32,32,2,88,1,44,2,1,0,1,0,20,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,32,40,74,69,84,76,50,68,32,99,111,110,
118,101,114,115,105,111,110,41,32,27,42,99,49,48,49,69,27,40,115,
49,55,54,87,5,0,6,0,58,0,2,0,16,0,24,0,24,0,24,0,24,0,56,8,56,8,
56,40,56,40,56,32,60,0,60,0,60,0,60,0,124,0,124,0,124,0,124,0,124,
0,124,0,124,0,124,0,124,0,60,0,60,0,60,0,44,0,40,0,8,0,65,1,199,1,
199,1,199,1,255,3,255,192,4,11,255,224,20,43,199,240,16,8,101,199,
116,8,8,241,199,52,8,1,225,199,22,1,193,199,14,3,193,199,7,3,129,
199,7,7,129,199,7,128,7,1,199,3,128,7,1,199,3,128,7,1,199,3,128,7,
1,199,3,128,7,1,199,3,128,7,1,199,3,128,7,1,199,3,128,3,129,199,7,
128,3,129,196,7,3,129,192,15,1,193,192,14,1,225,30,240,60,96,27,
42,99,53,70,
{ Fixed 10 CPI, Landscape, Font ID 1010 }
27,42,99,49,48,49,48,68,27,41,115,49,49,51,87,0,72,9,0,0,0,0,29,0,
29,0,58,1,0,1,15,0,120,0,200,0,88,0,0,0,46,244,2,2,0,246,3,0,240,
0,120,0,32,0,127,0,0,146,96,255,255,255,255,69,117,114,111,32,83,
105,103,110,32,77,111,110,111,32,32,2,88,1,44,249,2,245,2,0,20,0,
0,0,0,0,0,0,0,0,0,0,0,0,58,0,0,0,0,32,40,74,69,84,76,50,68,32,99,
111,110,118,101,114,115,105,111,110,41,32,27,42,99,49,48,49,69,27,
40,115,49,53,54,87,9,0,6,0,58,0,0,0,6,6,6,7,7,7,7,7,13,4,13,0,13,
0,8,0,8,0,8,0,15,0,15,0,15,0,8,0,8,0,8,0,14,0,14,0,14,0,8,0,8,0,8,
0,8,4,12,5,13,5,5,7,7,7,7,6,6,0,31,128,32,64,223,176,1,32,72,2,
207,180,5,48,72,10,64,38,5,128,17,26,10,128,5,28,2,192,8,1,192,
224,224,112,3,255,255,252,1,255,255,252,1,255,255,252,112,112,112,
255,255,252,127,255,252,127,255,252,112,224,224,192,1,2,192,8,5,4,
10,128,2,4,13,57,2,128,66,5,127,180,2,128,72,1,127,144,128,32,127,
192,27,42,99,53,70
);
Procedure DownloadEuros;
var i:integer;
Begin
for i:=1 to Asize do Write(lst,chr(EuroArr[i]));
End;
Const Eur=#27'(8Oe'#27'(0@';
Eur17=Eur+#27'*p+3X'; { a dirty fix to use 20 CPI euro char with
16.67 cpi }
Procedure CheckPitch;
var i:integer;
Begin
for i:=1 to 20 do Write(lst,Eur);
Writeln(lst);
for i:=1 to 20 do Write(lst,'=');
Writeln(lst);
End;
Procedure CheckPitch17;
var i:integer;
Begin
for i:=1 to 20 do Write(lst,Eur17);
Writeln(lst);
for i:=1 to 20 do Write(lst,'=');
Writeln(lst);
End;
Procedure TestFixed;
var i:integer;
begin
for i:=1 to 2 do begin
Write(lst,#27'(s0p10H');
Writeln(lst,'Fixed 10 CPI: 500 ',eur,'.');
Checkpitch;
Writeln(lst);
Write(lst,#27'(s0p20H');
Writeln(lst,'Fixed 20 CPI: 500 ',eur,'.');
Checkpitch;
Writeln(lst);
Write(lst,#27'(s0p16.67H');
Writeln(lst,'Fixed 16.67 CPI: 500 ',eur17,'.');
Checkpitch17;
Writeln(lst);
{ Note the difference in the code above }
Write(lst,#27'(s0p5H');
Writeln(lst,'Fixed 5 CPI: 500 ',eur,'.');
Checkpitch;
Writeln(lst);
Write(lst,#27'(s6V'#27'&l4C');
End;
Write(lst,#27'(s12V'#27'&l8C');
End;
Begin
Writeln('Start');
DownloadEuros;
Write(lst,#27'(s0p10h12V'#27'&a7L');
TestFixed;
Writeln(lst,#27'(s1p8V');
Writeln(lst,'Proportional 8 points: 500 ',eur,'.');
Writeln(lst);
Write(lst,#27'(s1p10V');
Writeln(lst,'Proportional 10 points: 500 ',eur,'.');
Writeln(lst);
Write(lst,#27'(s1p12V');
Writeln(lst,'Proportional 12 points: 500 ',eur,'.');
Writeln(lst);
Write(lst,#27'&l1O'); { landscape }
TestFixed;
Writeln(lst,#27'(s0p10h24V'#27'&l16C');
Writeln(lst,'Fixed 10 CPI, 24 points: 500 ',eur,'.');
Checkpitch;
Writeln(lst);
Write(lst,#27'E'); { Reset the printer }
Writeln('End');
end.
-----------------------------------------------------------------------
Now to the graphics approach. It is provided as a more ready to use
unit as well as a test program. This method supports only fixed pitch
with either 10 or 16.67 CPI and only in portrait orientation. You,
however, could try it with other fonts also, like proportional, if you
have exact width tables as with graphics one has to specify the
position of each euro symbol.
Note that the printing goes about one line lower in the paper than
normally with Writeln(lst,...), therefore it is advised to use these
routines to construct the whole page. Otherwise you might end with
gaps and lines on top of each other.
The routine provides two alternative interfaces, one can either
print a line at a time by using some symbol to mark euros (like \e),
or one could manually specify where the euro symbols (up to 100
per line) are put and where text items are put and then print the
line separately. The latter is more versatile as one can include
control codes for bold, italics etc. (no specific support for
those codes is provided, look at the manual)
Note one cannot mix normal and compressed euro characters
in same line.
If you have TP before 7.0, remove the consts from parameters as
older versions do not support constant parameters.
EuroDJ.pas
-----------------------------------------------------------------
{ This unit allows printing of
...