File: fontutils.C

package info (click to toggle)
sabre 0.2.4b-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,536 kB
  • ctags: 7,207
  • sloc: cpp: 36,926; ansic: 8,272; sh: 2,547; makefile: 208
file content (87 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// -*- mode: C; -*-
// jed does not understand .C

//
// Minefields:
// 
// This code is mine. You may use, modify or redistribute this code 
// in any APPROPRIATE manner you may choose. 
//  
// If you use, modify or redistribute this code, I am NOT responsible
// for ANY issue raised. 
// 
// ( If you modify or remove this note, this code is no longer mine. ) 
// 
// proff@iki.fi 
// 
//

// Mon Dec 29 16:40:01 EET 1997 (proff@alf.melmac)
// created file fontutils.C

// Current version:
// Last modified:

#include <stdio.h>
#include <stdarg.h>
#include "fontutils.h"

void gputc( fontdev *f, int x, int y, int c, int ascii )
{
   unsigned char *dest=(unsigned char *)G->getvbuf( ), 
                  *end=(unsigned char *)G->getvbuf(1);
   dest+=(x+y*G->getdimx());
   int fdimx=f->getdimx(), fdimy=f->getdimy(); 
   unsigned char *src=(unsigned char *)f->getfbp(ascii);
   int i, j, dstep=(G->getdimx()-fdimx);
   for( j=0; j<fdimy; j++, dest+=dstep ) {
      for( i=0; i<fdimx; i++, src++, dest++ ) {
	 if( dest >= end )
	   goto _abort_gputc;
	 if( *src ) {
	    *dest=c&*src;  
	 }	 
      }
   }
   
   _abort_gputc:
   return;
}

void gputs( fontdev *f, int x, int y, int c, char *s )
{
   unsigned char *dest=(unsigned char *)G->getvbuf( ),
                  *end=(unsigned char *)G->getvbuf(1);
   dest+=(x+y*G->getdimx());
   int fdimx=f->getdimx(), fdimy=f->getdimy(); 
   for( ; *s; s++ ) {
      unsigned char *src=(unsigned char *)f->getfbp((unsigned char)(*s));
      int i, j, dstep=(G->getdimx()-fdimx);
      for( j=0; j<fdimy; j++, dest+=dstep ) {
	 for( i=0; i<fdimx; i++, src++, dest++ ) {
	    if( dest >= end )
	      goto _abort_gputs;
	    if( *src ) {
	       *dest=c&*src;
	    }
	 }
      }
      dest-=(fdimy*G->getdimx()-fdimx);
      dest++;
   }
   
   _abort_gputs:
   return;
}

void gprintf( fontdev *f, int x, int y, int c, char *fmt, ... )
{
   char buf[4096]; // ?!

   va_list ap;
   va_start(ap,fmt);
   vsprintf(buf,fmt,ap);
   va_end(ap);

   gputs( f, x, y, c, buf );
}