1 2/* 3 ******************************************************************************* 4 * 5 * © 2016 and later: Unicode, Inc. and others. 6 * License & terms of use: http://www.unicode.org/copyright.html#License 7 * 8 ******************************************************************************* 9 ******************************************************************************* 10 * 11 * Copyright (C) 1999-2003, International Business Machines 12 * Corporation and others. All Rights Reserved. 13 * 14 ******************************************************************************* 15 * file name: GDIFontInstance.h 16 * 17 * created on: 08/09/2000 18 * created by: Eric R. Mader 19 */ 20 21#ifndef __GDIFONTINSTANCE_H 22#define __GDIFONTINSTANCE_H 23 24#include <windows.h> 25 26#include "layout/LETypes.h" 27#include "layout/LEFontInstance.h" 28#include "RenderingSurface.h" 29#include "FontTableCache.h" 30#include "cmaps.h" 31 32class GDIFontInstance; 33 34class GDISurface : public RenderingSurface 35{ 36public: 37 GDISurface(HDC theHDC); 38 virtual ~GDISurface(); 39 40 virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, 41 const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); 42 43 void setFont(const GDIFontInstance *font); 44 HDC getHDC() const; 45 void setHDC(HDC theHDC); 46 47private: 48 HDC fHdc; 49 const GDIFontInstance *fCurrentFont; 50}; 51 52inline HDC GDISurface::getHDC() const 53{ 54 return fHdc; 55} 56 57class GDIFontInstance : public LEFontInstance, protected FontTableCache 58{ 59protected: 60 GDISurface *fSurface; 61 HFONT fFont; 62 63 le_int32 fPointSize; 64 le_int32 fUnitsPerEM; 65 le_int32 fAscent; 66 le_int32 fDescent; 67 le_int32 fLeading; 68 69 float fDeviceScaleX; 70 float fDeviceScaleY; 71 72 CMAPMapper *fMapper; 73 74 virtual const void *readFontTable(LETag tableTag) const; 75 76 virtual LEErrorCode initMapper(); 77 78public: 79 GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status); 80 GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status); 81 //GDIFontInstance(GDISurface *surface, le_int16 pointSize); 82 83 virtual ~GDIFontInstance(); 84 85 HFONT getFont() const; 86 87 virtual const void *getFontTable(LETag tableTag) const; 88 89 virtual le_int32 getUnitsPerEM() const; 90 91 virtual le_int32 getAscent() const; 92 93 virtual le_int32 getDescent() const; 94 95 virtual le_int32 getLeading() const; 96 97 virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; 98 99 virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; 100 101 virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; 102 103 float getXPixelsPerEm() const; 104 105 float getYPixelsPerEm() const; 106 107 float getScaleFactorX() const; 108 109 float getScaleFactorY() const; 110}; 111 112inline HFONT GDIFontInstance::getFont() const 113{ 114 return fFont; 115} 116 117inline le_int32 GDIFontInstance::getUnitsPerEM() const 118{ 119 return fUnitsPerEM; 120} 121 122inline le_int32 GDIFontInstance::getAscent() const 123{ 124 return fAscent; 125} 126 127inline le_int32 GDIFontInstance::getDescent() const 128{ 129 return fDescent; 130} 131 132inline le_int32 GDIFontInstance::getLeading() const 133{ 134 return fLeading; 135} 136 137inline LEGlyphID GDIFontInstance::mapCharToGlyph(LEUnicode32 ch) const 138{ 139 return fMapper->unicodeToGlyph(ch); 140} 141 142inline float GDIFontInstance::getXPixelsPerEm() const 143{ 144 return (float) fPointSize; 145} 146 147inline float GDIFontInstance::getYPixelsPerEm() const 148{ 149 return (float) fPointSize; 150} 151 152inline float GDIFontInstance::getScaleFactorX() const 153{ 154 return fDeviceScaleX; 155} 156 157inline float GDIFontInstance::getScaleFactorY() const 158{ 159 return fDeviceScaleY; 160} 161 162#endif 163