os/textandloc/fontservices/textshaperplugin/test/letest/FontObject.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/test/letest/FontObject.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,235 @@
     1.4 +/***************************************************************************
     1.5 +*
     1.6 +*   Copyright (C) 1998-2002, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +*
     1.9 +************************************************************************/
    1.10 +
    1.11 +
    1.12 +#ifndef __FONTOBJECT_H
    1.13 +#define __FONTOBJECT_H
    1.14 +
    1.15 +#include <stdio.h>
    1.16 +
    1.17 +#include "LETypes.h"
    1.18 +
    1.19 +
    1.20 +#ifndef ANY_NUMBER
    1.21 +#define ANY_NUMBER 1
    1.22 +#endif
    1.23 +
    1.24 +struct DirectoryEntry
    1.25 +{
    1.26 +    le_uint32   tag;
    1.27 +    le_uint32   checksum;
    1.28 +    le_uint32   offset;
    1.29 +    le_uint32   length;
    1.30 +};
    1.31 +
    1.32 +struct SFNTDirectory
    1.33 +{
    1.34 +    le_uint32       scalerType;
    1.35 +    le_uint16       numTables;
    1.36 +    le_uint16       searchRange;
    1.37 +    le_uint16       entrySelector;
    1.38 +    le_uint16       rangeShift;
    1.39 +    DirectoryEntry  tableDirectory[ANY_NUMBER];
    1.40 +};
    1.41 +
    1.42 +
    1.43 +struct CMAPEncodingSubtableHeader
    1.44 +{
    1.45 +    le_uint16   platformID;
    1.46 +    le_uint16   platformSpecificID;
    1.47 +    le_uint32   encodingOffset;
    1.48 +};
    1.49 +
    1.50 +struct CMAPTable
    1.51 +{
    1.52 +    le_uint16   version;
    1.53 +    le_uint16   numberSubtables;
    1.54 +    CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
    1.55 +};
    1.56 +
    1.57 +struct CMAPEncodingSubtable
    1.58 +{
    1.59 +    le_uint16   format;
    1.60 +    le_uint16   length;
    1.61 +    le_uint16   language;
    1.62 +};
    1.63 +
    1.64 +struct CMAPFormat0Encoding : CMAPEncodingSubtable
    1.65 +{
    1.66 +    le_uint8    glyphIndexArray[256];
    1.67 +};
    1.68 +
    1.69 +struct CMAPFormat2Subheader
    1.70 +{
    1.71 +    le_uint16   firstCode;
    1.72 +    le_uint16   entryCount;
    1.73 +    le_int16    idDelta;
    1.74 +    le_uint16   idRangeOffset;
    1.75 +};
    1.76 +
    1.77 +struct CMAPFormat2Encoding : CMAPEncodingSubtable
    1.78 +{
    1.79 +    le_uint16  subHeadKeys[256];
    1.80 +    CMAPFormat2Subheader subheaders[ANY_NUMBER];
    1.81 +};
    1.82 +
    1.83 +struct CMAPFormat4Encoding : CMAPEncodingSubtable
    1.84 +{
    1.85 +    le_uint16   segCountX2;
    1.86 +    le_uint16   searchRange;
    1.87 +    le_uint16   entrySelector;
    1.88 +    le_uint16   rangeShift;
    1.89 +    le_uint16   endCodes[ANY_NUMBER];
    1.90 +//  le_uint16   reservedPad;
    1.91 +//  le_uint16   startCodes[ANY_NUMBER];
    1.92 +//  le_uint16   idDelta[ANY_NUMBER];
    1.93 +//  le_uint16   idRangeOffset[ANY_NUMBER];
    1.94 +//  le_uint16   glyphIndexArray[ANY_NUMBER];
    1.95 +};
    1.96 +
    1.97 +struct CMAPFormat6Encoding : CMAPEncodingSubtable
    1.98 +{
    1.99 +    le_uint16   firstCode;
   1.100 +    le_uint16   entryCount;
   1.101 +    le_uint16   glyphIndexArray[ANY_NUMBER];
   1.102 +};
   1.103 +
   1.104 +typedef le_int32 fixed;
   1.105 +
   1.106 +struct BigDate
   1.107 +{
   1.108 +    le_uint32 bc;
   1.109 +    le_uint32 ad;
   1.110 +};
   1.111 +
   1.112 +struct HEADTable
   1.113 +{
   1.114 +    fixed       version;
   1.115 +    fixed       fontRevision;
   1.116 +    le_uint32   checksumAdjustment;
   1.117 +    le_uint32   magicNumber;
   1.118 +    le_uint16   flags;
   1.119 +    le_uint16   unitsPerEm;
   1.120 +    BigDate     created;
   1.121 +    BigDate     modified;
   1.122 +    le_int16    xMin;
   1.123 +    le_int16    yMin;
   1.124 +    le_int16    xMax;
   1.125 +    le_int16    yMax;
   1.126 +    le_int16    lowestRecPPEM;
   1.127 +    le_int16    fontDirectionHint;
   1.128 +    le_int16    indexToLocFormat;
   1.129 +    le_int16    glyphDataFormat;
   1.130 +};
   1.131 +
   1.132 +struct MAXPTable
   1.133 +{
   1.134 +    fixed       version;
   1.135 +    le_uint16   numGlyphs;
   1.136 +    le_uint16   maxPoints;
   1.137 +    le_uint16   maxContours;
   1.138 +    le_uint16   maxComponentPoints;
   1.139 +    le_uint16   maxComponentContours;
   1.140 +    le_uint16   maxZones;
   1.141 +    le_uint16   maxTwilightPoints;
   1.142 +    le_uint16   maxStorage;
   1.143 +    le_uint16   maxFunctionDefs;
   1.144 +    le_uint16   maxInstructionDefs;
   1.145 +    le_uint16   maxStackElements;
   1.146 +    le_uint16   maxSizeOfInstructions;
   1.147 +    le_uint16   maxComponentElements;
   1.148 +    le_uint16   maxComponentDepth;
   1.149 +};
   1.150 +
   1.151 +struct HHEATable
   1.152 +{
   1.153 +    fixed       version;
   1.154 +    le_int16    ascent;
   1.155 +    le_int16    descent;
   1.156 +    le_int16    lineGap;
   1.157 +    le_uint16   advanceWidthMax;
   1.158 +    le_int16    minLeftSideBearing;
   1.159 +    le_int16    minRightSideBearing;
   1.160 +    le_int16    xMaxExtent;
   1.161 +    le_int16    caretSlopeRise;
   1.162 +    le_int16    caretSlopeRun;
   1.163 +    le_int16    caretOffset;
   1.164 +    le_int16    reserved1;
   1.165 +    le_int16    reserved2;
   1.166 +    le_int16    reserved3;
   1.167 +    le_int16    reserved4;
   1.168 +    le_int16    metricDataFormat;
   1.169 +    le_uint16   numOfLongHorMetrics;
   1.170 +};
   1.171 +
   1.172 +struct LongHorMetric
   1.173 +{
   1.174 +    le_uint16   advanceWidth;
   1.175 +    le_int16    leftSideBearing;
   1.176 +};
   1.177 +
   1.178 +struct HMTXTable
   1.179 +{
   1.180 +    LongHorMetric hMetrics[ANY_NUMBER];        // ANY_NUMBER = numOfLongHorMetrics from hhea table
   1.181 +//  le_int16      leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
   1.182 +};
   1.183 +
   1.184 +class FontObject
   1.185 +{
   1.186 +public:
   1.187 +    FontObject(char *fontName);
   1.188 +    ~FontObject();
   1.189 +
   1.190 +    void *readTable(LETag tag, le_uint32 *length);
   1.191 +    void deleteTable(void *table);
   1.192 +
   1.193 +    LEGlyphID unicodeToGlyph(LEUnicode32 unicode);
   1.194 +
   1.195 +#if 0
   1.196 +    le_uint32 unicodesToGlyphs(LEUnicode *chars, le_uint32 nChars, LEGlyphID *glyphs,
   1.197 +        le_uint32 *charIndices, le_bool rightToLeft);
   1.198 +#endif
   1.199 +
   1.200 +    le_uint16 getUnitsPerEM();
   1.201 +
   1.202 +    le_uint16 getGlyphAdvance(LEGlyphID glyph);
   1.203 +
   1.204 +private:
   1.205 +    FontObject();
   1.206 +
   1.207 +    DirectoryEntry *findTable(LETag tag);
   1.208 +    CMAPEncodingSubtable *findCMAP(le_uint16 platformID, le_uint16 platformSpecificID);
   1.209 +    void initUnicodeCMAP();
   1.210 +
   1.211 +    SFNTDirectory *directory;
   1.212 +    le_uint16 numTables;
   1.213 +    le_uint16 searchRange;
   1.214 +    le_uint16 entrySelector;
   1.215 +    le_uint16 rangeShift;
   1.216 +
   1.217 +    CMAPTable *cmapTable;
   1.218 +    le_uint16 cmSegCount;
   1.219 +    le_uint16 cmSearchRange;
   1.220 +    le_uint16 cmEntrySelector;
   1.221 +    le_uint16 cmRangeShift;
   1.222 +    le_uint16 *cmEndCodes;
   1.223 +    le_uint16 *cmStartCodes;
   1.224 +    le_uint16 *cmIdDelta;
   1.225 +    le_uint16 *cmIdRangeOffset;
   1.226 +
   1.227 +    HEADTable *headTable;
   1.228 +
   1.229 +    HMTXTable *hmtxTable;
   1.230 +    le_uint16 numGlyphs;
   1.231 +    le_uint16 numOfLongHorMetrics;
   1.232 +
   1.233 +    FILE *file;
   1.234 +
   1.235 +};
   1.236 +
   1.237 +#endif
   1.238 +