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