gfxtools/gditools/fontcomp/FONTCOMP.H
changeset 0 f58d6ec98e88
child 6 2013ebce6d92
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 1997-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #if !defined(__FONTCOMP_H__)
       
    20 #define __FONTCOMP_H__
       
    21 #include <stdlib.h>
       
    22 #include <string.h>
       
    23 #include <io.h>
       
    24 
       
    25 #ifdef __MSVCDOTNET__
       
    26 #include <fstream>
       
    27 #include <iostream>
       
    28 using namespace std;
       
    29 #else //!__MSVCDOTNET__
       
    30 #include <fstream.h>
       
    31 #endif //__MSVCDOTNET__
       
    32 
       
    33 /**
       
    34 @internalComponent
       
    35 */
       
    36 #define MAX_CHARS 256
       
    37 #define FONT_NAME_LEN 16
       
    38 /**
       
    39 @internalComponent
       
    40 */
       
    41 #define MAX_CHAR_WID 256
       
    42 #define MAX_HEIGHT 256
       
    43 #define MAX_LABEL_LENGTH 16		/* Max font label name */
       
    44 #define MAX_LEN_IN 255	/* Max input line length */
       
    45 #define MAXLINE 600	/* Max line length for writing to screen */
       
    46 #define FONT_MAX_HEADER_LEN 128
       
    47 #define P_FNAMESIZE 128 /* Maximum file name size */
       
    48 /**
       
    49 @internalComponent
       
    50 */
       
    51 enum Errors
       
    52 	{
       
    53 	NoError=0,
       
    54 	NoMemory=-1,
       
    55 	NoFile=-2,
       
    56 	FileRead=-3,
       
    57 	FileWrite=-4,
       
    58 	FileFormat=-5,
       
    59 	Parameter=-6
       
    60 	};
       
    61 /**
       
    62 @internalComponent
       
    63 */
       
    64 struct FcmCharHead
       
    65 	{
       
    66 	int xOffset;
       
    67 	int yOffset;
       
    68 	int width;
       
    69 	int height;
       
    70 	int move;
       
    71 	int ByteWid;
       
    72 	int offset;
       
    73 	};
       
    74 /**
       
    75 @internalComponent
       
    76 */
       
    77 struct LetterTableData
       
    78 	{
       
    79 	short int offset;
       
    80 	short int width; /* x16 in version 1*/
       
    81 	};
       
    82 /**
       
    83 @internalComponent
       
    84 */
       
    85 struct LetterData
       
    86 	{
       
    87 	char blx;
       
    88 	char bly;
       
    89 	unsigned char rWid; /* Enclosing rectangle width */
       
    90 	unsigned char rHgt; /* Enclosing rectangle height */
       
    91 	};
       
    92 /**
       
    93 @internalComponent
       
    94 */
       
    95 struct EffVariousData
       
    96 	{
       
    97 	short int version;
       
    98 	short int blx;
       
    99 	short int bly;
       
   100 	short int Wid;
       
   101 	short int Hgt;
       
   102 	short int xSize; /* 16 x Point size */
       
   103 	short int xRes;  /* DPI */
       
   104 	short int ySize;
       
   105 	short int yRes;
       
   106 	unsigned char XHeight;
       
   107 	unsigned char CapHeight;
       
   108 	unsigned char Ascender;
       
   109 	char Descender;
       
   110 	unsigned char LineSpacing;
       
   111 	char UnderLinePos;
       
   112 	unsigned char UnderLineThickness;
       
   113 	unsigned char filler[7];
       
   114 	};
       
   115 /**
       
   116 @internalComponent
       
   117 */
       
   118 const int EMaxFontNameLength=256;
       
   119 
       
   120 class Fxf
       
   121 /**
       
   122 @internalComponent
       
   123 */
       
   124 	{
       
   125 public:
       
   126 	FcmCharHead *chr[MAX_CHARS];
       
   127 	char name[EMaxFontNameLength]; /* Font name */
       
   128 	char typeface[EMaxFontNameLength]; /* Font typeface */
       
   129 	int MaxChrWidth;
       
   130 	int cell_height;      /* Height of character set */
       
   131 	int nominal_ascent;   /* Max ascent of normal (ASCII) characters */
       
   132 	int descent;         /* Descent of characters below base line */
       
   133 	int chr_seg;
       
   134 	int FirstChr;
       
   135 	int n_chars;         /* counts total number of characters defined */
       
   136 	unsigned int max_info_width;  /* Max char width to put in info file */
       
   137 	unsigned short int flags;
       
   138 	unsigned short int special;
       
   139 	unsigned int ByteWid;
       
   140 	int UseWords;
       
   141 	int UlinePos;
       
   142 	int UlineThickness;
       
   143 	int iBold;
       
   144 	int iItalic;
       
   145 	int iProportional;
       
   146 	int iSerif;
       
   147 	int iSymbol;
       
   148 	unsigned int iUid;
       
   149 	};
       
   150 /**
       
   151 @internalComponent
       
   152 */
       
   153 enum FontType
       
   154 	{
       
   155 	EFontTypeFsc,
       
   156 	EFontTypeEff
       
   157 	};
       
   158 
       
   159 class FontCompiler
       
   160 /**
       
   161 @internalComponent
       
   162 */
       
   163 	{
       
   164 public:
       
   165 	FontCompiler();
       
   166 	int Read(FontType aInputType);
       
   167 	int Init(char*,char*,char*);
       
   168 	void RemoveBlankSpace();
       
   169 	char* FontStore() const;
       
   170 	virtual int WriteFont()=0;
       
   171 protected: // general information
       
   172 	fstream iInputFile;
       
   173 	fstream iOutputFile;
       
   174 	Fxf* iFxf;
       
   175 protected: // font information
       
   176 	char* iFontSpace;
       
   177 	char* iWorkSpace; // misc. stuff
       
   178 	short int* iMapSpace;
       
   179 	int iWorkSpaceSize;
       
   180 	unsigned int iHeaderDataLen;
       
   181 	unsigned char iHeaderData[FONT_MAX_HEADER_LEN];
       
   182 	};
       
   183 
       
   184 class FontRead
       
   185 /**
       
   186 @internalComponent
       
   187 */
       
   188 	{
       
   189 public:
       
   190 	FontRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf);
       
   191 	virtual int ReadFont()=0;
       
   192 private:
       
   193 	FontRead& operator=(const FontRead&);
       
   194 protected:
       
   195 	fstream& iInputFile;
       
   196 	FontCompiler* iFontCompiler;
       
   197 	Fxf* iFxf;
       
   198 	};
       
   199 
       
   200 class EffRead : public FontRead
       
   201 /**
       
   202 @internalComponent
       
   203 */
       
   204 	{
       
   205 public:
       
   206 	EffRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf,short int* aMapSpace);
       
   207 	virtual int ReadFont();
       
   208 private:
       
   209 	EffRead& operator=(const EffRead&);
       
   210 private:
       
   211 	short int* iMapSpace;
       
   212 	};
       
   213 
       
   214 class FscRead : public FontRead
       
   215 /**
       
   216 @internalComponent
       
   217 */
       
   218 	{
       
   219 public:
       
   220 	FscRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf);
       
   221 	virtual int ReadFont();
       
   222 private:
       
   223 	FscRead& operator=(const FscRead&);
       
   224 private:
       
   225 	int ReadLine();
       
   226 	int Pass1();
       
   227 	int Pass2();
       
   228 	char* ScanLine(int& aLen);
       
   229 	int DoCom(int aSecondPass);
       
   230 private:
       
   231 	FcmCharHead *iChar;
       
   232 	char iInputBuf[256];
       
   233 	int iInputBufLen;
       
   234 	char* iFileBuf;
       
   235 	int iFileBufLen;
       
   236 	int iFileBufPos;
       
   237 	int iUnderHang;
       
   238 	int iOverHang;
       
   239 	};
       
   240 
       
   241 #endif