tesseract 3.04.01

training/GlyphLessFont.h

Go to the documentation of this file.
00001 /* I don't expect anyone to run this program, ever again.  It is
00002  * included primarily as documentation for how the GlyphLessFont was
00003  * created.
00004  */
00005 
00006 /* The OpenType data types, we'll duplicate the definitions so that
00007  * the code shall be (as far as possible) self-documenting simply by
00008  * referencing the OpenType specification. Note that the specification
00009  * is soemwhat inconsistent with regards to usage, naming and capitalisation
00010  * of the names for these data types.
00011  */
00012 typedef char BYTE;
00013 typedef char CHAR;
00014 typedef unsigned short USHORT;
00015 typedef short SHORT;
00016 typedef struct _uint24 {char top8;unsigned short bottom16;} UINT24;
00017 typedef unsigned long ULONG;
00018 typedef long LONG;
00019 typedef unsigned long Fixed;
00020 typedef SHORT FWORD;
00021 typedef USHORT UFWORD;
00022 typedef unsigned short F2DOT14;
00023 typedef struct _datetime {long upper;long lower;} LONGDATETIME;
00024 typedef char Tag[4];
00025 typedef USHORT GlyphId;
00026 typedef USHORT Offset;
00027 typedef struct _longHorMetric {USHORT advanceWidth;SHORT lsb;} longHorMetric;
00028 
00029 /* And now definitions for each of the OpenType tables we will wish to use */
00030 
00031 typedef struct {
00032     Fixed sfnt_version;
00033     USHORT numTables;
00034     USHORT searchRange;
00035     USHORT entrySelector;
00036     USHORT rangeShift;
00037 } Offset_Table;
00038 
00039 typedef struct {
00040     Tag tag;        /* The spec defines this as a ULONG,
00041                        but also as a 'Tag' in its own right */
00042     ULONG checkSum;
00043     ULONG offset;
00044     ULONG length;
00045 } TableRecord;
00046 
00047 typedef struct {
00048     USHORT version;
00049     USHORT numTables;
00050 } cmap_header;
00051 
00052 typedef struct {
00053     USHORT platformID;
00054     USHORT encodingID;
00055     ULONG Offset;
00056 } cmap_record;
00057 
00058 typedef struct {
00059     USHORT format;
00060     USHORT length;
00061     USHORT language;
00062     BYTE glyphIDArray[256];
00063 } format0_cmap_table;
00064 
00065 /* This structure only works for single segment format 4 tables,
00066    for multiple segments it must be constructed */
00067 typedef struct {
00068     USHORT format;
00069     USHORT length;
00070     USHORT language;
00071     USHORT segCountx2;
00072     USHORT searchRange;
00073     USHORT entrySelector;
00074     USHORT rangeShift;
00075     USHORT endcount;
00076     USHORT reservedPad;
00077     USHORT startCount;
00078     SHORT idDelta;
00079     USHORT idRangeOffset;
00080     USHORT glyphIdArray[2];
00081 } format4_cmap_table;
00082 
00083 typedef struct {
00084     USHORT format;
00085     USHORT length;
00086     USHORT language;
00087     USHORT firstCode;
00088     USHORT entryCount;
00089     USHORT glyphIDArray;
00090 } format6_cmap_table;
00091 
00092 typedef struct {
00093     cmap_header header;
00094     cmap_record records[2];
00095     format6_cmap_table AppleTable;
00096     format6_cmap_table MSTable;
00097 } cmap_table;
00098 
00099 typedef struct {
00100     Fixed version;
00101     Fixed FontRevision;
00102     ULONG checkSumAdjustment;
00103     ULONG MagicNumber;
00104     USHORT Flags;
00105     USHORT unitsPerEm;
00106     LONGDATETIME created;
00107     LONGDATETIME modified;
00108     SHORT xMin;
00109     SHORT yMin;
00110     SHORT xMax;
00111     SHORT yMax;
00112     USHORT macStyle;
00113     USHORT lowestRecPPEM;
00114     SHORT FontDirectionHint;
00115     SHORT indexToLocFormat;
00116     SHORT glyphDataFormat;
00117     SHORT PAD;
00118 } head_table;
00119 
00120 typedef struct {
00121     Fixed version;
00122     FWORD Ascender;
00123     FWORD Descender;
00124     FWORD LineGap;
00125     UFWORD advanceWidthMax;
00126     FWORD minLeftSideBearing;
00127     FWORD minRightSideBearing;
00128     FWORD xMaxExtent;
00129     SHORT caretSlopeRise;
00130     SHORT caretSlopeRun;
00131     SHORT caretOffset;
00132     SHORT reserved1;
00133     SHORT reserved2;
00134     SHORT reserved3;
00135     SHORT reserved4;
00136     SHORT metricDataFormat;
00137     USHORT numberOfHMetrics;
00138 } hhea_table;
00139 
00140 typedef struct {
00141     longHorMetric hMetrics[2];
00142 } hmtx_table;
00143 
00144 typedef struct {
00145     Fixed version;
00146     USHORT numGlyphs;
00147     USHORT maxPoints;
00148     USHORT maxContours;
00149     USHORT maxCompositePoints;
00150     USHORT maxCompositeContours;
00151     USHORT maxZones;
00152     USHORT maxTwilightPoints;
00153     USHORT maxStorage;
00154     USHORT maxFunctionDefs;
00155     USHORT maxInstructionDefs;
00156     USHORT maxStackElements;
00157     USHORT maxSizeOfInstructions;
00158     USHORT maxComponentElements;
00159     USHORT maxComponentDepth;
00160 } maxp_table;
00161 
00162 typedef struct {
00163     USHORT platformID;
00164     USHORT encodingID;
00165     USHORT languageID;
00166     USHORT nameID;
00167     USHORT length;
00168     USHORT offset;
00169 } NameRecord;
00170 
00171 typedef struct {
00172     USHORT format;
00173     USHORT count;
00174     USHORT stringOffset;
00175     NameRecord nameRecord[3];
00176 } name_table;
00177 
00178 typedef struct {
00179     USHORT version;
00180     SHORT xAvgCharWidth;
00181     USHORT usWeightClass;
00182     USHORT usWidthClass;
00183     USHORT fsType;
00184     SHORT ySubscriptXSize;
00185     SHORT ySubscriptYSize;
00186     SHORT ySubscriptXOffset;
00187     SHORT ySubscriptYOffset;
00188     SHORT ySuperscriptXSize;
00189     SHORT ySuperscriptYSize;
00190     SHORT ySuperscriptXOffset;
00191     SHORT ySuperscriptYOffset;
00192     SHORT yStrikeoutSize;
00193     SHORT yStrikeoutPosition;
00194     SHORT sFamilyClass;
00195     BYTE panose[10];
00196     ULONG ulUnicodeRange1;
00197     ULONG ulUnicodeRange2;
00198     ULONG ulUnicodeRange3;
00199     ULONG ulUnicodeRange4;
00200     CHAR achVendID[4];
00201     USHORT fsSelection;
00202     USHORT usFirstCharIndex;
00203     USHORT usLastCharIndex;
00204     SHORT sTypoAscender;
00205     SHORT sTypoDescender;
00206     SHORT sTypoLineGap;
00207     USHORT usWinAscent;
00208     USHORT usWinDescent;
00209     ULONG ulCodePageRange1;
00210     ULONG ulCodePageRange2;
00211     SHORT sxHeight;
00212     SHORT sCapHeight;
00213     USHORT usDefaultChar;
00214     USHORT usBreakChar;
00215     USHORT usMaxContent;
00216 } OS2_table;
00217 
00218 typedef struct {
00219     Fixed version;
00220     Fixed italicAngle;
00221     FWORD underlinePosition;
00222     FWORD underlineThickness;
00223     ULONG isFixedPitch;
00224     ULONG minMemType42;
00225     ULONG maxMemType42;
00226     ULONG minMemType1;
00227     ULONG maxMemType1;
00228 } post_table;
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines