+ else
+ {
+ /* init the widths array */
+ for(int i=0; i<256; i++) lastWidths[i] = INT_MIN;
+ /* some variables for holding parts of a line */
+ char cString[10],semiString[10],WXString[10],descString[20];
+ char upString[30], utString[30], encString[50];
+ char line[256];
+ int ascii,cWidth;
+ /* read in the file and parse it */
+ while(fgets(line,sizeof(line),afmFile)!=NULL)
+ {
+ /* A.) check for descender definition */
+ if (strncmp(line,"Descender",9)==0)
+ {
+ if ((sscanf(line,"%s%d",descString,&lastDescender)!=2) ||
+ (strcmp(descString,"Descender")!=0))
+ {
+ wxLogDebug( "AFM-file '%s': line '%s' has error (bad descender)\n", afmName,line );
+ }
+ }
+ /* JC 1.) check for UnderlinePosition */
+ else if(strncmp(line,"UnderlinePosition",17)==0)
+ {
+ if ((sscanf(line,"%s%lf",upString,&UnderlinePosition)!=2) ||
+ (strcmp(upString,"UnderlinePosition")!=0))
+ {
+ wxLogDebug( "AFM-file '%s': line '%s' has error (bad UnderlinePosition)\n", afmName, line );
+ }
+ }
+ /* JC 2.) check for UnderlineThickness */
+ else if(strncmp(line,"UnderlineThickness",18)==0)
+ {
+ if ((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) ||
+ (strcmp(utString,"UnderlineThickness")!=0))
+ {
+ wxLogDebug( "AFM-file '%s': line '%s' has error (bad UnderlineThickness)\n", afmName, line );
+ }
+ }
+ /* JC 3.) check for EncodingScheme */
+ else if(strncmp(line,"EncodingScheme",14)==0)
+ {
+ if ((sscanf(line,"%s%s",utString,encString)!=2) ||
+ (strcmp(utString,"EncodingScheme")!=0))
+ {
+ wxLogDebug("AFM-file '%s': line '%s' has error (bad EncodingScheme)\n", afmName, line );
+ }
+ else if (strncmp(encString, "AdobeStandardEncoding", 21))
+ {
+ wxLogDebug( "AFM-file '%s': line '%s' has error (unsupported EncodingScheme %s)\n",
+ afmName,line, encString);
+ }
+ }
+ /* B.) check for char-width */
+ else if(strncmp(line,"C ",2)==0)
+ {
+ if (sscanf(line,"%s%d%s%s%d",cString,&ascii,semiString,WXString,&cWidth)!=5)
+ {
+ wxLogDebug("AFM-file '%s': line '%s' has an error (bad character width)\n",afmName,line);
+ }
+ if(strcmp(cString,"C")!=0 || strcmp(semiString,";")!=0 || strcmp(WXString,"WX")!=0)
+ {
+ wxLogDebug("AFM-file '%s': line '%s' has a format error\n",afmName,line);
+ }
+ /* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */
+ if (ascii>=0 && ascii<256)
+ {
+ lastWidths[ascii] = cWidth; /* store width */
+ }
+ else
+ {
+ /* MATTHEW: this happens a lot; don't print an error */
+ /* wxLogDebug("AFM-file '%s': ASCII value %d out of range\n",afmName,ascii); */
+ }
+ }
+ /* C.) ignore other entries. */
+ }
+ fclose(afmFile);