graphicstools/bitmapfonttools/inc/FNTREADR.H
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 /*
       
     2 * Copyright (c) 1997-2009 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 * Header FNTREADR.H
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __FNTREADR_H__
       
    21 #define __FNTREADR_H__
       
    22 
       
    23 #include "FNTRECRD.H"
       
    24 #include "LST.H"
       
    25 #include "READER.H"
       
    26 /**
       
    27 @internalComponent
       
    28 */
       
    29 const uint16 KMaxSizeCodeSectionBitmap = 0x7FFF;
       
    30 const int KMaxBitmapWidth = 0x7f;
       
    31 const int KMaxBitmapHeight = 0x7f;
       
    32 const int KNumberOfBitsInByte = 8; 
       
    33 /**
       
    34 @internalComponent
       
    35 */
       
    36 const int KLowestPermittedCharacterEncoding = 0x0000;
       
    37 const int KHighestPermittedCharacterEncoding = 0xffff;
       
    38 /**
       
    39 @internalComponent
       
    40 */
       
    41 const int KMaxNumberRepeatedLines = 15;	// maximum number of repeated lines in font compiler
       
    42 
       
    43 /**
       
    44 KFillCharacterOffset is a significant offset that is set when a character within a code section is 
       
    45 not in the font. This means that for these fill characters nothing is stored within the binary
       
    46 data part of the code section
       
    47 @internalComponent
       
    48 */
       
    49 const uint16 KFillCharacterOffset = 0x7FFF;
       
    50 
       
    51 /**
       
    52 Resource identifiers
       
    53 @internalComponent
       
    54 */
       
    55 const String IdentFontBitmap("FontBitmap");
       
    56 const String IdentSTARTFONT("STARTFONT");
       
    57 const String IdentTypeface("Typeface");
       
    58 const String IdentFontStoreFile("FontStoreFile");
       
    59 /**
       
    60 Char identifiers
       
    61 @internalComponent
       
    62 */
       
    63 const String IdentAdjust("Adjust");
       
    64 const String IdentEndChar("EndChar");
       
    65 
       
    66 /**
       
    67 Codesection identifiers
       
    68 @internalComponent
       
    69 */
       
    70 const String IdentEndCodeSection("EndCodeSection");
       
    71 const String IdentChar("Char");
       
    72 
       
    73 /**
       
    74 Fontbitmap identifiers
       
    75 @internalComponent
       
    76 */
       
    77 const String IdentEndFontBitmap("EndFontBitmap");
       
    78 const String IdentUid("Uid");
       
    79 const String IdentBold("Bold");
       
    80 const String IdentItalic("Italic");
       
    81 const String IdentFontBitmapProportional("Proportional");
       
    82 const String IdentCellHeight("CellHeight");
       
    83 const String IdentAscent("Ascent");
       
    84 const String IdentMaxNormalCharWidth("MaxNormalCharWidth");
       
    85 const String IdentBitmapEncoding("BitmapEncoding");
       
    86 const String IdentCodeSection("CodeSection");
       
    87 const String IdentMaxConsecutiveFillChars("MaxConsecutiveFillChars"); 
       
    88 
       
    89 /**
       
    90 BDF CHAR identifiers
       
    91 @internalComponent
       
    92 */
       
    93 const String IdentBDFFileHeader("STARTFONT");
       
    94 const String IdentBDFComment("COMMENT");
       
    95 const String IdentBDFContentVersion("CONTENTVERSION");
       
    96 const String IdentBDFFontBitmap("FONT"); 
       
    97 const String IdentBDFPointSize("SIZE");
       
    98 const String IdentBDFFontDesignBox("FONTBOUNDINGBOX");
       
    99 const String IdentBDFWritingDirection("METRICSSET");
       
   100 const String IdentBDFStartProperties("STARTPROPERTIES");
       
   101 const String IdentBDFPropertyUid("UID");
       
   102 const String IdentBDFPropertyBold("BOLD");
       
   103 const String IdentBDFPropertyItalic("ITALIC");
       
   104 const String IdentBDFPropertyFontAscent("FONTASCENT");
       
   105 const String IdentBDFPropertyFontDescent("FONTDESCENT");
       
   106 const String IdentBDFPropertyMaxNormalCharWidth("MAXNORMALCHARWIDTH");
       
   107 const String IdentBDFPropertyMaxConsecutiveFillChars("MAXCONSECUTIVEFILLCHARS");
       
   108 const String IdentBDFEndProperties("ENDPROPERTIES");
       
   109 const String IdentBDFNumChars("CHARS");	// To be used as sanity check on BDF files
       
   110 const String IdentBDFCharLabel("STARTCHAR");
       
   111 const String IdentBDFChar("ENCODING");
       
   112 const String IdentBDFCursorMove("DWIDTH");
       
   113 const String IdentBDFBitmapSizeAndDisplacement("BBX");
       
   114 const String IdentBDFStartBitmap("BITMAP");
       
   115 const String IdentBDFEndChar("ENDCHAR");
       
   116 const String IdentBDFEndFontBitmap("ENDFONT");
       
   117 
       
   118 /**
       
   119 Typeface identifiers
       
   120 @internalComponent
       
   121 */
       
   122 const String IdentEndTypeface("EndTypeface");
       
   123 const String IdentName("Name");
       
   124 const String IdentTypefaceProportional("Proportional");
       
   125 const String IdentSerif("Serif");
       
   126 const String IdentSymbol("Symbol");
       
   127 const String IdentFontBitmaps("FontBitmaps");
       
   128 const String IdentWidthFactor("WidthFactor");
       
   129 const String IdentHeightFactor("HeightFactor");
       
   130 const String IdentEndFontBitmaps("EndFontBitmaps");
       
   131 
       
   132 /**
       
   133 Fontstorefile identifiers
       
   134 @internalComponent
       
   135 */
       
   136 const String IdentEndFontStoreFile("EndFontStoreFile");
       
   137 const String IdentFilename("Filename");
       
   138 const String IdentCollectionUid("CollectionUid");
       
   139 const String IdentKPixelAspectRatio("KPixelAspectRatio");
       
   140 const String IdentTypefaces("Typefaces");
       
   141 const String IdentEndTypefaces("EndTypefaces");
       
   142 const String IdentExtraFontBitmaps("FontBitmaps");
       
   143 const String IdentEndExtraFontBitmaps("EndFontBitmaps");
       
   144 const String IdentCopyrightInfo("CopyrightInfo");
       
   145 const String IdentEndCopyrightInfo("EndCopyrightInfo");
       
   146 
       
   147 class CroppedValues;
       
   148 
       
   149 class FontReader : public Reader
       
   150 /**
       
   151 @internalComponent
       
   152 */
       
   153 	{
       
   154 public:
       
   155 	enum TReadFileFormat
       
   156 		{
       
   157 		ESymbianGDFFormat,
       
   158 		EBDFFormat
       
   159 		};
       
   160 public:
       
   161 	FontReader();
       
   162 	boolean Read(const String& aFilename);
       
   163 	boolean ReadBDFCharacter(int aCode);
       
   164 	boolean ParseMetricsFromBDF(int aNumberCharsInFile, int aMaxConsecutiveFillChars);
       
   165 	boolean ReadMetricFromBDFCharacter(CharacterMetrics* aMetric, CroppedValues* aCropped);
       
   166 	boolean ReadBDFFontBitmap();
       
   167 	boolean ReadTypeface();
       
   168 	boolean ReadFontStoreFile();
       
   169 	int Store(const String& aFilename);
       
   170 	boolean CharLine(String& aCharLine);
       
   171 private:
       
   172 	boolean ReadBDFChars(const int aNumberOfGlyphsInFile, const int aMaxConsecutiveFillChars);
       
   173 	boolean DoMetricAnalysis(int& aHeight, int& aWidth, int& aLeftAdjust, int& aRightAdjust, int& aAscent);
       
   174 	void ErrorIdentifierExpected(const String& aIdentifier);
       
   175 	boolean CompareBitmapLines(int aLine1, int aLine2);
       
   176 	boolean BitmapLineEmpty(int aLine);
       
   177 	boolean BitmapColumnEmpty(int aColumn);
       
   178 	void WriteFillCharacters(int aNumberConsecutive);
       
   179 	void PrintoutCodeSection(const BitmapCodeSection* aCodeSection) const;
       
   180 private:
       
   181 	FontStore iFontStore;
       
   182 	FontStoreFile* iFontStoreFile;
       
   183 	CharacterMetrics* iCharacterMetrics;
       
   184 	BitmapCodeSection* iCodeSection;
       
   185 	FontBitmap* iFontBitmap;
       
   186 	FntTypeface* iTypeface;
       
   187 	TReadFileFormat iReadFileFormat;
       
   188 	int iBitArray[KMaxBitmapWidth][KMaxBitmapHeight];
       
   189 	int iBitmapWidth;
       
   190 	int iBitmapHeight;
       
   191 	int iDefaultXMoveInPixels;
       
   192 	int iDefaultYMoveInPixels;
       
   193 	String iFileName;
       
   194 	};
       
   195 
       
   196 #endif