Lines 70-79
Link Here
|
70 |
typedef void FcObjectSet; |
70 |
typedef void FcObjectSet; |
71 |
typedef void FcPattern; |
71 |
typedef void FcPattern; |
72 |
typedef void FcFontSet; |
72 |
typedef void FcFontSet; |
|
|
73 |
typedef void FcCharSet; |
73 |
typedef int FcResult; |
74 |
typedef int FcResult; |
74 |
typedef int FcBool; |
75 |
typedef int FcBool; |
75 |
typedef int FcMatchKind; |
76 |
typedef int FcMatchKind; |
76 |
typedef char FcChar8; |
77 |
typedef char FcChar8; |
|
|
78 |
typedef sal_Int32 FcChar32; |
77 |
#endif |
79 |
#endif |
78 |
|
80 |
|
79 |
#include <cstdio> |
81 |
#include <cstdio> |
Lines 106-111
Link Here
|
106 |
{ |
108 |
{ |
107 |
void* m_pLib; |
109 |
void* m_pLib; |
108 |
FcConfig* m_pDefConfig; |
110 |
FcConfig* m_pDefConfig; |
|
|
111 |
FcFontSet* m_pOutlineSet; |
109 |
|
112 |
|
110 |
FcBool (*m_pFcInit)(); |
113 |
FcBool (*m_pFcInit)(); |
111 |
FcConfig* (*m_pFcConfigGetCurrent)(); |
114 |
FcConfig* (*m_pFcConfigGetCurrent)(); |
Lines 114-130
Link Here
|
114 |
FcPattern* (*m_pFcPatternCreate)(); |
117 |
FcPattern* (*m_pFcPatternCreate)(); |
115 |
void (*m_pFcPatternDestroy)(FcPattern*); |
118 |
void (*m_pFcPatternDestroy)(FcPattern*); |
116 |
FcFontSet* (*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*); |
119 |
FcFontSet* (*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*); |
|
|
120 |
FcFontSet* (*m_pFcConfigGetFonts)(FcConfig*,FcSetName); |
117 |
FcFontSet* (*m_pFcFontSetCreate)(); |
121 |
FcFontSet* (*m_pFcFontSetCreate)(); |
|
|
122 |
FcCharSet* (*m_pFcCharSetCreate)(); |
123 |
FcBool (*m_pFcCharSetAddChar)(FcCharSet *, FcChar32); |
118 |
void (*m_pFcFontSetDestroy)(FcFontSet*); |
124 |
void (*m_pFcFontSetDestroy)(FcFontSet*); |
119 |
FcBool (*m_pFcFontSetAdd)(FcFontSet*,FcPattern*); |
125 |
FcBool (*m_pFcFontSetAdd)(FcFontSet*,FcPattern*); |
|
|
126 |
void (*m_pFcPatternReference)(FcPattern*); |
120 |
FcResult (*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**); |
127 |
FcResult (*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**); |
121 |
FcResult (*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*); |
128 |
FcResult (*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*); |
122 |
FcResult (*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*); |
129 |
FcResult (*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*); |
123 |
FcResult (*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*); |
130 |
FcResult (*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*); |
124 |
void (*m_pFcDefaultSubstitute)(FcPattern *); |
131 |
void (*m_pFcDefaultSubstitute)(FcPattern *); |
125 |
FcPattern* (*m_pFcFontMatch)(FcConfig*,FcPattern*,FcResult*); |
132 |
FcPattern* (*m_pFcFontSetMatch)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*); |
126 |
FcBool (*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind); |
133 |
FcBool (*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind); |
127 |
FcBool (*m_pFcPatternAddInteger)(FcPattern*,const char*,int); |
134 |
FcBool (*m_pFcPatternAddInteger)(FcPattern*,const char*,int); |
|
|
135 |
FcBool (*m_pFcPatternAddBool)(FcPattern*,const char*,FcBool); |
136 |
FcBool (*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*); |
128 |
FcBool (*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*); |
137 |
FcBool (*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*); |
129 |
|
138 |
|
130 |
void* loadSymbol( const char* ); |
139 |
void* loadSymbol( const char* ); |
Lines 140-145
Link Here
|
140 |
{ return m_pLib != NULL;} |
149 |
{ return m_pLib != NULL;} |
141 |
|
150 |
|
142 |
FcConfig* getDefConfig() { return m_pDefConfig; } |
151 |
FcConfig* getDefConfig() { return m_pDefConfig; } |
|
|
152 |
FcFontSet* getFontSet() { return m_pOutlineSet; } |
143 |
|
153 |
|
144 |
FcBool FcInit() |
154 |
FcBool FcInit() |
145 |
{ return m_pFcInit(); } |
155 |
{ return m_pFcInit(); } |
Lines 169-182
Link Here
|
169 |
|
179 |
|
170 |
FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet ) |
180 |
FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet ) |
171 |
{ return m_pFcFontList( pConfig, pPattern, pSet ); } |
181 |
{ return m_pFcFontList( pConfig, pPattern, pSet ); } |
172 |
|
182 |
|
|
|
183 |
FcFontSet* FcConfigGetFonts( FcConfig* pConfig, FcSetName eSet) |
184 |
{ return m_pFcConfigGetFonts( pConfig, eSet ); } |
185 |
|
173 |
FcFontSet* FcFontSetCreate() |
186 |
FcFontSet* FcFontSetCreate() |
174 |
{ return m_pFcFontSetCreate(); } |
187 |
{ return m_pFcFontSetCreate(); } |
|
|
188 |
|
189 |
FcCharSet* FcCharSetCreate() |
190 |
{ return m_pFcCharSetCreate(); } |
191 |
|
192 |
FcBool FcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4) |
193 |
{ return m_pFcCharSetAddChar(fcs, ucs4); } |
194 |
|
175 |
void FcFontSetDestroy( FcFontSet* pSet ) |
195 |
void FcFontSetDestroy( FcFontSet* pSet ) |
176 |
{ m_pFcFontSetDestroy( pSet );} |
196 |
{ m_pFcFontSetDestroy( pSet );} |
|
|
197 |
|
177 |
FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern ) |
198 |
FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern ) |
178 |
{ return m_pFcFontSetAdd( pSet, pPattern ); } |
199 |
{ return m_pFcFontSetAdd( pSet, pPattern ); } |
179 |
|
200 |
|
|
|
201 |
void FcPatternReference( FcPattern* pPattern ) |
202 |
{ m_pFcPatternReference( pPattern ); } |
203 |
|
180 |
FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s ) |
204 |
FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s ) |
181 |
{ return m_pFcPatternGetString( pPattern, object, n, s ); } |
205 |
{ return m_pFcPatternGetString( pPattern, object, n, s ); } |
182 |
|
206 |
|
Lines 190-201
Link Here
|
190 |
{ return m_pFcPatternGetBool( pPattern, object, n, s ); } |
214 |
{ return m_pFcPatternGetBool( pPattern, object, n, s ); } |
191 |
void FcDefaultSubstitute( FcPattern* pPattern ) |
215 |
void FcDefaultSubstitute( FcPattern* pPattern ) |
192 |
{ m_pFcDefaultSubstitute( pPattern ); } |
216 |
{ m_pFcDefaultSubstitute( pPattern ); } |
193 |
FcPattern* FcFontMatch( FcConfig* pConfig, FcPattern* pPattern, FcResult* pResult ) |
217 |
FcPattern* FcFontSetMatch(FcConfig* pConfig, FcFontSet** ppFontSet, int nset, FcPattern *pPattern, FcResult *pResult) |
194 |
{ return m_pFcFontMatch( pConfig, pPattern, pResult ); } |
218 |
{ return m_pFcFontSetMatch( pConfig, ppFontSet, nset, pPattern, pResult ); } |
195 |
FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind ) |
219 |
FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind ) |
196 |
{ return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); } |
220 |
{ return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); } |
197 |
FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue ) |
221 |
FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue ) |
198 |
{ return m_pFcPatternAddInteger( pPattern, pObject, nValue ); } |
222 |
{ return m_pFcPatternAddInteger( pPattern, pObject, nValue ); } |
|
|
223 |
FcBool FcPatternAddBool( FcPattern* pPattern, const char* pObject, FcBool b ) |
224 |
{ return m_pFcPatternAddBool( pPattern, pObject, b ); } |
225 |
FcBool FcPatternAddCharSet( FcPattern* pPattern, const char* pObject, const FcCharSet *c) |
226 |
{ return m_pFcPatternAddCharSet( pPattern, pObject, c ); } |
199 |
FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString ) |
227 |
FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString ) |
200 |
{ return m_pFcPatternAddString( pPattern, pObject, pString ); } |
228 |
{ return m_pFcPatternAddString( pPattern, pObject, pString ); } |
201 |
}; |
229 |
}; |
Lines 212-218
Link Here
|
212 |
|
240 |
|
213 |
FontCfgWrapper::FontCfgWrapper() |
241 |
FontCfgWrapper::FontCfgWrapper() |
214 |
: m_pLib( NULL ), |
242 |
: m_pLib( NULL ), |
215 |
m_pDefConfig( NULL ) |
243 |
m_pDefConfig( NULL ), |
|
|
244 |
m_pOutlineSet( NULL ) |
216 |
{ |
245 |
{ |
217 |
#ifdef ENABLE_FONTCONFIG |
246 |
#ifdef ENABLE_FONTCONFIG |
218 |
OUString aLib( RTL_CONSTASCII_USTRINGPARAM( "libfontconfig.so.1" ) ); |
247 |
OUString aLib( RTL_CONSTASCII_USTRINGPARAM( "libfontconfig.so.1" ) ); |
Lines 246-257
Link Here
|
246 |
loadSymbol( "FcPatternDestroy" ); |
275 |
loadSymbol( "FcPatternDestroy" ); |
247 |
m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*)) |
276 |
m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*)) |
248 |
loadSymbol( "FcFontList" ); |
277 |
loadSymbol( "FcFontList" ); |
|
|
278 |
m_pFcConfigGetFonts = (FcFontSet*(*)(FcConfig*,FcSetName)) |
279 |
loadSymbol( "FcConfigGetFonts" ); |
249 |
m_pFcFontSetCreate = (FcFontSet*(*)()) |
280 |
m_pFcFontSetCreate = (FcFontSet*(*)()) |
250 |
loadSymbol( "FcFontSetCreate" ); |
281 |
loadSymbol( "FcFontSetCreate" ); |
|
|
282 |
m_pFcCharSetCreate = (FcCharSet*(*)()) |
283 |
loadSymbol( "FcCharSetCreate" ); |
284 |
m_pFcCharSetAddChar = (FcBool(*)(FcCharSet*, FcChar32)) |
285 |
loadSymbol( "FcCharSetAddChar" ); |
251 |
m_pFcFontSetDestroy = (void(*)(FcFontSet*)) |
286 |
m_pFcFontSetDestroy = (void(*)(FcFontSet*)) |
252 |
loadSymbol( "FcFontSetDestroy" ); |
287 |
loadSymbol( "FcFontSetDestroy" ); |
253 |
m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*)) |
288 |
m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*)) |
254 |
loadSymbol( "FcFontSetAdd" ); |
289 |
loadSymbol( "FcFontSetAdd" ); |
|
|
290 |
m_pFcPatternReference = (void(*)(FcPattern*)) |
291 |
loadSymbol( "FcPatternReference" ); |
255 |
m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**)) |
292 |
m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**)) |
256 |
loadSymbol( "FcPatternGetString" ); |
293 |
loadSymbol( "FcPatternGetString" ); |
257 |
m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*)) |
294 |
m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*)) |
Lines 262-273
Link Here
|
262 |
loadSymbol( "FcPatternGetBool" ); |
299 |
loadSymbol( "FcPatternGetBool" ); |
263 |
m_pFcDefaultSubstitute = (void(*)(FcPattern *)) |
300 |
m_pFcDefaultSubstitute = (void(*)(FcPattern *)) |
264 |
loadSymbol( "FcDefaultSubstitute" ); |
301 |
loadSymbol( "FcDefaultSubstitute" ); |
265 |
m_pFcFontMatch = (FcPattern*(*)(FcConfig*,FcPattern*,FcResult*)) |
302 |
m_pFcFontSetMatch = (FcPattern*(*)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*)) |
266 |
loadSymbol( "FcFontMatch" ); |
303 |
loadSymbol( "FcFontSetMatch" ); |
267 |
m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind)) |
304 |
m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind)) |
268 |
loadSymbol( "FcConfigSubstitute" ); |
305 |
loadSymbol( "FcConfigSubstitute" ); |
269 |
m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int)) |
306 |
m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int)) |
270 |
loadSymbol( "FcPatternAddInteger" ); |
307 |
loadSymbol( "FcPatternAddInteger" ); |
|
|
308 |
m_pFcPatternAddBool = (FcBool(*)(FcPattern*,const char*,FcBool)) |
309 |
loadSymbol( "FcPatternAddBool" ); |
310 |
m_pFcPatternAddCharSet = (FcBool(*)(FcPattern*,const char*,const FcCharSet *)) |
311 |
loadSymbol( "FcPatternAddCharSet" ); |
271 |
m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*)) |
312 |
m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*)) |
272 |
loadSymbol( "FcPatternAddString" ); |
313 |
loadSymbol( "FcPatternAddString" ); |
273 |
|
314 |
|
Lines 279-295
Link Here
|
279 |
m_pFcPatternCreate && |
320 |
m_pFcPatternCreate && |
280 |
m_pFcPatternDestroy && |
321 |
m_pFcPatternDestroy && |
281 |
m_pFcFontList && |
322 |
m_pFcFontList && |
|
|
323 |
m_pFcConfigGetFonts && |
282 |
m_pFcFontSetCreate && |
324 |
m_pFcFontSetCreate && |
|
|
325 |
m_pFcCharSetCreate && |
326 |
m_pFcCharSetAddChar && |
283 |
m_pFcFontSetDestroy && |
327 |
m_pFcFontSetDestroy && |
284 |
m_pFcFontSetAdd && |
328 |
m_pFcFontSetAdd && |
|
|
329 |
m_pFcPatternReference && |
285 |
m_pFcPatternGetString && |
330 |
m_pFcPatternGetString && |
286 |
m_pFcPatternGetInteger && |
331 |
m_pFcPatternGetInteger && |
287 |
m_pFcPatternGetDouble && |
332 |
m_pFcPatternGetDouble && |
288 |
m_pFcPatternGetBool && |
333 |
m_pFcPatternGetBool && |
289 |
m_pFcDefaultSubstitute && |
334 |
m_pFcDefaultSubstitute && |
290 |
m_pFcFontMatch && |
335 |
m_pFcFontSetMatch && |
291 |
m_pFcConfigSubstitute && |
336 |
m_pFcConfigSubstitute && |
292 |
m_pFcPatternAddInteger && |
337 |
m_pFcPatternAddInteger && |
|
|
338 |
m_pFcPatternAddCharSet && |
339 |
m_pFcPatternAddBool && |
293 |
m_pFcPatternAddString |
340 |
m_pFcPatternAddString |
294 |
) ) |
341 |
) ) |
295 |
{ |
342 |
{ |
Lines 307-316
Link Here
|
307 |
osl_unloadModule( m_pLib ); |
354 |
osl_unloadModule( m_pLib ); |
308 |
m_pLib = NULL; |
355 |
m_pLib = NULL; |
309 |
} |
356 |
} |
|
|
357 |
|
358 |
m_pOutlineSet = FcFontSetCreate(); |
359 |
|
360 |
/* |
361 |
add only acceptable outlined fonts to our config, |
362 |
for future fontconfig use |
363 |
*/ |
364 |
FcFontSet *pOrig = FcConfigGetFonts(NULL, FcSetSystem); |
365 |
|
366 |
if (!pOrig) |
367 |
return; |
368 |
|
369 |
for( int i = 0; i < pOrig->nfont; ++i ) |
370 |
{ |
371 |
FcBool outline = false; |
372 |
FcPattern *pOutlinePattern = pOrig->fonts[i]; |
373 |
FcResult eOutRes = |
374 |
FcPatternGetBool( pOutlinePattern, FC_OUTLINE, 0, &outline ); |
375 |
if (eOutRes == FcResultMatch && !outline) |
376 |
continue; |
377 |
FcPatternReference(pOutlinePattern); |
378 |
FcFontSetAdd(m_pOutlineSet, pOutlinePattern); |
379 |
} |
310 |
} |
380 |
} |
311 |
|
381 |
|
312 |
FontCfgWrapper::~FontCfgWrapper() |
382 |
FontCfgWrapper::~FontCfgWrapper() |
313 |
{ |
383 |
{ |
|
|
384 |
if( m_pOutlineSet ) |
385 |
FcFontSetDestroy( m_pOutlineSet ); |
314 |
if( m_pLib ) |
386 |
if( m_pLib ) |
315 |
osl_unloadModule( m_pLib ); |
387 |
osl_unloadModule( m_pLib ); |
316 |
} |
388 |
} |
Lines 345-362
Link Here
|
345 |
if( ! rWrapper.isValid() ) |
417 |
if( ! rWrapper.isValid() ) |
346 |
return false; |
418 |
return false; |
347 |
|
419 |
|
348 |
FcConfig* pConfig = rWrapper.getDefConfig(); |
420 |
FcFontSet* pFSet = rWrapper.getFontSet(); |
349 |
FcObjectSet* pOSet = rWrapper.FcObjectSetBuild( FC_FAMILY, |
|
|
350 |
FC_STYLE, |
351 |
FC_SLANT, |
352 |
FC_WEIGHT, |
353 |
FC_SPACING, |
354 |
FC_FILE, |
355 |
FC_OUTLINE, |
356 |
FC_INDEX, |
357 |
(void *) NULL ); |
358 |
FcPattern* pPattern = rWrapper.FcPatternCreate(); |
359 |
FcFontSet* pFSet = rWrapper.FcFontList( pConfig, pPattern, pOSet ); |
360 |
|
421 |
|
361 |
if( pFSet ) |
422 |
if( pFSet ) |
362 |
{ |
423 |
{ |
Lines 399-404
Link Here
|
399 |
); |
460 |
); |
400 |
#endif |
461 |
#endif |
401 |
|
462 |
|
|
|
463 |
OSL_ASSERT(eOutRes != FcResultMatch || outline); |
464 |
|
402 |
// only outline fonts are usable to psprint anyway |
465 |
// only outline fonts are usable to psprint anyway |
403 |
if( eOutRes == FcResultMatch && ! outline ) |
466 |
if( eOutRes == FcResultMatch && ! outline ) |
404 |
continue; |
467 |
continue; |
Lines 537-550
Link Here
|
537 |
} |
600 |
} |
538 |
} |
601 |
} |
539 |
|
602 |
|
540 |
// cleanup |
|
|
541 |
if( pPattern ) |
542 |
rWrapper.FcPatternDestroy( pPattern ); |
543 |
if( pFSet ) |
544 |
rWrapper.FcFontSetDestroy( pFSet ); |
545 |
if( pOSet ) |
546 |
rWrapper.FcObjectSetDestroy( pOSet ); |
547 |
|
548 |
// how does one get rid of the config ? |
603 |
// how does one get rid of the config ? |
549 |
#if OSL_DEBUG_LEVEL > 1 |
604 |
#if OSL_DEBUG_LEVEL > 1 |
550 |
fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts ); |
605 |
fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts ); |
Lines 558-596
Link Here
|
558 |
FontCfgWrapper::release(); |
613 |
FontCfgWrapper::release(); |
559 |
} |
614 |
} |
560 |
|
615 |
|
561 |
bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ) |
616 |
static void addtopattern(FontCfgWrapper& rWrapper, FcPattern *pPattern, |
|
|
617 |
italic::type eItalic, weight::type eWeight, width::type eWidth, pitch::type ePitch) |
562 |
{ |
618 |
{ |
563 |
#ifdef ENABLE_FONTCONFIG |
619 |
#ifdef ENABLE_FONTCONFIG |
564 |
FontCfgWrapper& rWrapper = FontCfgWrapper::get(); |
620 |
if( eItalic != italic::Unknown ) |
565 |
if( ! rWrapper.isValid() ) |
|
|
566 |
return false; |
567 |
|
568 |
FcConfig* pConfig = rWrapper.getDefConfig(); |
569 |
FcPattern* pPattern = rWrapper.FcPatternCreate(); |
570 |
|
571 |
OString aLangAttrib; |
572 |
// populate pattern with font characteristics |
573 |
if( rLocale.Language.getLength() ) |
574 |
{ |
575 |
OUStringBuffer aLang(6); |
576 |
aLang.append( rLocale.Language ); |
577 |
if( rLocale.Country.getLength() ) |
578 |
{ |
579 |
aLang.append( sal_Unicode('-') ); |
580 |
aLang.append( rLocale.Country ); |
581 |
} |
582 |
aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); |
583 |
} |
584 |
if( aLangAttrib.getLength() ) |
585 |
rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() ); |
586 |
|
587 |
OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 ); |
588 |
if( aFamily.getLength() ) |
589 |
rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() ); |
590 |
if( rInfo.m_eItalic != italic::Unknown ) |
591 |
{ |
621 |
{ |
592 |
int nSlant = FC_SLANT_ROMAN; |
622 |
int nSlant = FC_SLANT_ROMAN; |
593 |
switch( rInfo.m_eItalic ) |
623 |
switch( eItalic ) |
594 |
{ |
624 |
{ |
595 |
case italic::Italic: nSlant = FC_SLANT_ITALIC;break; |
625 |
case italic::Italic: nSlant = FC_SLANT_ITALIC;break; |
596 |
case italic::Oblique: nSlant = FC_SLANT_OBLIQUE;break; |
626 |
case italic::Oblique: nSlant = FC_SLANT_OBLIQUE;break; |
Lines 599-608
Link Here
|
599 |
} |
629 |
} |
600 |
rWrapper.FcPatternAddInteger( pPattern, FC_SLANT, nSlant ); |
630 |
rWrapper.FcPatternAddInteger( pPattern, FC_SLANT, nSlant ); |
601 |
} |
631 |
} |
602 |
if( rInfo.m_eWeight != weight::Unknown ) |
632 |
if( eWeight != weight::Unknown ) |
603 |
{ |
633 |
{ |
604 |
int nWeight = FC_WEIGHT_NORMAL; |
634 |
int nWeight = FC_WEIGHT_NORMAL; |
605 |
switch( rInfo.m_eWeight ) |
635 |
switch( eWeight ) |
606 |
{ |
636 |
{ |
607 |
case weight::Thin: nWeight = FC_WEIGHT_THIN;break; |
637 |
case weight::Thin: nWeight = FC_WEIGHT_THIN;break; |
608 |
case weight::UltraLight: nWeight = FC_WEIGHT_ULTRALIGHT;break; |
638 |
case weight::UltraLight: nWeight = FC_WEIGHT_ULTRALIGHT;break; |
Lines 619-628
Link Here
|
619 |
} |
649 |
} |
620 |
rWrapper.FcPatternAddInteger( pPattern, FC_WEIGHT, nWeight ); |
650 |
rWrapper.FcPatternAddInteger( pPattern, FC_WEIGHT, nWeight ); |
621 |
} |
651 |
} |
622 |
if( rInfo.m_eWidth != width::Unknown ) |
652 |
if( eWidth != width::Unknown ) |
623 |
{ |
653 |
{ |
624 |
int nWidth = FC_WIDTH_NORMAL; |
654 |
int nWidth = FC_WIDTH_NORMAL; |
625 |
switch( rInfo.m_eWidth ) |
655 |
switch( eWidth ) |
626 |
{ |
656 |
{ |
627 |
case width::UltraCondensed: nWidth = FC_WIDTH_ULTRACONDENSED;break; |
657 |
case width::UltraCondensed: nWidth = FC_WIDTH_ULTRACONDENSED;break; |
628 |
case width::ExtraCondensed: nWidth = FC_WIDTH_EXTRACONDENSED;break; |
658 |
case width::ExtraCondensed: nWidth = FC_WIDTH_EXTRACONDENSED;break; |
Lines 638-647
Link Here
|
638 |
} |
668 |
} |
639 |
rWrapper.FcPatternAddInteger( pPattern, FC_WIDTH, nWidth ); |
669 |
rWrapper.FcPatternAddInteger( pPattern, FC_WIDTH, nWidth ); |
640 |
} |
670 |
} |
641 |
if( rInfo.m_ePitch != pitch::Unknown ) |
671 |
if( ePitch != pitch::Unknown ) |
642 |
{ |
672 |
{ |
643 |
int nSpacing = FC_PROPORTIONAL; |
673 |
int nSpacing = FC_PROPORTIONAL; |
644 |
switch( rInfo.m_ePitch ) |
674 |
switch( ePitch ) |
645 |
{ |
675 |
{ |
646 |
case pitch::Fixed: nSpacing = FC_MONO;break; |
676 |
case pitch::Fixed: nSpacing = FC_MONO;break; |
647 |
case pitch::Variable: nSpacing = FC_PROPORTIONAL;break; |
677 |
case pitch::Variable: nSpacing = FC_PROPORTIONAL;break; |
Lines 649-660
Link Here
|
649 |
break; |
679 |
break; |
650 |
} |
680 |
} |
651 |
rWrapper.FcPatternAddInteger( pPattern, FC_SPACING, nSpacing ); |
681 |
rWrapper.FcPatternAddInteger( pPattern, FC_SPACING, nSpacing ); |
|
|
682 |
if (nSpacing == FC_MONO) |
683 |
rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)"monospace"); |
652 |
} |
684 |
} |
|
|
685 |
#endif |
686 |
} |
687 |
|
688 |
String PrintFontManager::Substitute(const std::vector<String> &rNames, const std::vector<sal_Unicode> &rGlyphs, |
689 |
const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight, |
690 |
width::type eWidth, pitch::type ePitch) const |
691 |
{ |
692 |
String aName; |
693 |
#ifdef ENABLE_FONTCONFIG |
694 |
FontCfgWrapper& rWrapper = FontCfgWrapper::get(); |
695 |
if( ! rWrapper.isValid() ) |
696 |
return aName; |
697 |
|
698 |
FcFontSet* pSet = NULL; |
699 |
FcPattern* pPattern = rWrapper.FcPatternCreate(); |
700 |
|
701 |
// Prefer scalable fonts |
702 |
rWrapper.FcPatternAddBool( pPattern, FC_SCALABLE, 1 ); |
703 |
|
704 |
std::vector<String>::const_iterator aEnd = rNames.end(); |
705 |
for (std::vector<String>::const_iterator aIter = rNames.begin(); aIter != aEnd; ++aIter) |
706 |
{ |
707 |
OString maTargetName = OUStringToOString(*aIter, RTL_TEXTENCODING_UTF8); |
708 |
rWrapper.FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)maTargetName.getStr()); |
709 |
} |
710 |
|
711 |
if( rLangAttrib.Len() ) |
712 |
rWrapper.FcPatternAddString(pPattern, FC_LANG, (FcChar8*)rLangAttrib.GetBuffer()); |
713 |
|
714 |
// Add required Unicode characters, if any |
715 |
FcCharSet *unicodes = NULL; |
716 |
if (! rGlyphs.empty() ) |
717 |
{ |
718 |
unicodes = rWrapper.FcCharSetCreate(); |
719 |
std::vector<sal_Unicode>::const_iterator aGlyphEnd = rGlyphs.end(); |
720 |
for (std::vector<sal_Unicode>::const_iterator aGlyphIter = rGlyphs.begin(); |
721 |
aGlyphIter != aGlyphEnd; ++aGlyphIter) |
722 |
{ |
723 |
rWrapper.FcCharSetAddChar( unicodes, (FcChar32)*aGlyphIter ); |
724 |
} |
725 |
rWrapper.FcPatternAddCharSet( pPattern, FC_CHARSET, unicodes); |
726 |
} |
727 |
|
728 |
addtopattern(rWrapper, pPattern, eItalic, eWeight, eWidth, ePitch); |
729 |
|
730 |
rWrapper.FcConfigSubstitute( NULL, pPattern, FcMatchPattern ); |
731 |
rWrapper.FcDefaultSubstitute( pPattern ); |
732 |
FcResult eResult = FcResultNoMatch; |
733 |
FcFontSet *pFontSet = rWrapper.getFontSet(); |
734 |
FcPattern* pResult = rWrapper.FcFontSetMatch( NULL, &pFontSet, 1, pPattern, &eResult ); |
735 |
rWrapper.FcPatternDestroy( pPattern ); |
736 |
|
737 |
if( pResult ) |
738 |
{ |
739 |
pSet = rWrapper.FcFontSetCreate(); |
740 |
// info: destroying the pSet destroys pResult implicitly |
741 |
// since pResult was "added" to pSet |
742 |
rWrapper.FcFontSetAdd( pSet, pResult ); |
743 |
} |
744 |
|
745 |
if( pSet ) |
746 |
{ |
747 |
if( pSet->nfont > 0 ) |
748 |
{ |
749 |
//extract the closest match |
750 |
FcChar8* family = NULL; |
751 |
FcResult eFileRes = rWrapper.FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family ); |
752 |
if( eFileRes == FcResultMatch ) |
753 |
aName = String( (sal_Char*)family, RTL_TEXTENCODING_UTF8 ); |
754 |
} |
755 |
} |
756 |
rWrapper.FcFontSetDestroy( pSet ); |
757 |
#endif |
758 |
return aName; |
759 |
} |
760 |
|
761 |
bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ) |
762 |
{ |
763 |
#ifdef ENABLE_FONTCONFIG |
764 |
FontCfgWrapper& rWrapper = FontCfgWrapper::get(); |
765 |
if( ! rWrapper.isValid() ) |
766 |
return false; |
767 |
|
768 |
FcConfig* pConfig = rWrapper.getDefConfig(); |
769 |
FcPattern* pPattern = rWrapper.FcPatternCreate(); |
770 |
|
771 |
OString aLangAttrib; |
772 |
// populate pattern with font characteristics |
773 |
if( rLocale.Language.getLength() ) |
774 |
{ |
775 |
OUStringBuffer aLang(6); |
776 |
aLang.append( rLocale.Language ); |
777 |
if( rLocale.Country.getLength() ) |
778 |
{ |
779 |
aLang.append( sal_Unicode('-') ); |
780 |
aLang.append( rLocale.Country ); |
781 |
} |
782 |
aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); |
783 |
} |
784 |
if( aLangAttrib.getLength() ) |
785 |
rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() ); |
786 |
|
787 |
OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 ); |
788 |
if( aFamily.getLength() ) |
789 |
rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() ); |
790 |
|
791 |
addtopattern(rWrapper, pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch); |
653 |
|
792 |
|
654 |
rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern ); |
793 |
rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern ); |
655 |
rWrapper.FcDefaultSubstitute( pPattern ); |
794 |
rWrapper.FcDefaultSubstitute( pPattern ); |
656 |
FcResult eResult = FcResultNoMatch; |
795 |
FcResult eResult = FcResultNoMatch; |
657 |
FcPattern* pResult = rWrapper.FcFontMatch( pConfig, pPattern, &eResult ); |
796 |
FcFontSet *pFontSet = rWrapper.getFontSet(); |
|
|
797 |
FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult ); |
658 |
bool bSuccess = false; |
798 |
bool bSuccess = false; |
659 |
if( pResult ) |
799 |
if( pResult ) |
660 |
{ |
800 |
{ |