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"
29
PFI_FONT_FILE_NOT_FOUND_ERROR = 1,
30
PFI_MISSING_FONT_TABLE_ERROR = 2,
31
PFI_OUT_OF_MEMORY_ERROR = 3
35
typedef enum PFIErrorCode PFIErrorCode;
38
class PortableFontInstance : public LEFontInstance
46
const SFNTDirectory *fDirectory;
48
CMAPMapper *fCMAPMapper;
50
const HMTXTable *fHMTXTable;
52
le_uint16 fNumLongHorMetrics;
54
const DirectoryEntry *findTable(LETag tag) const;
55
const void *readTable(LETag tag, le_uint32 *length) const;
56
void deleteTable(const void *table) const;
58
CMAPMapper *PortableFontInstance::findUnicodeMapper();
61
PortableFontInstance(char *fileName, float pointSize, PFIErrorCode &status);
63
virtual ~PortableFontInstance();
65
virtual const void *getFontTable(LETag tableTag) const
69
return readTable(tableTag, &length);
72
virtual le_bool canDisplay(LEUnicode32 ch) const
74
return (le_bool) fCMAPMapper->unicodeToGlyph(ch) != 0;
77
virtual le_int32 getUnitsPerEM() const
79
return (le_int32) fUnitsPerEM;
82
virtual le_int32 getLineHeight() const
84
// this is a cheap hack!!
85
return (le_int32) fPointSize;
88
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphID glyphs[]) const;
90
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
92
virtual le_int32 getName(le_uint16 platformID, le_uint16 scriptID, le_uint16 languageID, le_uint16 nameID, LEUnicode *name) const
94
// This is only used for CDAC fonts, and we'll have to loose that support anyhow...
95
//return (le_int32) fFontObject->getName(platformID, scriptID, languageID, nameID, name);
103
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
105
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
107
float getXPixelsPerEm() const
112
float getYPixelsPerEm() const
117
float xUnitsToPoints(float xUnits) const
119
return (xUnits * fPointSize) / fUnitsPerEM;
122
float yUnitsToPoints(float yUnits) const
124
return (yUnits * fPointSize) / fUnitsPerEM;
127
void unitsToPoints(LEPoint &units, LEPoint &points) const
129
points.fX = xUnitsToPoints(units.fX);
130
points.fY = yUnitsToPoints(units.fY);
133
float xPixelsToUnits(float xPixels) const
135
return (xPixels * fUnitsPerEM) / fPointSize;
138
float yPixelsToUnits(float yPixels) const
140
return (yPixels * fUnitsPerEM) / fPointSize;
143
void pixelsToUnits(LEPoint &pixels, LEPoint &units) const
145
units.fX = xPixelsToUnits(pixels.fX);
146
units.fY = yPixelsToUnits(pixels.fY);
149
void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;