3
*******************************************************************************
5
* Copyright (C) 1999-2001, International Business Machines
6
* Corporation and others. All Rights Reserved.
8
*******************************************************************************
9
* file name: PortableFontInstance.h
11
* created on: 11/12/1999
12
* created by: Eric R. Mader
15
#ifndef __PORTABLEFONTINSTANCE_H
16
#define __PORTABLEFONTINSTANCE_H
21
#include "LEFontInstance.h"
26
#define TABLE_CACHE_INIT 5
27
#define TABLE_CACHE_GROW 5
29
struct TableCacheEntry
38
PFI_FONT_FILE_NOT_FOUND_ERROR = 1,
39
PFI_MISSING_FONT_TABLE_ERROR = 2,
40
PFI_OUT_OF_MEMORY_ERROR = 3
44
typedef enum PFIErrorCode PFIErrorCode;
47
class PortableFontInstance : public LEFontInstance
55
const SFNTDirectory *fDirectory;
59
TableCacheEntry *fTableCache;
60
le_int32 fTableCacheCurr;
61
le_int32 fTableCacheSize;
63
CMAPMapper *fCMAPMapper;
65
const HMTXTable *fHMTXTable;
67
le_uint16 fNumLongHorMetrics;
69
static le_int8 highBit(le_int32 value);
71
PFIErrorCode PortableFontInstance::initFontTableCache();
72
void PortableFontInstance::flushFontTableCache();
74
const DirectoryEntry *findTable(LETag tag) const;
75
const void *readTable(LETag tag, le_uint32 *length) const;
76
void deleteTable(const void *table) const;
78
CMAPMapper *PortableFontInstance::findUnicodeMapper();
81
PortableFontInstance(char *fileName, float pointSize, PFIErrorCode &status);
83
virtual ~PortableFontInstance();
85
virtual const void *getFontTable(LETag tableTag) const;
87
virtual le_bool canDisplay(LEUnicode32 ch) const
89
return (le_bool) fCMAPMapper->unicodeToGlyph(ch) != 0;
92
virtual le_int32 getUnitsPerEM() const
94
return (le_int32) fUnitsPerEM;
97
virtual le_int32 getLineHeight() const
99
// this is a cheap hack!!
100
return (le_int32) fPointSize;
103
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphID glyphs[]) const;
105
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
107
virtual le_int32 getName(le_uint16 platformID, le_uint16 scriptID, le_uint16 languageID, le_uint16 nameID, LEUnicode *name) const
109
// This is only used for CDAC fonts, and we'll have to loose that support anyhow...
110
//return (le_int32) fFontObject->getName(platformID, scriptID, languageID, nameID, name);
118
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
120
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
122
float getXPixelsPerEm() const
127
float getYPixelsPerEm() const
132
float xUnitsToPoints(float xUnits) const
134
return (xUnits * fPointSize) / fUnitsPerEM;
137
float yUnitsToPoints(float yUnits) const
139
return (yUnits * fPointSize) / fUnitsPerEM;
142
void unitsToPoints(LEPoint &units, LEPoint &points) const
144
points.fX = xUnitsToPoints(units.fX);
145
points.fY = yUnitsToPoints(units.fY);
148
float xPixelsToUnits(float xPixels) const
150
return (xPixels * fUnitsPerEM) / fPointSize;
153
float yPixelsToUnits(float yPixels) const
155
return (yPixels * fUnitsPerEM) / fPointSize;
158
void pixelsToUnits(LEPoint &pixels, LEPoint &units) const
160
units.fX = xPixelsToUnits(pixels.fX);
161
units.fY = yPixelsToUnits(pixels.fY);
164
void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;