lib/gemfont.c File Reference

#include "common.h"
#include "memgfx.h"
#include "gemfont.h"

Include dependency graph for gemfont.c:

Go to the source code of this file.

Data Structures

union  myInt

Functions

void gfText (struct memGfx *screen, struct font_hdr *f, char *text, int x, int y, Color color, TextBlit tblit, Color bcolor)
static int fchar_width (struct font_hdr *f, unsigned char *s)
long fnstring_width (struct font_hdr *f, unsigned char *s, int n)
int fwidest_char (struct font_hdr *f)
int font_cel_height (struct font_hdr *f)

Variables

static char const rcsid [] = "$Id: gemfont.c,v 1.9 2006/06/20 18:17:38 hiram Exp $"


Function Documentation

static int fchar_width ( struct font_hdr f,
unsigned char *  s 
) [static]

Definition at line 104 of file gemfont.c.

References font_hdr::ADE_hi, font_hdr::ADE_lo, font_hdr::ch_ofst, font_hdr::frm_wdt, font_hdr::hz_ofst, font_hdr::id, internalErr, font_hdr::lft_ofst, MFIXED, MPROP, font_hdr::rgt_ofst, STPROP, and font_hdr::wchr_wdt.

Referenced by fnstring_width(), and fwidest_char().

00106 {
00107 int c;
00108 signed char *offsets;
00109 int width;
00110 int t;
00111 
00112 c = *s++;
00113 if (c > f->ADE_hi)
00114     c = ' ';
00115 c -= f->ADE_lo;
00116 if (c < 0)
00117     {
00118     c = ' ' - f->ADE_lo;
00119     }
00120 switch (f->id)
00121     {
00122     case MFIXED:
00123             return(f->wchr_wdt + f->lft_ofst + f->rgt_ofst);
00124     case STPROP:
00125             return(f->ch_ofst[c+1] - f->ch_ofst[c] + f->lft_ofst + f->rgt_ofst);
00126     case MPROP:
00127             offsets = f->hz_ofst+c*2;
00128             if (offsets[0] == -1 && offsets[1] == -1)   /* missing char */
00129                 {
00130                 t = f->ADE_hi - f->ADE_lo;
00131                 return( f->frm_wdt*8 - f->ch_ofst[t+1]);
00132                 }
00133             else
00134                 {
00135                 width = offsets[1];
00136                 if ((c = *s++) != 0)
00137                         {
00138                         c -= f->ADE_lo;
00139                         offsets = f->hz_ofst+c*2;
00140                         width += offsets[0] + f->rgt_ofst;
00141                         }
00142                 return(width);
00143                 }
00144     default:
00145          internalErr();
00146          return 0;
00147     }
00148 }

Here is the caller graph for this function:

long fnstring_width ( struct font_hdr f,
unsigned char *  s,
int  n 
)

Definition at line 150 of file gemfont.c.

References fchar_width().

Referenced by mgFontWidth().

00151 {
00152 long acc = 0;
00153 
00154 while (--n >= 0)
00155     {
00156     acc += fchar_width(f, s);
00157     s++;
00158     }
00159 return(acc);
00160 }

Here is the call graph for this function:

Here is the caller graph for this function:

int font_cel_height ( struct font_hdr f  ) 

Definition at line 191 of file gemfont.c.

References font_hdr::frm_hgt.

Referenced by mgFontLineHeight(), and mgFontPixelHeight().

00192 {
00193 int dy;
00194 
00195 dy = f->frm_hgt;
00196 return(dy);
00197 }

Here is the caller graph for this function:

int fwidest_char ( struct font_hdr f  ) 

Definition at line 170 of file gemfont.c.

References font_hdr::ADE_hi, font_hdr::ADE_lo, and fchar_width().

00171 {
00172 unsigned char buf[2];
00173 int i;
00174 int c;
00175 int widest = 1;
00176 int w;
00177 
00178 c = f->ADE_lo;
00179 i = f->ADE_hi - c;
00180 buf[1] = 0;
00181 while (--i >= 0)
00182         {
00183         buf[0] = c++;
00184         w = fchar_width(f, buf);
00185         if (w > widest)
00186                 widest = w;
00187         }
00188 return(widest);
00189 }

Here is the call graph for this function:

void gfText ( struct memGfx screen,
struct font_hdr f,
char *  text,
int  x,
int  y,
Color  color,
TextBlit  tblit,
Color  bcolor 
)

Definition at line 17 of file gemfont.c.

References font_hdr::ADE_hi, font_hdr::ADE_lo, font_hdr::ch_ofst, font_hdr::fnt_dta, font_hdr::frm_hgt, font_hdr::frm_wdt, font_hdr::hz_ofst, font_hdr::id, font_hdr::lft_ofst, MFIXED, MPROP, font_hdr::rgt_ofst, ss, STPROP, UBYTE, font_hdr::wchr_wdt, WORD, font_hdr::xOff, and font_hdr::yOff.

Referenced by mgText().

00019 {
00020 UBYTE *s = (UBYTE*)text;
00021 UBYTE *ss;
00022 int c, lo, hi;
00023 int sx, imageWid;
00024 WORD *off, wd, ht;
00025 UBYTE *data;
00026 myInt *OWtab, *iPtr;
00027 int missChar;
00028 int font_type;
00029 int extraWidth = f->lft_ofst + f->rgt_ofst;
00030 
00031 x += f->xOff;
00032 y += f->yOff;
00033 x += f->lft_ofst;
00034 lo = f->ADE_lo;
00035 hi = f->ADE_hi;
00036 off = f->ch_ofst;
00037 wd = f->frm_wdt;
00038 ht = f->frm_hgt,
00039 data = f->fnt_dta;
00040 OWtab= (myInt *)(f->hz_ofst);
00041 font_type = f->id;
00042 
00043 while ((c = *s++)!=0)
00044     {
00045     /* If we don't have the character, just turn it into a space. */
00046     if (c > hi)
00047         {
00048         c = ' ';
00049         }
00050     c -= lo;
00051     if (c < 0)
00052         {
00053         c = ' ' - lo;
00054         }
00055 
00056     /* Mac prop font && its a missing char */
00057     if (font_type == MPROP && (*(OWtab+c)).theInt == -1) 
00058         {            
00059         c=hi-lo;                      /* last char is set */
00060         missChar=1;
00061         sx = off[c+1];
00062         imageWid= f->frm_wdt*8 - sx;  /* sort of a kludge */
00063         }
00064     else 
00065         {
00066         missChar=0;
00067         sx = off[c];
00068         imageWid = off[c+1]-sx;
00069         }
00070     (*tblit)(imageWid, ht, sx, 0, data, wd, screen, x, y, color, bcolor);
00071     switch (font_type)
00072         {
00073         case STPROP:
00074             x += imageWid + extraWidth;
00075             break;
00076         case MFIXED:
00077             x += f->wchr_wdt + extraWidth;          
00078             break;
00079         case MPROP:
00080             iPtr=OWtab+c;  
00081             if (!missChar)
00082                     /* -1 means its a missing character */
00083                 {
00084                 x += (int)((*iPtr).bytes[1]);
00085                 ss=s;
00086                 if ((c=*(ss++)) != 0)
00087                         /* look to next char to determine amt to change x */
00088                     {
00089                     c-= lo;
00090                     iPtr=OWtab+c;
00091                     /* subtract kern Of Next char */
00092                     /* f->rgt_ofst is neg of Mac maxKern value */
00093                     if ((*iPtr).theInt!=-1)
00094                        x += (int)((*iPtr).bytes[0])+ f->rgt_ofst;  
00095                     }           
00096                 }
00097             else /* display the non print char */
00098                 x+=imageWid + extraWidth;
00099             break;
00100         }
00101     }
00102 }

Here is the caller graph for this function:


Variable Documentation

char const rcsid[] = "$Id: gemfont.c,v 1.9 2006/06/20 18:17:38 hiram Exp $" [static]

Definition at line 9 of file gemfont.c.


Generated on Tue Dec 25 19:51:29 2007 for blat by  doxygen 1.5.2