summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-03-16 15:47:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-03-16 15:47:14 +0000
commitc3d5444d84e18fa82235bb9d419861ac5e54f544 (patch)
treee009dc981635db07e84132e36b23b74bb62a4941
parent15857a3690f2ee4649934ac36a7493b40c9de7c1 (diff)
Resolves: rhbz#680460 honour lcdfilter, subpixeling etc.
-rw-r--r--vcl/inc/vcl/glyphcache.hxx1
-rw-r--r--vcl/inc/vcl/impfont.hxx2
-rw-r--r--vcl/source/glyphs/gcach_ftyp.cxx5
-rw-r--r--vcl/source/glyphs/gcach_ftyp.hxx1
-rw-r--r--vcl/unx/source/fontmanager/fontconfig.cxx41
-rw-r--r--vcl/unx/source/gdi/salgdi3.cxx20
6 files changed, 59 insertions, 11 deletions
diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx
index e9ab220d8e77..48eb16a7f17b 100644
--- a/vcl/inc/vcl/glyphcache.hxx
+++ b/vcl/inc/vcl/glyphcache.hxx
@@ -188,6 +188,7 @@ public:
virtual void* GetFtFace() const { return 0; }
virtual int GetLoadFlags() const { return 0; }
virtual void SetFontOptions( const ImplFontOptions*) {}
+ virtual const ImplFontOptions* GetFontOptions() const { return 0; }
virtual bool NeedsArtificialBold() const { return false; }
virtual bool NeedsArtificialItalic() const { return false; }
diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx
index efa2307d6d83..cc2807d3e420 100644
--- a/vcl/inc/vcl/impfont.hxx
+++ b/vcl/inc/vcl/impfont.hxx
@@ -166,6 +166,8 @@ public:
{ return meAntiAlias == ANTIALIAS_FALSE; }
bool DontUseHinting() const
{ return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
+ virtual void *GetPattern(void * /*pFace*/) const
+ { return NULL; }
};
// -------------------
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
index 4d6014882000..3a285e1338bc 100644
--- a/vcl/source/glyphs/gcach_ftyp.cxx
+++ b/vcl/source/glyphs/gcach_ftyp.cxx
@@ -967,6 +967,11 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions)
mnLoadFlags |= FT_LOAD_NO_BITMAP;
}
+const ImplFontOptions* FreetypeServerFont::GetFontOptions() const
+{
+ return mpFontOptions;
+}
+
// -----------------------------------------------------------------------
bool FreetypeServerFont::TestFont() const
diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
index 964db8352129..0313406d30ea 100644
--- a/vcl/source/glyphs/gcach_ftyp.hxx
+++ b/vcl/source/glyphs/gcach_ftyp.hxx
@@ -187,6 +187,7 @@ public:
virtual bool TestFont() const;
virtual void* GetFtFace() const;
virtual void SetFontOptions( const ImplFontOptions*);
+ virtual const ImplFontOptions* GetFontOptions() const;
virtual int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); }
virtual bool NeedsArtificialBold() const { return mbArtBold; }
virtual bool NeedsArtificialItalic() const { return mbArtItalic; }
diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx
index 031fac4e6641..602a82430cdb 100644
--- a/vcl/unx/source/fontmanager/fontconfig.cxx
+++ b/vcl/unx/source/fontmanager/fontconfig.cxx
@@ -56,6 +56,9 @@ using namespace psp;
#define FC_HINT_MEDIUM 2
#define FC_HINT_FULL 3
#endif
+ #ifndef FC_FT_FACE
+ #define FC_FT_FACE "ftface"
+ #endif
#else
typedef void FcConfig;
typedef void FcObjectSet;
@@ -141,6 +144,7 @@ class FontCfgWrapper
FcBool (*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*);
FcBool (*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
FT_UInt (*m_pFcFreeTypeCharIndex)(FT_Face,FcChar32);
+ FcBool (*m_pFcPatternAddFTFace)(FcPattern*,const char*,const FT_Face);
oslGenericFunction loadSymbol( const char* );
void addFontSet( FcSetName );
@@ -257,10 +261,14 @@ public:
{ return m_pFcPatternAddBool( pPattern, pObject, nValue ); }
FcBool FcPatternAddCharSet(FcPattern* pPattern,const char* pObject,const FcCharSet*pCharSet)
{ return m_pFcPatternAddCharSet(pPattern,pObject,pCharSet); }
-
FT_UInt FcFreeTypeCharIndex( FT_Face face, FcChar32 ucs4 )
{ return m_pFcFreeTypeCharIndex ? m_pFcFreeTypeCharIndex( face, ucs4 ) : 0; }
-
+ FcBool FcPatternAddFTFace( FcPattern* pPattern, const char* pObject, const FT_Face nValue )
+ {
+ return m_pFcPatternAddFTFace
+ ? m_pFcPatternAddFTFace( pPattern, pObject, nValue )
+ : false;
+ }
public:
FcResult LocalizedElementFromPattern(FcPattern* pPattern, FcChar8 **family,
const char *elementtype, const char *elementlangtype);
@@ -372,6 +380,8 @@ FontCfgWrapper::FontCfgWrapper()
loadSymbol( "FcPatternAddString" );
m_pFcFreeTypeCharIndex = (FT_UInt(*)(FT_Face,FcChar32))
loadSymbol( "FcFreeTypeCharIndex" );
+ m_pFcPatternAddFTFace = (FcBool(*)(FcPattern*,const char*,const FT_Face))
+ loadSymbol( "FcPatternAddFTFace" );
m_nFcVersion = FcGetVersion();
#if (OSL_DEBUG_LEVEL > 1)
@@ -1093,6 +1103,26 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName,
return aName;
}
+class FontConfigFontOptions : public ImplFontOptions
+{
+public:
+ FontConfigFontOptions() : mpPattern(0) {}
+ ~FontConfigFontOptions()
+ {
+ FontCfgWrapper& rWrapper = FontCfgWrapper::get();
+ if( rWrapper.isValid() )
+ rWrapper.FcPatternDestroy( mpPattern );
+ }
+ virtual void *GetPattern(void * face) const
+ {
+ FontCfgWrapper& rWrapper = FontCfgWrapper::get();
+ if( rWrapper.isValid() )
+ rWrapper.FcPatternAddFTFace(mpPattern, FC_FT_FACE, static_cast<FT_Face>(face));
+ return mpPattern;
+ }
+ FcPattern* mpPattern;
+};
+
ImplFontOptions* PrintFontManager::getFontOptions(
const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*)) const
{
@@ -1103,7 +1133,7 @@ ImplFontOptions* PrintFontManager::getFontOptions(
if( ! rWrapper.isValid() )
return NULL;
- ImplFontOptions *pOptions = NULL;
+ FontConfigFontOptions* pOptions = NULL;
FcConfig* pConfig = rWrapper.FcConfigGetCurrent();
FcPattern* pPattern = rWrapper.FcPatternCreate();
@@ -1140,9 +1170,10 @@ ImplFontOptions* PrintFontManager::getFontOptions(
FC_HINTING, 0, &hinting);
/*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger(pResult,
FC_HINT_STYLE, 0, &hintstyle);
- rWrapper.FcPatternDestroy(pResult);
- pOptions = new ImplFontOptions;
+ pOptions = new FontConfigFontOptions;
+
+ pOptions->mpPattern = pResult;
if( eEmbeddedBitmap == FcResultMatch )
pOptions->meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE;
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
index a7e8eec1050b..5dacaf8022d7 100644
--- a/vcl/unx/source/gdi/salgdi3.cxx
+++ b/vcl/unx/source/gdi/salgdi3.cxx
@@ -89,7 +89,6 @@ struct cairo_surface_t;
struct cairo_t;
struct cairo_font_face_t;
typedef void* FT_Face;
-typedef void* FcPattern;
struct cairo_matrix_t {
double xx; double yx;
double xy; double yy;
@@ -742,7 +741,7 @@ private:
void (*mp_clip)(cairo_t*);
void (*mp_rectangle)(cairo_t*, double, double, double, double);
cairo_font_face_t * (*mp_ft_font_face_create_for_ft_face)(FT_Face, int);
- cairo_font_face_t * (*mp_ft_font_face_create_for_pattern)(FcPattern*);
+ cairo_font_face_t * (*mp_ft_font_face_create_for_pattern)(void*);
void (*mp_set_font_face)(cairo_t *, cairo_font_face_t *);
void (*mp_font_face_destroy)(cairo_font_face_t *);
void (*mp_matrix_init_identity)(cairo_matrix_t *);
@@ -772,8 +771,12 @@ public:
{ (*mp_rectangle)(cr, x, y, width, height); }
cairo_font_face_t* ft_font_face_create_for_ft_face(FT_Face face, int load_flags)
{ return (*mp_ft_font_face_create_for_ft_face)(face, load_flags); }
- cairo_font_face_t* ft_font_face_create_for_pattern(FcPattern *pattern)
- { return (*mp_ft_font_face_create_for_pattern)(pattern); }
+ cairo_font_face_t* ft_font_face_create_for_pattern(void *pattern)
+ {
+ return mp_ft_font_face_create_for_pattern
+ ? (*mp_ft_font_face_create_for_pattern)(pattern)
+ : NULL;
+ }
void set_font_face(cairo_t *cr, cairo_font_face_t *font_face)
{ (*mp_set_font_face)(cr, font_face); }
void font_face_destroy(cairo_font_face_t *font_face)
@@ -847,7 +850,7 @@ CairoWrapper::CairoWrapper()
osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_rectangle" );
mp_ft_font_face_create_for_ft_face = (cairo_font_face_t * (*)(FT_Face, int))
osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_ft_face" );
- mp_ft_font_face_create_for_pattern = (cairo_font_face_t * (*)(FcPattern*))
+ mp_ft_font_face_create_for_pattern = (cairo_font_face_t * (*)(void*))
osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_face_create_for_pattern" );
mp_set_font_face = (void (*)(cairo_t *, cairo_font_face_t *))
osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_set_font_face" );
@@ -1016,7 +1019,12 @@ void X11SalGraphics::DrawCairoAAFontString( const ServerFontLayout& rLayout )
font_face = (cairo_font_face_t*)m_aCairoFontsCache.FindCachedFont(pId);
if (!font_face)
{
- font_face = rCairo.ft_font_face_create_for_ft_face(pId, rFont.GetLoadFlags());
+ const ImplFontOptions *pOptions = rFont.GetFontOptions();
+ void *pPattern = pOptions ? pOptions->GetPattern(pId) : NULL;
+ if (pPattern)
+ font_face = rCairo.ft_font_face_create_for_pattern(pPattern);
+ if (!font_face)
+ font_face = rCairo.ft_font_face_create_for_ft_face(pId, rFont.GetLoadFlags());
m_aCairoFontsCache.CacheFont(font_face, pId);
}