Annotation of 43BSDTahoe/new/X/libapollo/text.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char *rcsid_text_c = "$Header: text.c,v 10.1 86/11/29 13:52:56 jg Rel $";
                      3: #endif lint
                      4:     /*
                      5: 
                      6:     Copyright 1986 by the University of Utah
                      7: 
                      8:     Permission to use, copy, modify, and distribute this
                      9:     software and its documentation for any purpose and without
                     10:     fee is hereby granted, provided that the above copyright
                     11:     notice appear in all copies and that both that copyright
                     12:     notice and this permission notice appear in supporting
                     13:     documentation, and that the name of the University of Utah
                     14:     not be used in advertising or publicity pertaining to 
                     15:     distribution of the software without specific, written 
                     16:     prior permission. The University of Utah makes no
                     17:     representations about the suitability of this software for
                     18:     any purpose.  It is provided "as is" without express or
                     19:     implied warranty.
                     20: 
                     21:     */
                     22: 
                     23: /*
                     24:  *     ToDo:
                     25:  *             xymask's
                     26:  */
                     27: 
                     28: #include "Xapollo.h"
                     29: #ifndef stdin
                     30: #include <stdio.h>
                     31: #endif   
                     32: 
                     33: extern boolean borrow_flag;
                     34: extern int old_op;
                     35: 
                     36: PrintText(string, strlen, font, fore, back, charpad, spacepad, dstx, dsty,
                     37:          clipstart, clipcount, func, zmask)
                     38:     unsigned char *string;
                     39:     FONT       *font;
                     40:     int         strlen, fore, back, charpad, spacepad, dstx, dsty;
                     41:     CLIP       *clipstart;
                     42:     int         clipcount, zmask;
                     43:     int         func;
                     44: {
                     45:     int         op, i;
                     46:     extern char FBMap[];
                     47:     register    w = 0;
                     48:     int         bsize = 0;
                     49:     int         lheight;
                     50:     int         sbot, sright;
                     51:     int         savestrlen = strlen;
                     52:     unsigned char *savestring = string;
                     53:     gpr_$window_t cwindow;
                     54:     boolean active;
                     55:     status_$t status;
                     56:     FontPriv   * fp;
                     57:     static int old_fore = -1,
                     58:                old_back = -1;
                     59: 
                     60:     fp = (FontPriv *)font->data;
                     61: 
                     62: /* Do apollo-format fonts */
                     63:     if (fp->ap_font) {
                     64:       int lback, lfore;
                     65: 
                     66:       if (!borrow_flag)
                     67:         active = gpr_$acquire_display( status );
                     68:       if ((charpad != 0) || (spacepad != 0))
                     69:         fprintf(stderr, "charpad=%d, spacepad=%d\n", charpad,spacepad);
                     70: /* if window is inverted (and just using 0 & 1 pixels, use inverted font */
                     71:       gpr_$set_text_font( (short)fp->ap_font_id, status);
                     72:       if ((back == 1) && (fore == 0))
                     73:         gpr_$set_text_font( (short)fp->ap_font_id_inv, status);
                     74:       fore = (fore == 0) ? 1 : fore;
                     75:       back = (back == 1) ? 0 : back;
                     76: 
                     77:       if (old_fore != fore) {
                     78:         old_fore = fore;
                     79:         gpr_$set_text_value((gpr_$pixel_value_t)fore, status);
                     80:         }
                     81:       if (old_back != back) {
                     82:         old_back = back;
                     83:         gpr_$set_text_background_value((gpr_$pixel_value_t)back, status);
                     84:         }
                     85:       set_zmask(zmask);
                     86:       set_op( func );
                     87:       CheckCursor(dstx, dsty, strlen * fp->maxwidth, font->height);
                     88:       dsty = dsty + font->height - 1;
                     89:       do {
                     90:                GetNextClip(clipstart, cwindow);
                     91:         gpr_$set_clip_window( cwindow, status);   
                     92:         gpr_$move( (short)dstx, (short)dsty, status);
                     93:         gpr_$text( *string, (short)strlen, status);
                     94:         } while (--clipcount);
                     95:       if (!borrow_flag)
                     96:         gpr_$release_display( status);
                     97:       }        
                     98:     else {
                     99: /* wasn't in apollo format, use internal format--this should be avoided! */
                    100:     if (fore & 1)
                    101:        func += 0x20;
                    102:     if (back & 1)
                    103:        func += 0x10;
                    104:     func = FBMap[func];
                    105: 
                    106:     lheight = font->height;
                    107: 
                    108:     sbot = dsty + lheight;
                    109:     sright = dstx + w;
                    110: 
                    111:     dsty -= font->base;
                    112:     do {
                    113:         gpr_$window_t window;
                    114:         gpr_$position_t dest;
                    115:         int w;
                    116: 
                    117:         gpr_$set_raster_op((short)0, (short)func, status);
                    118:         old_op = func;
                    119:        GetNextClip(clipstart, cwindow);
                    120:        CheckCursor(cwindow.x_coord, cwindow.y_coord,
                    121:                 cwindow.x_size, cwindow.y_size);
                    122:         gpr_$set_clip_window( cwindow, status);
                    123:         window.y_size = lheight;
                    124:         dest.y_coord = dsty;
                    125:         dest.x_coord = dstx;
                    126: 
                    127:         while( strlen-- )
                    128:            {
                    129:           window.x_coord = fp->leftarray[*string];
                    130:           w = fp->widths[*string];
                    131:           window.x_size = w;
                    132:           gpr_$bit_blt(fp->strike->data, window, (short)0, dest, (short)0, status); 
                    133:           ++string;
                    134:          dest.x_coord += w; 
                    135:         }
                    136:         string = savestring;
                    137:         strlen = savestrlen;
                    138:         } while (--clipcount > 0);
                    139:     }
                    140:        RestoreCursor();
                    141: }
                    142: 
                    143: PrintTextMask(string, strlen, font, srcpix, charpad, spacepad, dstx, dsty,
                    144:              clips, clipcount, func, zmask)
                    145:     unsigned char *string;
                    146:     FONT       *font;
                    147:     int         strlen, srcpix, charpad, spacepad, dstx, dsty;
                    148:     CLIP       *clips;
                    149:     int         clipcount, zmask;
                    150:     register int func;
                    151: {
                    152:     int         cleft, ctop, cwidth, cheight;
                    153:     int         fore, back;
                    154:     extern char SSMap[];        
                    155: 
                    156: /* ( assume depth == 1) */
                    157:     fore = 1;
                    158:     back = 0;
                    159:        if ((srcpix & 1) == 0) {
                    160:         fore = 0;
                    161:         back = 1;
                    162:     }
                    163: /* Punt for now on masking */
                    164:     PrintText(string, strlen, font, fore, back, charpad, spacepad, dstx, dsty,
                    165:              clips, clipcount, func, zmask);
                    166: 
                    167: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.