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