3
*******************************************************************************
5
* Copyright (C) 1999-2001, International Business Machines
6
* Corporation and others. All Rights Reserved.
8
*******************************************************************************
9
* file name: RenderingFontInstance.h
11
* created on: 10/23/2001
12
* created by: Eric R. Mader
15
#ifndef __RENDERINGFONTINSTANCE_H
16
#define __RENDERINGFONTINSTANCE_H
19
#include "LEFontInstance.h"
22
#define TABLE_CACHE_INIT 5
23
#define TABLE_CACHE_GROW 5
25
struct TableCacheEntry
34
RFI_ILLEGAL_ARGUMENT_ERROR = 1,
35
RFI_FONT_FILE_NOT_FOUND_ERROR = 2,
36
RFI_MISSING_FONT_TABLE_ERROR = 3,
37
RFI_OUT_OF_MEMORY_ERROR = 4
40
class RenderingFontInstance : public LEFontInstance
51
TableCacheEntry *fTableCache;
52
le_int32 fTableCacheCurr;
53
le_int32 fTableCacheSize;
57
virtual RFIErrorCode initMapper();
58
virtual RFIErrorCode initFontTableCache();
59
virtual void flushFontTableCache();
60
virtual const void *readFontTable(LETag tableTag) const = 0;
63
RenderingFontInstance(void *surface, le_int16 pointSize);
65
virtual ~RenderingFontInstance();
67
virtual const void *getFontTable(LETag tableTag) const;
69
virtual le_bool canDisplay(LEUnicode32 ch) const
71
return fMapper->unicodeToGlyph(ch) != 0;
74
virtual le_int32 getUnitsPerEM() const
79
virtual le_int32 getLineHeight() const
81
return getAscent() + getDescent() + getLeading();
84
virtual le_int32 getAscent() const
89
virtual le_int32 getDescent() const
94
virtual le_int32 getLeading() const
99
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphID glyphs[]) const;
101
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
103
virtual le_int32 getName(le_uint16 platformID, le_uint16 scriptID, le_uint16 languageID, le_uint16 nameID, LEUnicode *name) const
105
// This is only used for CDAC fonts, and we'll have to loose that support anyhow...
106
//return (le_int32) fFontObject->getName(platformID, scriptID, languageID, nameID, name);
114
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
116
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
118
virtual const void setFont(void *surface) const
120
// default implementation is to ignore this
123
virtual void drawGlyphs(void *surface, LEGlyphID *glyphs, le_uint32 count, le_int32 *dx,
124
le_int32 x, le_int32 y, le_int32 width, le_int32 height) const = 0;
126
float getXPixelsPerEm() const
128
return (float) fPointSize;
131
float getYPixelsPerEm() const
133
return (float) fPointSize;
136
float xUnitsToPoints(float xUnits) const
138
return (xUnits * fPointSize) / (float) fUnitsPerEM;
141
float yUnitsToPoints(float yUnits) const
143
return (yUnits * fPointSize) / (float) fUnitsPerEM;
146
void unitsToPoints(LEPoint &units, LEPoint &points) const
148
points.fX = xUnitsToPoints(units.fX);
149
points.fY = yUnitsToPoints(units.fY);
152
float xPixelsToUnits(float xPixels) const
154
return (xPixels * fUnitsPerEM) / (float) fPointSize;
157
float yPixelsToUnits(float yPixels) const
159
return (yPixels * fUnitsPerEM) / (float) fPointSize;
162
void pixelsToUnits(LEPoint &pixels, LEPoint &units) const
164
units.fX = xPixelsToUnits(pixels.fX);
165
units.fY = yPixelsToUnits(pixels.fY);
168
void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
170
pixels.fX = xUnitsToPoints(xFunits);
171
pixels.fY = yUnitsToPoints(yFunits);