Diffstat (limited to 'freetype/fontfactoryttf_qws.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | freetype/fontfactoryttf_qws.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/freetype/fontfactoryttf_qws.cpp b/freetype/fontfactoryttf_qws.cpp index 5aa53fb..1f082a9 100644 --- a/freetype/fontfactoryttf_qws.cpp +++ b/freetype/fontfactoryttf_qws.cpp | |||
@@ -24,29 +24,28 @@ | |||
24 | #ifdef QT_NO_FREETYPE | 24 | #ifdef QT_NO_FREETYPE |
25 | 25 | ||
26 | #include "qfontdata_p.h" | 26 | #include "qfontdata_p.h" |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | 29 | ||
30 | #define FLOOR(x) ((x) & -64) | 30 | #define FLOOR(x) ((x) & -64) |
31 | #define CEIL(x) (((x)+63) & -64) | 31 | #define CEIL(x) (((x)+63) & -64) |
32 | #define TRUNC(x) ((x) >> 6) | 32 | #define TRUNC(x) ((x) >> 6) |
33 | 33 | ||
34 | 34 | ||
35 | extern "C" { | 35 | extern "C" { |
36 | #include <ft2build.h> | 36 | #include <freetype/freetype.h> |
37 | #include FT_FREETYPE_H | 37 | #include <freetype/ftglyph.h> |
38 | #include FT_GLYPH_H | 38 | #include <freetype/ftoutln.h> |
39 | #include FT_OUTLINE_H | 39 | #include <freetype/ftbbox.h> |
40 | #include FT_BBOX_H | ||
41 | } | 40 | } |
42 | 41 | ||
43 | class QDiskFontFT : public QDiskFontPrivate { | 42 | class QDiskFontFT : public QDiskFontPrivate { |
44 | public: | 43 | public: |
45 | FT_Face face; | 44 | FT_Face face; |
46 | }; | 45 | }; |
47 | 46 | ||
48 | class QRenderedFontFT : public QRenderedFont { | 47 | class QRenderedFontFT : public QRenderedFont { |
49 | public: | 48 | public: |
50 | QRenderedFontFT(QDiskFont* f, const QFontDef &d) : | 49 | QRenderedFontFT(QDiskFont* f, const QFontDef &d) : |
51 | QRenderedFont(f,d) | 50 | QRenderedFont(f,d) |
52 | { | 51 | { |
@@ -60,24 +59,26 @@ public: | |||
60 | fdescent=-FLOOR(myface->size->metrics.descender)/64-1; | 59 | fdescent=-FLOOR(myface->size->metrics.descender)/64-1; |
61 | fmaxwidth=CEIL(myface->size->metrics.max_advance)/64; | 60 | fmaxwidth=CEIL(myface->size->metrics.max_advance)/64; |
62 | fleading=CEIL(myface->size->metrics.height)/64 | 61 | fleading=CEIL(myface->size->metrics.height)/64 |
63 | - fascent - fdescent + 1; | 62 | - fascent - fdescent + 1; |
64 | 63 | ||
65 | // FT has these in font units | 64 | // FT has these in font units |
66 | funderlinepos = ptsize/200+1; | 65 | funderlinepos = ptsize/200+1; |
67 | funderlinewidth = ptsize/200+1; | 66 | funderlinewidth = ptsize/200+1; |
68 | } | 67 | } |
69 | 68 | ||
70 | ~QRenderedFontFT() | 69 | ~QRenderedFontFT() |
71 | { | 70 | { |
71 | // When inter-process glyph sharing is implemented, the glyph data | ||
72 | // for this font can be dereferenced here. | ||
72 | } | 73 | } |
73 | 74 | ||
74 | bool unicode(int & i) const | 75 | bool unicode(int & i) const |
75 | { | 76 | { |
76 | int ret; | 77 | int ret; |
77 | 78 | ||
78 | FT_Face theface=myface; | 79 | FT_Face theface=myface; |
79 | 80 | ||
80 | ret=FT_Get_Char_Index(theface,i); | 81 | ret=FT_Get_Char_Index(theface,i); |
81 | 82 | ||
82 | if (ret==0) { | 83 | if (ret==0) { |
83 | return FALSE; | 84 | return FALSE; |
@@ -99,25 +100,25 @@ public: | |||
99 | 100 | ||
100 | int index = ch.unicode(); | 101 | int index = ch.unicode(); |
101 | if ( !unicode(index) ) | 102 | if ( !unicode(index) ) |
102 | index = 0; | 103 | index = 0; |
103 | QGlyph result; | 104 | QGlyph result; |
104 | 105 | ||
105 | FT_Error err; | 106 | FT_Error err; |
106 | 107 | ||
107 | err=FT_Load_Glyph(myface,index,FT_LOAD_DEFAULT); | 108 | err=FT_Load_Glyph(myface,index,FT_LOAD_DEFAULT); |
108 | if(err) | 109 | if(err) |
109 | qFatal("Load glyph error %x",err); | 110 | qFatal("Load glyph error %x",err); |
110 | 111 | ||
111 | int width,height,pitch,size = 0; | 112 | int width=0,height=0,pitch=0,size=0; |
112 | FT_Glyph glyph; | 113 | FT_Glyph glyph; |
113 | err=FT_Get_Glyph( myface->glyph, &glyph ); | 114 | err=FT_Get_Glyph( myface->glyph, &glyph ); |
114 | if(err) | 115 | if(err) |
115 | qFatal("Get glyph error %x",err); | 116 | qFatal("Get glyph error %x",err); |
116 | 117 | ||
117 | FT_BBox bbox; | 118 | FT_BBox bbox; |
118 | FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_gridfit, &bbox); | 119 | FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_gridfit, &bbox); |
119 | 120 | ||
120 | FT_Vector origin; | 121 | FT_Vector origin; |
121 | origin.x = -bbox.xMin; | 122 | origin.x = -bbox.xMin; |
122 | origin.y = -bbox.yMin; | 123 | origin.y = -bbox.yMin; |
123 | 124 | ||
@@ -146,24 +147,30 @@ public: | |||
146 | } | 147 | } |
147 | 148 | ||
148 | result.metrics = new QGlyphMetrics; | 149 | result.metrics = new QGlyphMetrics; |
149 | memset((char*)result.metrics, 0, sizeof(QGlyphMetrics)); | 150 | memset((char*)result.metrics, 0, sizeof(QGlyphMetrics)); |
150 | result.metrics->bearingx=myface->glyph->metrics.horiBearingX/64; | 151 | result.metrics->bearingx=myface->glyph->metrics.horiBearingX/64; |
151 | result.metrics->advance=myface->glyph->metrics.horiAdvance/64; | 152 | result.metrics->advance=myface->glyph->metrics.horiAdvance/64; |
152 | result.metrics->bearingy=myface->glyph->metrics.horiBearingY/64; | 153 | result.metrics->bearingy=myface->glyph->metrics.horiBearingY/64; |
153 | 154 | ||
154 | result.metrics->linestep=pitch; | 155 | result.metrics->linestep=pitch; |
155 | result.metrics->width=width; | 156 | result.metrics->width=width; |
156 | result.metrics->height=height; | 157 | result.metrics->height=height; |
157 | 158 | ||
159 | // XXX memory manage me | ||
160 | // At some point inter-process glyph data sharing must be implemented | ||
161 | // and the flag below can be set to prevent Qt from deleting the glyph | ||
162 | // data. | ||
163 | // result.metrics->flags = QGlyphMetrics::RendererOwnsData; | ||
164 | |||
158 | FT_Done_Glyph( glyph ); | 165 | FT_Done_Glyph( glyph ); |
159 | 166 | ||
160 | return result; | 167 | return result; |
161 | } | 168 | } |
162 | 169 | ||
163 | FT_Face myface; | 170 | FT_Face myface; |
164 | 171 | ||
165 | private: | 172 | private: |
166 | void selectThisSize() | 173 | void selectThisSize() |
167 | { | 174 | { |
168 | int psize=(ptsize<<6)/10; | 175 | int psize=(ptsize<<6)/10; |
169 | 176 | ||