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