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-2006, International Business Machines
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   Corporation and others.  All Rights Reserved.
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *******************************************************************************
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   file name:  GnomeFontInstance.h
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   created on: 08/30/2001
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   created by: Eric R. Mader
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __GNOMEFONTINSTANCE_H
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __GNOMEFONTINSTANCE_H
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <gnome.h>
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <ft2build.h>
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include FT_FREETYPE_H
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include FT_GLYPH_H
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <cairo.h>
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "layout/LETypes.h"
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "layout/LEFontInstance.h"
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "RenderingSurface.h"
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "FontTableCache.h"
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cmaps.h"
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass GnomeSurface : public RenderingSurface
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    GnomeSurface(GtkWidget *theWidget);
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~GnomeSurface();
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count,
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height);
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    GtkWidget *getWidget() const;
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void setWidget(GtkWidget *theWidget);
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    GtkWidget *fWidget;
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    cairo_t   *fCairo;
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass GnomeFontInstance : public LEFontInstance, protected FontTableCache
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru protected:
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FT_Face fFace;
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//  FT_Glyph fGlyph;
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    cairo_font_face_t *fCairoFace;
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fPointSize;
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fUnitsPerEM;
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fAscent;
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fDescent;
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fLeading;
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float fDeviceScaleX;
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float fDeviceScaleY;
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CMAPMapper *fMapper;
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual const void *readFontTable(LETag tableTag) const;
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual LEErrorCode initMapper();
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru public:
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status);
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~GnomeFontInstance();
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual const void *getFontTable(LETag tableTag) const;
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 getUnitsPerEM() const;
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 getAscent() const;
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 getDescent() const;
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 getLeading() const;
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float getXPixelsPerEm() const;
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float getYPixelsPerEm() const;
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float getScaleFactorX() const;
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    float getScaleFactorY() const;
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions,
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru				   le_int32 x, le_int32 y) const;
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline GtkWidget *GnomeSurface::getWidget() const
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fWidget;
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void GnomeSurface::setWidget(GtkWidget *theWidget)
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fWidget = theWidget;
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline FT_Instance GnomeFontInstance::getFont() const
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fInstance;
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline le_int32 GnomeFontInstance::getUnitsPerEM() const
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fUnitsPerEM;
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline le_int32 GnomeFontInstance::getAscent() const
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fAscent;
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline le_int32 GnomeFontInstance::getDescent() const
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fDescent;
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline le_int32 GnomeFontInstance::getLeading() const
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fLeading;
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fMapper->unicodeToGlyph(ch);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline float GnomeFontInstance::getXPixelsPerEm() const
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (float) fPointSize;
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline float GnomeFontInstance::getYPixelsPerEm() const
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return  (float) fPointSize;
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline float GnomeFontInstance::getScaleFactorX() const
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fDeviceScaleX;
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline float GnomeFontInstance::getScaleFactorY() const
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fDeviceScaleY;
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
173