You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
9.8 KiB
227 lines
9.8 KiB
From 5aab60551b825b3ad283f19263f3ce549c725055 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
Date: Wed, 16 Mar 2011 15:47:14 +0000
|
|
Subject: [PATCH] Resolves: rhbz#680460 honour lcdfilter, subpixeling etc.
|
|
|
|
---
|
|
vcl/inc/vcl/glyphcache.hxx | 1 +
|
|
vcl/inc/vcl/impfont.hxx | 2 +
|
|
vcl/source/glyphs/gcach_ftyp.cxx | 5 +++
|
|
vcl/source/glyphs/gcach_ftyp.hxx | 1 +
|
|
vcl/unx/source/fontmanager/fontconfig.cxx | 41 +++++++++++++++++++++++++---
|
|
vcl/unx/source/gdi/salgdi3.cxx | 20 ++++++++++----
|
|
6 files changed, 59 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx
|
|
index 1c03759..035fd5c 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 fa8a837..ed9c35c 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 a6a13da..8c46009 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 6069388..1df8253 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 92632c7..7b792d3 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 6de93fe..a0bef90 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);
|
|
}
|
|
|
|
--
|
|
1.7.4.1
|
|
|