#include "gd.h"#include <string.h>#include <stdlib.h>#include "../../../../libs/MALLOC/includes/MALLOC.h"Include dependency graph for bdftogd.c:

Go to the source code of this file.
Defines | |
| #define | MAXCHARS 256 |
| #define | MAXLINE 80 |
| #define | BITN(x, n) ( (x>>n) & 0x1 ) |
| #define | Max(x, y) (((x)>(y))?(x):(y)) |
Functions | |
| int | GetTag (char *s, char *tag) |
| void | dispchar (char *C, int height, int width) |
| int | ReadbdfFont (FILE *f, gdFontPtr FontPtr, char *FontName) |
| #define MAXLINE 80 |
Definition at line 2 of file bdftogd.c.
Referenced by ReadbdfFont(), ReadFunction(), and ReadListElement().
| int GetTag | ( | char * | s, | |
| char * | tag | |||
| ) |
Definition at line 15 of file bdftogd.c.
References i.
Referenced by ReadbdfFont().
00017 { 00018 int i; 00019 i=0; 00020 while (*s) { 00021 tag[i++] = *s++; 00022 if (*s == ' ' || *s == '\t' || *s == '\n') { 00023 tag[i] = '\0'; 00024 return i++; 00025 } 00026 } 00027 return i; /* Correction warning missing return statement at end of non-void function */ 00028 }
Here is the caller graph for this function:

Definition at line 46 of file bdftogd.c.
References BITN, bot, CALLOC, gdFont::data, data, gdFont::fixed, FREE, GetTag(), gdFont::h, height, i, j, left, Max, MAXLINE, gdFont::nchars, gdFont::offset, s, gdFont::w, and width.
00051 { 00052 char s[MAXLINE],hex[3],Spacing[4]; 00053 char tag[MAXLINE]; 00054 int curptr, curptrs, curcharptr; 00055 int bottom, width, currentchar, globalleft, globaltop, left; 00056 int height,hei,wid, gobitmap, bot; 00057 char *Data, *data; 00058 int i, j, nrow, nbytes,k ; 00059 int c; 00060 00061 FontPtr->fixed =0; 00062 gobitmap =0; 00063 hex[2]=0; 00064 00065 while (fgets(s,MAXLINE,f)) 00066 { 00067 GetTag(s,tag); 00068 if (!strcmp(tag,"ENCODING")){ 00069 sscanf(s,"%s %d",tag,¤tchar); 00070 } 00071 else if (!strcmp(tag,"FONT")){ 00072 sscanf(s,"%s %s",tag,FontName); 00073 } 00074 else if (!strcmp(tag,"SPACING")){ 00075 char buff[256]; 00076 int nbchar = sprintf(buff,"%%%ds %%3s",MAXLINE-4); 00077 buff[nbchar+1]='\0'; 00078 00079 sscanf(s,buff,tag,Spacing); 00080 if (Spacing[1]=='M') FontPtr->fixed=1; 00081 } 00082 else if (!strcmp(tag,"FONTBOUNDINGBOX")){ 00083 sscanf(s,"%s %d %d %d %d",tag,&width,&height,&globalleft,&globaltop); 00084 Data = (char *)CALLOC(256*width*height,sizeof(char)); 00085 if (Data == 0) return 1; 00086 data = (char *)CALLOC(width*height+8,sizeof(char)); 00087 if (Data == 0) { 00088 FREE(Data); 00089 return 1; 00090 } 00091 FontPtr->nchars = 256; 00092 FontPtr->offset = 0; /* ? */ 00093 FontPtr->w = width; 00094 FontPtr->h = height; 00095 FontPtr->data = Data; 00096 for (i=0;i<256*width*height;i++) Data[i]=0; 00097 } 00098 else if (!strcmp(tag,"BBX")){ 00099 sscanf(s,"%s %d %d %d %d",tag,&wid,&hei,&left,&bottom); 00100 } 00101 else if (!strcmp(tag,"BITMAP")){ 00102 if (currentchar>=0) { 00103 gobitmap = 1; 00104 nrow = 0; 00105 curcharptr = width*height*currentchar; 00106 for (i=0; i<width*height; i++) data[i]=0; 00107 } 00108 curptrs = 0; 00109 } 00110 00111 else if (!strcmp(tag,"ENDCHAR")){ 00112 gobitmap = 0; 00113 if (currentchar>=0) { 00114 bot = globaltop - bottom; 00115 if (bot <= 0) { 00116 k=curcharptr+(height-nrow+bot)*width; 00117 for (i=0; i<nrow*width; i++) 00118 Data[k + i]=data[i]; 00119 } 00120 } 00121 } 00122 else if (gobitmap) { 00123 curptr = Max(curptrs+left,0); 00125 nbytes=strlen(s)/2; 00126 for (j=0 ; j<nbytes ; j++) { 00127 hex[0]=s[2*j]; 00128 hex[1]=s[2*j+1]; 00129 sscanf(hex,"%x",&c); 00130 for (i=7 ; i>=0 ; i--) { 00131 data[curptr++] = (char)(BITN(c,i) != 0); 00132 } 00133 } 00134 00135 /* ?????? */ 00136 if (curptrs >0) 00137 data[curptrs-1]=0; 00138 00139 curptrs = curptrs + width; 00140 nrow++; 00141 } 00142 } 00143 FREE(data); 00144 return 0; 00145 }
Here is the call graph for this function:

1.5.1