1
/* $Xorg: PclText.c,v 1.5 2001/03/06 16:28:48 pookie Exp $ */
2
/*******************************************************************
4
** *********************************************************
9
** * Character-drawing routines for the PCL DDX
11
** * Created: 10/23/95
13
** *********************************************************
15
********************************************************************/
17
(c) Copyright 1996 Hewlett-Packard Company
18
(c) Copyright 1996 International Business Machines Corp.
19
(c) Copyright 1996 Sun Microsystems, Inc.
20
(c) Copyright 1996 Novell, Inc.
21
(c) Copyright 1996 Digital Equipment Corp.
22
(c) Copyright 1996 Fujitsu Limited
23
(c) Copyright 1996 Hitachi, Ltd.
25
Permission is hereby granted, free of charge, to any person obtaining a copy
26
of this software and associated documentation files (the "Software"), to deal
27
in the Software without restriction, including without limitation the rights
28
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
copies of the Software, and to permit persons to whom the Software is
30
furnished to do so, subject to the following conditions:
32
The above copyright notice and this permission notice shall be included in
33
all copies or substantial portions of the Software.
35
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
Except as contained in this notice, the names of the copyright holders shall
43
not be used in advertising or otherwise to promote the sale, use or other
44
dealings in this Software without prior written authorization from said
47
/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclText.c,v 1.10tsi Exp $ */
49
#ifdef HAVE_DIX_CONFIG_H
50
#include <dix-config.h>
53
#ifdef DO_TWO_BYTE_PCL
55
#endif /* DO_TWO_BYTE_PCL */
57
#include "windowstr.h"
61
#include <X11/Xatom.h>
63
#include "PclSFonts.h"
65
static PclFontHead8Ptr makeFontHeader8 (FontPtr, PclSoftFontInfoPtr);
66
static PclFontHead16Ptr makeFontHeader16(FontPtr, PclSoftFontInfoPtr);
67
static PclInternalFontPtr makeInternalFont(FontPtr, PclSoftFontInfoPtr);
68
static void fillFontDescData(FontPtr, PclFontDescPtr, unsigned int);
69
static PclCharDataPtr fillCharDescData(PclCharDataPtr, CharInfoPtr);
70
static void output_text(FILE *, PclContextPrivPtr, unsigned char);
71
static char * getFontName(FontPtr);
72
static char isInternal(FontPtr);
73
static void selectInternalFont(FILE *, PclInternalFontPtr, int);
74
static void selectSize(FILE *, PclContextPrivPtr, PclInternalFontPtr);
77
#ifdef DO_TWO_BYTE_PCL
78
static void code_conv(PclSoftFontInfoPtr, FontPtr, char *, char *);
79
#endif /* DO_TWO_BYTE_PCL */
85
#define DOWNLOAD_FONT 0
86
#define INTERNAL_FONT 1
90
DrawablePtr pDrawable,
98
PclContextPrivPtr pConPriv;
101
CharInfoPtr charinfo[255], *chinfo;
104
PclSoftFontInfoPtr pSoftFontInfo;
105
PclFontHead8Ptr pfh8 = (PclFontHead8Ptr)NULL;
106
PclInternalFontPtr pin = (PclInternalFontPtr)NULL;
109
unsigned char last_fid;
110
int max_ascent, max_descent;
115
RegionPtr drawRegion, region;
118
if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
121
GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
122
Linear8Bit, &n, charinfo);
126
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
127
pConPriv = (PclContextPrivPtr)
128
pCon->devPrivates[PclContextPrivateIndex].ptr;
129
pSoftFontInfo = pConPriv->pSoftFontInfo;
130
font_type = isInternal(pGC->font);
131
if ( font_type == DOWNLOAD_FONT ) {
133
* Create Soft Font Header Information
135
pfh8 = makeFontHeader8(pGC->font, pSoftFontInfo);
140
* exec Soft Font Downloading
142
p = (unsigned char *)string;
143
for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
144
if ( !pfh8->index[*p] ) {
145
fillCharDescData(&cd, *chinfo);
146
PclDownloadSoftFont8(pConPriv->pJobFile, pSoftFontInfo,
148
xfree(cd.raster_top);
155
MACRO_START( outFile, pConPriv );
156
sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
157
x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
159
SAVE_PCL( outFile, pConPriv, t );
160
SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
164
max_ascent = charinfo[0]->metrics.ascent;
165
max_descent = charinfo[0]->metrics.descent;
166
p = (unsigned char *)string;
167
for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
168
if ( last_fid != pfh8->fid ) {
169
sprintf(t, "%c;FI%d;SS;LB", ETX, pfh8->fid);
170
SAVE_PCL( outFile, pConPriv, t );
172
last_fid = pfh8->fid;
175
output_text(outFile, pConPriv, pfh8->index[*p]);
177
w += (*chinfo)->metrics.characterWidth;
178
max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
179
max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
182
sprintf(t, "%c", ETX);
183
SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
184
sprintf(t, "TD0;\033%%1A");
185
SAVE_PCL( outFile, pConPriv, t );
186
MACRO_END( outFile );
191
pin = makeInternalFont(pGC->font, pSoftFontInfo);
195
selectInternalFont(outFile, pin, fid);
200
MACRO_START( outFile, pConPriv );
201
sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
202
x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
204
SAVE_PCL( outFile, pConPriv, t );
205
selectSize(outFile, pConPriv, pin);
206
SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
209
max_ascent = charinfo[0]->metrics.ascent;
210
max_descent = charinfo[0]->metrics.descent;
211
p = (unsigned char *)string;
212
for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
213
output_text(outFile, pConPriv, *p);
215
w += (*chinfo)->metrics.characterWidth;
216
max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
217
max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
219
sprintf(t, "%c", ETX);
220
SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
221
sprintf(t, "TD0;\033%%1A");
222
SAVE_PCL( outFile, pConPriv, t );
223
MACRO_END( outFile );
227
* Convert the collection of rectangles into a proper region, then
228
* intersect it with the clip region.
230
box.x1 = x + pDrawable->x;
231
box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
232
box.x2 = x + w + pDrawable->x;
233
box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
235
drawRegion = miRegionCreate( &box, 0 );
236
region = miRegionCreate( NULL, 0 );
237
miIntersect( region, drawRegion, pGC->pCompositeClip );
240
* For each rectangle in the clip region, set the HP-GL/2 "input
241
* window" and render the entire polyline to it.
243
pbox = REGION_RECTS( region );
244
nbox = REGION_NUM_RECTS( region );
246
PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
249
* Clean up the temporary regions
251
REGION_DESTROY( pGC->pScreen, drawRegion );
252
REGION_DESTROY( pGC->pScreen, region );
259
DrawablePtr pDrawable,
264
unsigned short *string)
267
PclContextPrivPtr pConPriv;
270
CharInfoPtr charinfo[255], *chinfo;
273
PclSoftFontInfoPtr pSoftFontInfo;
274
PclFontHead16Ptr pfh16 = (PclFontHead16Ptr)NULL;
277
unsigned char row, col;
279
unsigned char last_fid;
280
int max_ascent, max_descent;
286
RegionPtr drawRegion, region;
289
if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
292
GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
293
(FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
296
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
297
pConPriv = (PclContextPrivPtr)
298
pCon->devPrivates[PclContextPrivateIndex].ptr;
299
pSoftFontInfo = pConPriv->pSoftFontInfo;
301
font_type = isInternal(pGC->font);
302
if ( font_type == DOWNLOAD_FONT ) {
304
* Create Soft Font Header Information
306
pfh16 = makeFontHeader16(pGC->font, pSoftFontInfo);
311
* exec Soft Font Downloading
313
pfi = (FontInfoRec *)&pGC->font->info;
315
for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
318
if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
319
&& (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
320
row = row - pfi->firstRow;
321
col = col - pfi->firstCol;
323
def = pfi->defaultCh;
324
row = ((def>>8)&0xff) - pfi->firstRow;
325
col = (def&0xff) - pfi->firstCol;
327
if ( !pfh16->index[row][col].fid ) {
328
fillCharDescData(&cd, *chinfo);
329
PclDownloadSoftFont16(pConPriv->pJobFile, pSoftFontInfo,
330
pfh16, &cd, row, col);
331
xfree(cd.raster_top);
338
MACRO_START( outFile, pConPriv );
339
sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
340
x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
342
SAVE_PCL( outFile, pConPriv, t );
343
SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
348
max_ascent = charinfo[0]->metrics.ascent;
349
max_descent = charinfo[0]->metrics.descent;
350
for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
353
if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
354
&& (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
355
row = row - pfi->firstRow;
356
col = col - pfi->firstCol;
358
def = pfi->defaultCh;
359
row = ((def>>8)&0xff) - pfi->firstRow;
360
col = (def&0xff) - pfi->firstCol;
362
if ( last_fid != pfh16->index[row][col].fid ) {
363
sprintf(t, "%cFI%d;SS;LB",
364
ETX, pfh16->index[row][col].fid);
365
SAVE_PCL( outFile, pConPriv, t );
366
last_fid = pfh16->index[row][col].fid;
369
output_text(outFile, pConPriv, pfh16->index[row][col].cindex);
371
w += (*chinfo)->metrics.characterWidth;
372
max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
373
max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
375
sprintf(t, "%c", ETX);
376
SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
377
sprintf(t, "TD0;\033%%1A");
378
SAVE_PCL( outFile, pConPriv, t );
379
MACRO_END( outFile );
382
#ifdef DO_TWO_BYTE_PCL
383
PclInternalFontPtr pin;
386
pin = makeInternalFont(pGC->font, pSoftFontInfo);
390
selectInternalFont(outFile, pin, fid);
391
fprintf(outFile, "%c&t31P", ESC);
396
MACRO_START( outFile, pConPriv );
397
sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
398
x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
400
SAVE_PCL( outFile, pConPriv, t );
401
sprintf(t, "TD0;\033%%1A");
402
SAVE_PCL( outFile, pConPriv, t );
406
max_ascent = charinfo[0]->metrics.ascent;
407
max_descent = charinfo[0]->metrics.descent;
408
for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
410
code_conv(pSoftFontInfo, pGC->font, (char *)p, tobuf);
411
fprintf(outFile, "%c%c", tobuf[0], tobuf[1]);
413
w += (*chinfo)->metrics.characterWidth;
414
max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
415
max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
417
MACRO_END( outFile );
420
#endif /* DO_TWO_BYTE_PCL */
424
* Convert the collection of rectangles into a proper region, then
425
* intersect it with the clip region.
427
box.x1 = x + pDrawable->x;
428
box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
429
box.x2 = x + w + pDrawable->x;
430
box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
432
drawRegion = miRegionCreate( &box, 0 );
433
region = miRegionCreate( NULL, 0 );
434
miIntersect( region, drawRegion, pGC->pCompositeClip );
437
* For each rectangle in the clip region, set the HP-GL/2 "input
438
* window" and render the entire polyline to it.
440
pbox = REGION_RECTS( region );
441
nbox = REGION_NUM_RECTS( region );
443
PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
446
* Clean up the temporary regions
448
REGION_DESTROY( pGC->pScreen, drawRegion );
449
REGION_DESTROY( pGC->pScreen, region );
456
DrawablePtr pDrawable,
466
DrawablePtr pDrawable,
471
unsigned short *string)
477
DrawablePtr pDrawable,
480
unsigned int nGlyphs,
481
CharInfoPtr *pCharInfo,
488
DrawablePtr pDrawable,
491
unsigned int nGlyphs,
492
CharInfoPtr *pCharInfo,
497
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
498
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
500
static PclFontHead8Ptr
501
makeFontHeader8(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
503
PclFontHead8Ptr phead8 = pSoftFontInfo->phead8;
504
PclFontHead8Ptr pfh8 = phead8;
505
PclFontHead8Ptr prev = (PclFontHead8Ptr)NULL;
508
unsigned char nindex;
511
CharInfoPtr charinfo[1];
512
unsigned int space_width;
514
if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
515
return (PclFontHead8Ptr)NULL;
518
* Verify it has already been created, if so, return it.
520
if ( (fontname = getFontName(pfont)) == (char *)NULL)
521
return (PclFontHead8Ptr)NULL;
523
while (pfh8 != (PclFontHead8Ptr) NULL) {
524
if (!strcmp(pfh8->fontname, fontname))
531
* Create Font Header Information
533
pfh8 = (PclFontHead8Ptr)xalloc(sizeof(PclFontHead8Rec));
534
if (pfh8 == (PclFontHead8Ptr)NULL)
535
return (PclFontHead8Ptr)NULL;
537
pfi = (FontInfoRec *)&pfont->info;
538
GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
539
Linear8Bit, &n, charinfo);
541
space_width = charinfo[0]->metrics.characterWidth;
543
space_width = FONTMAXBOUNDS(pfont,characterWidth);
545
fillFontDescData(pfont, &(pfh8->fd), space_width);
547
pfh8->fontname = (char *)xalloc(strlen(fontname) + 1);
548
if (pfh8->fontname == (char *)NULL) {
550
return (PclFontHead8Ptr) NULL;
552
strcpy(pfh8->fontname, fontname);
555
pfh8->index = (unsigned char *)xalloc(nindex);
556
if ( pfh8->index == (unsigned char *) NULL ) {
557
xfree(pfh8->fontname);
559
return (PclFontHead8Ptr) NULL;
562
for (i=0; i<=nindex; i++)
563
pfh8->index[i] = 0x0;
565
pfh8->next = (PclFontHead8Ptr)NULL;
567
if ( prev == (PclFontHead8Ptr) NULL)
568
pSoftFontInfo->phead8 = pfh8;
575
static PclFontHead16Ptr
576
makeFontHeader16(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
578
PclFontHead16Ptr phead16 = pSoftFontInfo->phead16;
579
PclFontHead16Ptr pfh16 = phead16;
580
PclFontHead16Ptr prev = (PclFontHead16Ptr)NULL;
581
PclFontMapRec ** index;
584
unsigned char nindex_row, nindex_col;
587
CharInfoPtr charinfo[1];
588
unsigned int space_width;
590
if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
591
return (PclFontHead16Ptr)NULL;
594
* Verify it has already been created, if so, return it.
596
if ( (fontname = getFontName(pfont)) == (char *)NULL)
597
return (PclFontHead16Ptr)NULL;
599
while (pfh16 != (PclFontHead16Ptr) NULL) {
600
if (!strcmp(pfh16->fontname, fontname))
607
* Create Font Header Information
609
pfh16 = (PclFontHead16Ptr)xalloc(sizeof(PclFontHead16Rec));
610
if (pfh16 == (PclFontHead16Ptr)NULL)
611
return (PclFontHead16Ptr)NULL;
613
pfi = (FontInfoRec *)&pfont->info;
614
GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
615
(FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit,
619
space_width = charinfo[0]->metrics.characterWidth;
621
space_width = FONTMAXBOUNDS(pfont,characterWidth);
623
fillFontDescData(pfont, &(pfh16->fd), space_width);
625
pfh16->cur_cindex = 0;
626
pfh16->fontname = (char *)xalloc(strlen(fontname) + 1);
627
if (pfh16->fontname == (char *)NULL) {
629
return (PclFontHead16Ptr) NULL;
631
strcpy(pfh16->fontname, fontname);
633
pfi = (FontInfoRec *)&pfont->info;
634
nindex_col = pfi->lastCol - pfi->firstCol + 1;
635
nindex_row = pfi->lastRow - pfi->firstRow + 1;
636
index = (PclFontMapRec **)xalloc(sizeof(PclFontMapRec *)*nindex_row);
637
if (index == (PclFontMapRec **)NULL) {
638
xfree(pfh16->fontname);
640
return (PclFontHead16Ptr) NULL;
642
for (i=0; i<nindex_row; i++) {
643
index[i] = (PclFontMapRec *)xalloc(sizeof(PclFontMapRec)*nindex_col);
644
if (index[i] == (PclFontMapRec *)NULL) {
647
xfree(pfh16->fontname);
649
return (PclFontHead16Ptr) NULL;
651
for (j=0; j<=nindex_col; j++)
652
index[i][j].fid = 0x0;
655
pfh16->index = index;
656
pfh16->firstCol = pfi->firstCol;
657
pfh16->lastCol = pfi->lastCol;
658
pfh16->firstRow = pfi->firstRow;
659
pfh16->lastRow = pfi->lastRow;
660
pfh16->next = (PclFontHead16Ptr)NULL;
662
if ( prev == (PclFontHead16Ptr) NULL)
663
pSoftFontInfo->phead16 = pfh16;
670
static PclInternalFontPtr
671
makeInternalFont(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
673
PclInternalFontPtr pinfont = pSoftFontInfo->pinfont;
674
PclInternalFontPtr pin = pinfont;
675
PclInternalFontPtr prev = (PclInternalFontPtr)NULL;
679
Atom xa_pcl_font_name, xa_res, xa_ave_width, xa_spacing;
684
if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
685
return (PclInternalFontPtr)NULL;
688
* Verify it has already been created, if so, return it.
690
if ( (fontname = getFontName(pfont)) == (char *)NULL)
691
return (PclInternalFontPtr)NULL;
693
while (pin != (PclInternalFontPtr) NULL) {
694
if (!strcmp(pin->fontname, fontname))
701
* Create Internal Font Information
703
pin = (PclInternalFontPtr)xalloc(sizeof(PclInternalFontRec));
704
if (pin == (PclInternalFontPtr)NULL)
705
return (PclInternalFontPtr)NULL;
707
pin->fontname = (char *)xalloc(strlen(fontname) + 1);
708
if (pin->fontname == (char *)NULL) {
710
return (PclInternalFontPtr) NULL;
712
strcpy(pin->fontname, fontname);
714
xa_pcl_font_name = MakeAtom("PCL_FONT_NAME", strlen("PCL_FONT_NAME"), TRUE);
715
xa_res = MakeAtom("RESOLUTION_X", strlen("RESOLUTION_X"), TRUE);
716
xa_ave_width = MakeAtom("AVERAGE_WIDTH", strlen("AVERAGE_WIDTH"), TRUE);
717
xa_spacing = MakeAtom("SPACING", strlen("SPACING"), TRUE);
718
pfi = (FontInfoRec *)&pfont->info;
722
for (i=0; i<pfi->nprops; i++, props++) {
723
if ( (Atom) props->name == xa_pcl_font_name ) {
724
pin->pcl_font_name = NameForAtom(props->value);
726
} else if ( props->name == XA_POINT_SIZE ) {
727
pin->height = (float) props->value / 10.0;
729
} else if ( (Atom) props->name == xa_res ) {
731
} else if ( (Atom) props->name == xa_ave_width ) {
732
width = (int) props->value / 10;
734
} else if ( (Atom) props->name == xa_spacing ) {
735
pin->spacing = NameForAtom(props->value);
739
if ( mask != 0x1f ) {
740
xfree(pin->fontname);
742
return (PclInternalFontPtr) NULL;
745
if ( *pin->spacing != 'P' || *pin->spacing != 'p' ) {
748
pin->pitch = (float) 300.0 / width; /* Hard-Code: Resolution is 300 */
751
pin->next = (PclInternalFontPtr)NULL;
752
if ( prev == (PclInternalFontPtr) NULL)
753
pSoftFontInfo->pinfont = pin;
761
fillFontDescData(FontPtr pfont, PclFontDescPtr pfd, unsigned int space)
765
pfi = (FontInfoRec *)&pfont->info;
767
if ( (pfi->maxbounds.leftSideBearing == pfi->minbounds.leftSideBearing)
768
&& (pfi->maxbounds.rightSideBearing == pfi->minbounds.rightSideBearing)
769
&& (pfi->maxbounds.characterWidth == pfi->minbounds.characterWidth)
770
&& (pfi->maxbounds.ascent == pfi->minbounds.ascent)
771
&& (pfi->maxbounds.descent == pfi->minbounds.descent)
773
pfd->spacing = MONOSPACE;
775
pfd->spacing = PROPSPACE;
778
pfd->cellheight = FONTMAXBOUNDS(pfont,ascent)
779
+ FONTMAXBOUNDS(pfont,descent);
780
pfd->cellwidth = FONTMAXBOUNDS(pfont,rightSideBearing)
781
- FONTMINBOUNDS(pfont,leftSideBearing);
782
pfd->ascent = FONTMAXBOUNDS(pfont,ascent); /*FONTASCENT(pfont);*/
783
pfd->descent = FONTMAXBOUNDS(pfont,descent); /*FONTDESCENT(pfont);*/
786
static PclCharDataPtr
787
fillCharDescData(PclCharDataPtr pcd, CharInfoPtr pci)
789
unsigned int byte_width;
791
register int nbyGlyphWidth;
792
unsigned char *pglyph, *pg;
795
pcd->h_offset = pci->metrics.leftSideBearing;
796
pcd->v_offset = pci->metrics.ascent;
797
pcd->width = pci->metrics.rightSideBearing
798
- pci->metrics.leftSideBearing;
799
pcd->height = pci->metrics.ascent + pci->metrics.descent;
800
pcd->font_pitch = pci->metrics.characterWidth;
802
byte_width = (pcd->width + 7)/8;
803
pcd->raster_top = (unsigned char *)xalloc(byte_width * pcd->height);
804
if (pcd->raster_top == (unsigned char *)NULL)
805
return (PclCharDataPtr)NULL;
808
nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
809
pglyph = FONTGLYPHBITS(pglyphBase, pci);
810
for (i=0; i<pcd->height; i++) {
811
pg = pglyph + nbyGlyphWidth * i;
812
for (j=0; j<byte_width; j++)
819
output_text(FILE *outFile,
820
PclContextPrivPtr pConPriv,
823
if ( index == ETX ) {
824
sprintf(t, "%c;DT%c,1;LB%c%c;DT%c,1;LB",
825
ETX, ETX_ALT, ETX, ETX_ALT, ETX);
826
SAVE_PCL( outFile, pConPriv, t );
828
sprintf(t, "%c", index);
829
SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
834
getFontName(FontPtr pfont)
841
pfi = (FontInfoRec *)&pfont->info;
843
fontname = (char *) NULL;
844
for (i=0; i<pfi->nprops; i++, props++) {
845
if ( props->name == XA_FONT ) {
846
fontname = (char *)NameForAtom(props->value);
853
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
854
/* Internal Font Selection */
855
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
858
isInternal(FontPtr pfont)
865
dest = MakeAtom("PRINTER_RESIDENT_FONT", strlen("PRINTER_RESIDENT_FONT"), TRUE);
867
pfi = (FontInfoRec *)&pfont->info;
869
for (i=0; i<pfi->nprops; i++, props++) {
870
if ( (Atom) props->name == dest && props->value == 2 )
871
return INTERNAL_FONT;
873
return DOWNLOAD_FONT;
877
selectInternalFont(FILE *outFile, PclInternalFontPtr pin, int fid)
879
fprintf(outFile, "%c*c%dD", ESC, fid);
880
if ( *pin->spacing == 'P' || *pin->spacing == 'p' )
881
fprintf(outFile, pin->pcl_font_name, pin->height);
883
fprintf(outFile, pin->pcl_font_name, pin->pitch);
884
fprintf(outFile, "%c*c6F", ESC);
888
selectSize(FILE *outFile,
889
PclContextPrivPtr pConPriv,
890
PclInternalFontPtr pin)
892
if ( *pin->spacing == 'P' || *pin->spacing == 'p' ) {
893
sprintf(t, "SD4,%f;", pin->height);
894
SAVE_PCL( outFile, pConPriv, t );
896
sprintf(t, "SD3,%f;", pin->pitch);
897
SAVE_PCL( outFile, pConPriv, t );
902
#ifdef DO_TWO_BYTE_PCL
905
PclSoftFontInfoPtr pSoftFontInfo,
912
char frombuf[9], *fromptr;
913
size_t inbyte = 5, outbyte=2;
916
frombuf[0] = 0x1b; /* Esc */
917
frombuf[1] = 0x24; /* $ */
918
frombuf[2] = 0x42; /* B */
920
frombuf[4] = *(from+1);
921
frombuf[5] = 0x1b; /* Esc */
922
frombuf[6] = 0x28; /* ( */
923
frombuf[7] = 0x4a; /* J */
925
if ((cd = iconv_open("sjis", "jis")) == (iconv_t)(-1)) {
926
*to = (unsigned char)NULL;
930
if ( iconv(cd, &fromptr, &inbyte, &to, &outbyte) == -1 )
931
*to = (unsigned char)NULL;
936
#endif /* DO_TWO_BYTE_PCL */