1 |
From d83bc4d9921afd31f1afddc52f39951bb686e60a Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Thu, 10 Mar 2011 15:59:44 +0000 |
4 |
Subject: [PATCH] Related: rhbz#680460 reorganize this to make it inheritable |
5 |
|
6 |
--- |
7 |
vcl/inc/vcl/fontmanager.hxx | 2 +- |
8 |
vcl/inc/vcl/glyphcache.hxx | 5 +-- |
9 |
vcl/inc/vcl/impfont.hxx | 25 ++++++++++----------- |
10 |
vcl/source/glyphs/gcach_ftyp.cxx | 18 ++++++++++----- |
11 |
vcl/source/glyphs/gcach_ftyp.hxx | 4 ++- |
12 |
vcl/source/glyphs/glyphcache.cxx | 3 +- |
13 |
vcl/unx/source/fontmanager/fontconfig.cxx | 32 ++++++++++++++-------------- |
14 |
vcl/unx/source/gdi/salgdi3.cxx | 17 ++++++--------- |
15 |
8 files changed, 55 insertions(+), 51 deletions(-) |
16 |
|
17 |
diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx |
18 |
index 6c76eea..103cd92 100644 |
19 |
--- a/vcl/inc/vcl/fontmanager.hxx |
20 |
+++ b/vcl/inc/vcl/fontmanager.hxx |
21 |
@@ -733,7 +733,7 @@ public: |
22 |
false else |
23 |
*/ |
24 |
bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ); |
25 |
- bool getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*), ImplFontOptions& rResult ) const; |
26 |
+ ImplFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*)) const; |
27 |
|
28 |
rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, |
29 |
const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight, |
30 |
diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx |
31 |
index 8714697..1c03759 100644 |
32 |
--- a/vcl/inc/vcl/glyphcache.hxx |
33 |
+++ b/vcl/inc/vcl/glyphcache.hxx |
34 |
@@ -187,7 +187,7 @@ public: |
35 |
virtual bool TestFont() const { return true; } |
36 |
virtual void* GetFtFace() const { return 0; } |
37 |
virtual int GetLoadFlags() const { return 0; } |
38 |
- virtual void SetFontOptions( const ImplFontOptions&) {} |
39 |
+ virtual void SetFontOptions( const ImplFontOptions*) {} |
40 |
virtual bool NeedsArtificialBold() const { return false; } |
41 |
virtual bool NeedsArtificialItalic() const { return false; } |
42 |
|
43 |
@@ -266,9 +266,8 @@ class VCL_DLLPUBLIC ImplServerFontEntry : public ImplFontEntry |
44 |
{ |
45 |
private: |
46 |
ServerFont* mpServerFont; |
47 |
- ImplFontOptions maFontOptions; |
48 |
+ ImplFontOptions* mpFontOptions; |
49 |
bool mbGotFontOptions; |
50 |
- bool mbValidFontOptions; |
51 |
|
52 |
public: |
53 |
ImplServerFontEntry( ImplFontSelectData& ); |
54 |
diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx |
55 |
index b7a0368..fa8a837 100644 |
56 |
--- a/vcl/inc/vcl/impfont.hxx |
57 |
+++ b/vcl/inc/vcl/impfont.hxx |
58 |
@@ -135,7 +135,7 @@ public: |
59 |
}; |
60 |
|
61 |
// ------------------ |
62 |
-// - ImplFontHints - |
63 |
+// - ImplFontOptions - |
64 |
// ------------------ |
65 |
|
66 |
class ImplFontOptions |
67 |
@@ -154,19 +154,18 @@ public: |
68 |
meHinting(HINTING_DONTKNOW), |
69 |
meHintStyle(HINT_SLIGHT) |
70 |
{} |
71 |
- ImplFontOptions( FontEmbeddedBitmap eEmbeddedBitmap, FontAntiAlias eAntiAlias, |
72 |
- FontAutoHint eAutoHint, FontHinting eHinting, FontHintStyle eHintStyle) : |
73 |
- meEmbeddedBitmap(eEmbeddedBitmap), |
74 |
- meAntiAlias(eAntiAlias), |
75 |
- meAutoHint(eAutoHint), |
76 |
- meHinting(eHinting), |
77 |
- meHintStyle(eHintStyle) |
78 |
+ virtual ~ImplFontOptions() |
79 |
{} |
80 |
- FontAutoHint GetUseAutoHint() const { return meAutoHint; } |
81 |
- FontHintStyle GetHintStyle() const { return meHintStyle; } |
82 |
- bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; } |
83 |
- bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; } |
84 |
- bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); } |
85 |
+ FontAutoHint GetUseAutoHint() const |
86 |
+ { return meAutoHint; } |
87 |
+ FontHintStyle GetHintStyle() const |
88 |
+ { return meHintStyle; } |
89 |
+ bool DontUseEmbeddedBitmaps() const |
90 |
+ { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; } |
91 |
+ bool DontUseAntiAlias() const |
92 |
+ { return meAntiAlias == ANTIALIAS_FALSE; } |
93 |
+ bool DontUseHinting() const |
94 |
+ { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); } |
95 |
}; |
96 |
|
97 |
// ------------------- |
98 |
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx |
99 |
index 2db53a5..2236bad 100644 |
100 |
--- a/vcl/source/glyphs/gcach_ftyp.cxx |
101 |
+++ b/vcl/source/glyphs/gcach_ftyp.cxx |
102 |
@@ -768,6 +768,7 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn |
103 |
mpFontInfo( pFI ), |
104 |
maFaceFT( NULL ), |
105 |
maSizeFT( NULL ), |
106 |
+ mpFontOptions( NULL ), |
107 |
mbFaceOk( false ), |
108 |
maRecodeConverter( NULL ), |
109 |
mpLayoutEngine( NULL ) |
110 |
@@ -913,9 +914,14 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn |
111 |
mnLoadFlags |= FT_LOAD_NO_BITMAP; |
112 |
} |
113 |
|
114 |
-void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions) |
115 |
+void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions) |
116 |
{ |
117 |
- FontAutoHint eHint = rFontOptions.GetUseAutoHint(); |
118 |
+ mpFontOptions = pFontOptions; |
119 |
+ |
120 |
+ if (!mpFontOptions) |
121 |
+ return; |
122 |
+ |
123 |
+ FontAutoHint eHint = mpFontOptions->GetUseAutoHint(); |
124 |
if( eHint == AUTOHINT_DONTKNOW ) |
125 |
eHint = mbUseGamma ? AUTOHINT_TRUE : AUTOHINT_FALSE; |
126 |
|
127 |
@@ -926,11 +932,11 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions) |
128 |
mnLoadFlags |= FT_LOAD_NO_HINTING; |
129 |
mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334# |
130 |
|
131 |
- if( rFontOptions.DontUseAntiAlias() ) |
132 |
+ if( mpFontOptions->DontUseAntiAlias() ) |
133 |
mnPrioAntiAlias = 0; |
134 |
- if( rFontOptions.DontUseEmbeddedBitmaps() ) |
135 |
+ if( mpFontOptions->DontUseEmbeddedBitmaps() ) |
136 |
mnPrioEmbedded = 0; |
137 |
- if( rFontOptions.DontUseHinting() ) |
138 |
+ if( mpFontOptions->DontUseHinting() ) |
139 |
mnPrioAutoHint = 0; |
140 |
|
141 |
#if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER) |
142 |
@@ -942,7 +948,7 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions) |
143 |
if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103)) |
144 |
{ |
145 |
mnLoadFlags |= FT_LOAD_TARGET_NORMAL; |
146 |
- switch( rFontOptions.GetHintStyle() ) |
147 |
+ switch( mpFontOptions->GetHintStyle() ) |
148 |
{ |
149 |
case HINT_NONE: |
150 |
mnLoadFlags |= FT_LOAD_NO_HINTING; |
151 |
diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx |
152 |
index cf2284c..6069388 100644 |
153 |
--- a/vcl/source/glyphs/gcach_ftyp.hxx |
154 |
+++ b/vcl/source/glyphs/gcach_ftyp.hxx |
155 |
@@ -186,7 +186,7 @@ public: |
156 |
virtual int GetFontFaceNum() const { return mpFontInfo->GetFaceNum(); } |
157 |
virtual bool TestFont() const; |
158 |
virtual void* GetFtFace() const; |
159 |
- virtual void SetFontOptions( const ImplFontOptions&); |
160 |
+ virtual void SetFontOptions( const ImplFontOptions*); |
161 |
virtual int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); } |
162 |
virtual bool NeedsArtificialBold() const { return mbArtBold; } |
163 |
virtual bool NeedsArtificialItalic() const { return mbArtItalic; } |
164 |
@@ -233,6 +233,8 @@ private: |
165 |
FT_FaceRec_* maFaceFT; |
166 |
FT_SizeRec_* maSizeFT; |
167 |
|
168 |
+ const ImplFontOptions* mpFontOptions; |
169 |
+ |
170 |
bool mbFaceOk; |
171 |
bool mbArtItalic; |
172 |
bool mbArtBold; |
173 |
diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx |
174 |
index 8ad5a87..9668a50 100644 |
175 |
--- a/vcl/source/glyphs/glyphcache.cxx |
176 |
+++ b/vcl/source/glyphs/glyphcache.cxx |
177 |
@@ -522,8 +522,8 @@ bool ServerFont::IsGlyphInvisible( int nGlyphIndex ) |
178 |
ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD ) |
179 |
: ImplFontEntry( rFSD ) |
180 |
, mpServerFont( NULL ) |
181 |
+, mpFontOptions( NULL ) |
182 |
, mbGotFontOptions( false ) |
183 |
-, mbValidFontOptions( false ) |
184 |
{} |
185 |
|
186 |
// ----------------------------------------------------------------------- |
187 |
@@ -531,6 +531,7 @@ ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD ) |
188 |
ImplServerFontEntry::~ImplServerFontEntry() |
189 |
{ |
190 |
// TODO: remove the ServerFont here instead of in the GlyphCache |
191 |
+ delete mpFontOptions; |
192 |
} |
193 |
|
194 |
// ======================================================================= |
195 |
diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx |
196 |
index 0dd5260..3c2f636 100644 |
197 |
--- a/vcl/unx/source/fontmanager/fontconfig.cxx |
198 |
+++ b/vcl/unx/source/fontmanager/fontconfig.cxx |
199 |
@@ -1093,17 +1093,17 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName, |
200 |
return aName; |
201 |
} |
202 |
|
203 |
-bool PrintFontManager::getFontOptions( |
204 |
- const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*), |
205 |
- ImplFontOptions& rOptions) const |
206 |
+ImplFontOptions* PrintFontManager::getFontOptions( |
207 |
+ const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*)) const |
208 |
{ |
209 |
#ifndef ENABLE_FONTCONFIG |
210 |
- return false; |
211 |
+ return NULL; |
212 |
#else // ENABLE_FONTCONFIG |
213 |
FontCfgWrapper& rWrapper = FontCfgWrapper::get(); |
214 |
if( ! rWrapper.isValid() ) |
215 |
- return false; |
216 |
+ return NULL; |
217 |
|
218 |
+ ImplFontOptions *pOptions = NULL; |
219 |
FcConfig* pConfig = rWrapper.FcConfigGetCurrent(); |
220 |
FcPattern* pPattern = rWrapper.FcPatternCreate(); |
221 |
|
222 |
@@ -1144,22 +1144,24 @@ bool PrintFontManager::getFontOptions( |
223 |
FC_HINTING, 0, &hinting); |
224 |
/*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger( pSet->fonts[0], |
225 |
FC_HINT_STYLE, 0, &hintstyle); |
226 |
+ |
227 |
+ pOptions = new ImplFontOptions; |
228 |
|
229 |
if( eEmbeddedBitmap == FcResultMatch ) |
230 |
- rOptions.meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE; |
231 |
+ pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE; |
232 |
if( eAntialias == FcResultMatch ) |
233 |
- rOptions.meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE; |
234 |
+ pOptions->meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE; |
235 |
if( eAutoHint == FcResultMatch ) |
236 |
- rOptions.meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE; |
237 |
+ pOptions->meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE; |
238 |
if( eHinting == FcResultMatch ) |
239 |
- rOptions.meHinting = hinting ? HINTING_TRUE : HINTING_FALSE; |
240 |
+ pOptions->meHinting = hinting ? HINTING_TRUE : HINTING_FALSE; |
241 |
switch (hintstyle) |
242 |
{ |
243 |
- case FC_HINT_NONE: rOptions.meHintStyle = HINT_NONE; break; |
244 |
- case FC_HINT_SLIGHT: rOptions.meHintStyle = HINT_SLIGHT; break; |
245 |
- case FC_HINT_MEDIUM: rOptions.meHintStyle = HINT_MEDIUM; break; |
246 |
+ case FC_HINT_NONE: pOptions->meHintStyle = HINT_NONE; break; |
247 |
+ case FC_HINT_SLIGHT: pOptions->meHintStyle = HINT_SLIGHT; break; |
248 |
+ case FC_HINT_MEDIUM: pOptions->meHintStyle = HINT_MEDIUM; break; |
249 |
default: // fall through |
250 |
- case FC_HINT_FULL: rOptions.meHintStyle = HINT_FULL; break; |
251 |
+ case FC_HINT_FULL: pOptions->meHintStyle = HINT_FULL; break; |
252 |
} |
253 |
} |
254 |
// info: destroying the pSet destroys pResult implicitly |
255 |
@@ -1170,9 +1172,7 @@ bool PrintFontManager::getFontOptions( |
256 |
// cleanup |
257 |
rWrapper.FcPatternDestroy( pPattern ); |
258 |
|
259 |
- // TODO: return true only if non-default font options are set |
260 |
- const bool bOK = (pResult != NULL); |
261 |
- return bOK; |
262 |
+ return pOptions; |
263 |
#endif |
264 |
} |
265 |
|
266 |
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx |
267 |
index 9834028..6de93fe 100644 |
268 |
--- a/vcl/unx/source/gdi/salgdi3.cxx |
269 |
+++ b/vcl/unx/source/gdi/salgdi3.cxx |
270 |
@@ -632,22 +632,21 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev |
271 |
return false; |
272 |
} |
273 |
|
274 |
+ImplFontOptions* GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize); |
275 |
+ |
276 |
void ImplServerFontEntry::HandleFontOptions( void ) |
277 |
{ |
278 |
- bool GetFCFontOptions( const ImplFontAttributes&, int nSize, ImplFontOptions& ); |
279 |
- |
280 |
if( !mpServerFont ) |
281 |
return; |
282 |
if( !mbGotFontOptions ) |
283 |
{ |
284 |
// get and cache the font options |
285 |
mbGotFontOptions = true; |
286 |
- mbValidFontOptions = GetFCFontOptions( *maFontSelData.mpFontData, |
287 |
- maFontSelData.mnHeight, maFontOptions ); |
288 |
+ mpFontOptions = GetFCFontOptions( *maFontSelData.mpFontData, |
289 |
+ maFontSelData.mnHeight ); |
290 |
} |
291 |
// apply the font options |
292 |
- if( mbValidFontOptions ) |
293 |
- mpServerFont->SetFontOptions( maFontOptions ); |
294 |
+ mpServerFont->SetFontOptions( mpFontOptions ); |
295 |
} |
296 |
|
297 |
//-------------------------------------------------------------------------- |
298 |
@@ -1636,8 +1635,7 @@ void cairosubcallback( void* pPattern ) |
299 |
rCairo.ft_font_options_substitute( pFontOptions, pPattern ); |
300 |
} |
301 |
|
302 |
-bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, |
303 |
- ImplFontOptions& rFontOptions) |
304 |
+ImplFontOptions* GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize) |
305 |
{ |
306 |
// TODO: get rid of these insane enum-conversions |
307 |
// e.g. by using the classic vclenum values inside VCL |
308 |
@@ -1734,8 +1732,7 @@ bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, |
309 |
} |
310 |
|
311 |
const psp::PrintFontManager& rPFM = psp::PrintFontManager::get(); |
312 |
- bool bOK = rPFM.getFontOptions( aInfo, nSize, cairosubcallback, rFontOptions); |
313 |
- return bOK; |
314 |
+ return rPFM.getFontOptions(aInfo, nSize, cairosubcallback); |
315 |
} |
316 |
|
317 |
// ---------------------------------------------------------------------------- |
318 |
-- |
319 |
1.7.4.1 |
320 |
|