Update contrib.
1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 int GdsFontCompiler::WriteFont()
23 if(index<0) return(index);
24 for(int ch=index;ch<iFxf->n_chars;ch++)
30 int GdsFontCompiler::WriteHeader()
33 for(char letter='A';letter<='Z';letter++)
35 FcmCharHead* fChar=iFxf->chr[letter];
38 int letterwidth=fChar->move;
43 WriteFormattedData("FontBitmap ");
44 WriteFormattedData(iFxf->name,1);
45 WriteFormattedData("Uid ");
46 WriteFormattedData(iFxf->iUid);
48 WriteFormattedData(" Bold");
50 WriteFormattedData(" Italic");
51 if(iFxf->iProportional)
52 WriteFormattedData(" Proportional");
54 WriteFormattedData(" Serif");
56 WriteFormattedData(" Symbol");
58 WriteFormattedData("MaxNormalCharWidth ");
59 WriteFormattedData(mncw,1);
60 WriteFormattedData("CellHeight ");
61 WriteFormattedData(iFxf->cell_height,1);
62 WriteFormattedData("Ascent ");
63 WriteFormattedData(iFxf->nominal_ascent,1);
64 // WriteFormattedData("Uline ");
65 // WriteFormattedData(iFxf->UlinePos,0);
66 // WriteFormattedData(" ");
67 // WriteFormattedData(iFxf->UlineThickness,1);
69 while(!iFxf->chr[index])
71 if(index>=iFxf->n_chars)
73 WriteFormattedData("CodeSection ");
74 WriteFormattedData(index,0);
75 WriteFormattedData(":");
76 WriteFormattedData(iFxf->n_chars-1,1);
80 void GdsFontCompiler::WriteFooter()
82 WriteFormattedData("EndCodeSection",1);
83 WriteFormattedData("EndFontBitmap",1);
87 void GdsFontCompiler::WriteCharData(int charnum)
89 unsigned short int* pSrc;
90 unsigned short int bit;
91 char buf[10+MAX_CHAR_WID];
92 unsigned short int srcBuf[(MAX_CHAR_WID+15)>>4];
94 const FcmCharHead* fChar=iFxf->chr[charnum];
96 WriteFormattedData("Char ");
97 WriteFormattedData(charnum);
101 WriteFormattedData("EndChar",1);
104 WriteFormattedData(" Adjust ");
106 int bitwid=fChar->move+(fChar->xOffset<0?-fChar->xOffset:0);
107 const int ohang=fChar->move-fChar->xOffset-fChar->width;
108 WriteFormattedData(fChar->xOffset);
109 WriteFormattedData(" ");
110 WriteFormattedData(ohang);
114 WriteFormattedData(" ! '");
115 WriteFormattedData((char*)&charnum);
116 WriteFormattedData("'");
121 WriteBlankLines(iFxf->cell_height-iFxf->descent-fChar->yOffset,fChar->width);
122 for(int y=0;y<fChar->height;y++)
124 memcpy(srcBuf,iFontSpace+fChar->offset+y*fChar->ByteWid,fChar->ByteWid);
128 for(int i=0;i<fChar->width;i++)
130 buf[pb++]=((*pSrc)&bit)?SetPixel:BlankPixel;
139 WriteFormattedData(buf,1);
141 WriteBlankLines(iFxf->descent+fChar->yOffset-fChar->height,fChar->width);
143 WriteFormattedData("EndChar",1);
146 void GdsFontCompiler::WriteBlankLines(int num,int width)
148 char buf[2+MAX_CHAR_WID+20];
149 memset(&buf[0],BlankPixel,width);
151 for(int i=0;i<num;i++)
152 WriteFormattedData(buf,1);
155 void GdsFontCompiler::WriteFormattedData(char* aData,int aNewLine)
158 iOutputFile << aData;
163 void GdsFontCompiler::WriteFormattedData(int aNum,int aNewLine)
166 _itoa(aNum,numbuf,10);
167 WriteFormattedData(numbuf,aNewLine);
170 void GdsFontCompiler::WriteNewLine()
175 int main(int argc,char *argv[])
180 cout << "FONTCOMP Version 0.01(" << version << ")\n";
182 cout << "USAGE: FONTCOMP srcfile destfile [/e [mapfile]|/f]\n";
183 cout << "Where srcfile is the file to be processed,\n";
184 cout << "destfile is the file to be created,\n";
185 cout << "/e specifies EFF format (default) and /f\n";
186 cout << "specifies FSC format. If the format is EFF then\n";
187 cout << "the optional mapfile may be used for altenative\n";
188 cout << "character sets.\n\n";
191 FontType type=EFontTypeEff;
193 if(argv[3][1]=='f' || argv[3][1]=='F')
196 if(argc==5) mapfile=argv[4];
197 GdsFontCompiler fontcomp;
198 int ret=fontcomp.Init(argv[1],argv[2],mapfile);
200 ret=fontcomp.Read(type);
202 fontcomp.RemoveBlankSpace();
204 ret=fontcomp.WriteFont();
208 cout << "Success\n\n";
211 cout << "Out of memory\n\n";
214 cout << "File does not exist\n\n";
217 cout << "File read error\n\n";
220 cout << "File write error\n\n";
223 cout << "File has wrong format\n\n";
226 cout << "Bad parameter\n\n";