summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/settings.cxx2
-rw-r--r--vcl/source/gdi/outdev3.cxx37
-rw-r--r--vcl/source/glyphs/gcach_ftyp.cxx97
-rw-r--r--vcl/source/glyphs/gcach_ftyp.hxx7
-rw-r--r--vcl/source/glyphs/glyphcache.cxx16
5 files changed, 102 insertions, 57 deletions
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 1aebe5913959..5ad3f6787461 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -433,6 +433,7 @@ ImplStyleData::ImplStyleData()
mnToolbarIconSize = STYLE_TOOLBAR_ICONSIZE_UNKNOWN;
mnSymbolsStyle = STYLE_SYMBOLS_AUTO;
mnPreferredSymbolsStyle = STYLE_SYMBOLS_AUTO;
+ mpFontOptions = NULL;
SetStandardStyles();
}
@@ -539,6 +540,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
mnToolbarIconSize = rData.mnToolbarIconSize;
mnSymbolsStyle = rData.mnSymbolsStyle;
mnPreferredSymbolsStyle = rData.mnPreferredSymbolsStyle;
+ mpFontOptions = rData.mpFontOptions;
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 895a98dfaf1a..6ca90540d8ee 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -68,6 +68,9 @@
#ifdef ENABLE_GRAPHITE
#include <vcl/graphite_features.hxx>
#endif
+#ifdef USE_BUILTIN_RASTERIZER
+#include <vcl/glyphcache.hxx>
+#endif
#include <vcl/unohelp.hxx>
#include <pdfwriter_impl.hxx>
@@ -995,21 +998,28 @@ ImplFontEntry::~ImplFontEntry()
// -----------------------------------------------------------------------
-inline void ImplFontEntry::AddFallbackForUnicode( sal_UCS4 cChar, const String& rFontName )
+size_t ImplFontEntry::GFBCacheKey_Hash::operator()( const GFBCacheKey& rData ) const
+{
+ std::hash<sal_UCS4> a;
+ std::hash<int > b;
+ return a(rData.first) ^ b(rData.second);
+}
+
+inline void ImplFontEntry::AddFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const String& rFontName )
{
if( !mpUnicodeFallbackList )
mpUnicodeFallbackList = new UnicodeFallbackList;
- (*mpUnicodeFallbackList)[cChar] = rFontName;
+ (*mpUnicodeFallbackList)[ GFBCacheKey(cChar,eWeight) ] = rFontName;
}
// -----------------------------------------------------------------------
-inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, String* pFontName ) const
+inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, String* pFontName ) const
{
if( !mpUnicodeFallbackList )
return false;
- UnicodeFallbackList::const_iterator it = mpUnicodeFallbackList->find( cChar );
+ UnicodeFallbackList::const_iterator it = mpUnicodeFallbackList->find( GFBCacheKey(cChar,eWeight) );
if( it == mpUnicodeFallbackList->end() )
return false;
@@ -1019,10 +1029,10 @@ inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, String* pFontN
// -----------------------------------------------------------------------
-inline void ImplFontEntry::IgnoreFallbackForUnicode( sal_UCS4 cChar, const String& rFontName )
+inline void ImplFontEntry::IgnoreFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const String& rFontName )
{
// DBG_ASSERT( mpUnicodeFallbackList, "ImplFontEntry::IgnoreFallbackForUnicode no list" );
- UnicodeFallbackList::iterator it = mpUnicodeFallbackList->find( cChar );
+ UnicodeFallbackList::iterator it = mpUnicodeFallbackList->find( GFBCacheKey(cChar,eWeight) );
// DBG_ASSERT( it != mpUnicodeFallbackList->end(), "ImplFontEntry::IgnoreFallbackForUnicode no match" );
if( it == mpUnicodeFallbackList->end() )
return;
@@ -1417,7 +1427,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
while( nStrIndex < rMissingCodes.getLength() )
{
cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &rFontSelData.maSearchName );
+ bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName );
// ignore entries which don't have a fallback
if( !bCached || (rFontSelData.maSearchName.Len() != 0) )
break;
@@ -1433,7 +1443,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
while( nStrIndex < rMissingCodes.getLength() )
{
cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &aFontName );
+ bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &aFontName );
if( !bCached || (rFontSelData.maSearchName != aFontName) )
pRemainingCodes[ nRemainingLength++ ] = cChar;
}
@@ -1452,8 +1462,8 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
// cache the result even if there was no match
for(;;)
{
- if( !rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &rFontSelData.maSearchName ) )
- rFontSelData.mpFontEntry->AddFallbackForUnicode( cChar, rFontSelData.maSearchName );
+ if( !rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName ) )
+ rFontSelData.mpFontEntry->AddFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName );
if( nStrIndex >= aOldMissingCodes.getLength() )
break;
cChar = aOldMissingCodes.iterateCodePoints( &nStrIndex );
@@ -1464,7 +1474,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
for( nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
{
cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- rFontSelData.mpFontEntry->IgnoreFallbackForUnicode( cChar, rFontSelData.maSearchName );
+ rFontSelData.mpFontEntry->IgnoreFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName );
}
}
}
@@ -2780,6 +2790,11 @@ void ImplFontCache::Invalidate()
maFontInstanceList.clear();
DBG_ASSERT( (mnRef0Count==0), "ImplFontCache::Invalidate() - mnRef0Count non-zero" );
+
+#ifdef USE_BUILTIN_RASTERIZER
+ // TODO: eventually move into SalGraphics layer
+ GlyphCache::GetInstance().InvalidateAllGlyphs();
+#endif
}
// =======================================================================
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
index a337f2553ff7..ebdd59f517af 100644
--- a/vcl/source/glyphs/gcach_ftyp.cxx
+++ b/vcl/source/glyphs/gcach_ftyp.cxx
@@ -38,8 +38,6 @@
#include "vcl/svapp.hxx"
#include "vcl/outfont.hxx"
#include "vcl/impfont.hxx"
-#include "vcl/bitmap.hxx"
-#include "vcl/bmpacc.hxx"
#include "tools/poly.hxx"
#include "basegfx/matrix/b2dhommatrix.hxx"
@@ -80,7 +78,7 @@ typedef FT_Vector* FT_Vector_CPtr;
// TODO: move file mapping stuff to OSL
#if defined(UNX)
#if !defined(HPUX)
- // PORTERS: dlfcn is used for code dependend on FT version
+ // PORTERS: dlfcn is used for getting symbols from FT versions newer than baseline
#include <dlfcn.h>
#endif
#include <unistd.h>
@@ -93,10 +91,6 @@ typedef FT_Vector* FT_Vector_CPtr;
#define strncasecmp strnicmp
#endif
-#include "vcl/svapp.hxx"
-#include "vcl/settings.hxx"
-#include "i18npool/lang.h"
-
typedef const unsigned char* CPU8;
inline sal_uInt16 NEXT_U16( CPU8& p ) { p+=2; return (p[-2]<<8)|p[-1]; }
inline sal_Int16 NEXT_S16( CPU8& p ) { return (sal_Int16)NEXT_U16(p); }
@@ -623,9 +617,6 @@ long FreetypeManager::AddFontDir( const String& rUrlName )
aDFA.mbSubsettable= false;
aDFA.mbEmbeddable = false;
- aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW;
- aDFA.meAntiAlias = ANTIALIAS_DONTKNOW;
-
FT_Done_Face( aFaceFT );
AddFontFile( aCFileName, nFaceNum, ++mnNextFontId, aDFA, NULL );
++nCount;
@@ -705,6 +696,7 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn
: ServerFont( rFSD ),
mnPrioEmbedded(nDefaultPrioEmbedded),
mnPrioAntiAlias(nDefaultPrioAntiAlias),
+ mnPrioAutoHint(nDefaultPrioAutoHint),
mpFontInfo( pFI ),
maFaceFT( NULL ),
maSizeFT( NULL ),
@@ -838,46 +830,71 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn
mbArtItalic = (rFSD.meItalic != ITALIC_NONE && pFI->GetFontAttributes().GetSlant() == ITALIC_NONE);
mbArtBold = (rFSD.meWeight > WEIGHT_MEDIUM && pFI->GetFontAttributes().GetWeight() <= WEIGHT_MEDIUM);
-
- //static const int TT_CODEPAGE_RANGE_874 = (1L << 16); // Thai
- //static const int TT_CODEPAGE_RANGE_932 = (1L << 17); // JIS/Japan
- //static const int TT_CODEPAGE_RANGE_936 = (1L << 18); // Chinese: Simplified
- //static const int TT_CODEPAGE_RANGE_949 = (1L << 19); // Korean Wansung
- //static const int TT_CODEPAGE_RANGE_950 = (1L << 20); // Chinese: Traditional
- //static const int TT_CODEPAGE_RANGE_1361 = (1L << 21); // Korean Johab
- static const int TT_CODEPAGE_RANGES1_CJKT = 0x3F0000; // all of the above
- const TT_OS2* pOs2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 );
- if ((pOs2) && (pOs2->ulCodePageRange1 & TT_CODEPAGE_RANGES1_CJKT )
+ mbUseGamma = false;
+ if( mbArtBold )
+ {
+ //static const int TT_CODEPAGE_RANGE_874 = (1L << 16); // Thai
+ //static const int TT_CODEPAGE_RANGE_932 = (1L << 17); // JIS/Japan
+ //static const int TT_CODEPAGE_RANGE_936 = (1L << 18); // Chinese: Simplified
+ //static const int TT_CODEPAGE_RANGE_949 = (1L << 19); // Korean Wansung
+ //static const int TT_CODEPAGE_RANGE_950 = (1L << 20); // Chinese: Traditional
+ //static const int TT_CODEPAGE_RANGE_1361 = (1L << 21); // Korean Johab
+ static const int TT_CODEPAGE_RANGES1_CJKT = 0x3F0000; // all of the above
+ const TT_OS2* pOs2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 );
+ if ((pOs2) && (pOs2->ulCodePageRange1 & TT_CODEPAGE_RANGES1_CJKT )
&& rFSD.mnHeight < 20)
mbUseGamma = true;
- else
- mbUseGamma = false;
+ }
+
+ if( ((mnCos != 0) && (mnSin != 0)) || (mnPrioEmbedded <= 0) )
+ mnLoadFlags |= FT_LOAD_NO_BITMAP;
+}
+
+void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions)
+{
+ FontAutoHint eHint = rFontOptions.GetUseAutoHint();
+ if( eHint == AUTOHINT_DONTKNOW )
+ eHint = mbUseGamma ? AUTOHINT_TRUE : AUTOHINT_FALSE;
- if (mbUseGamma)
+ if( eHint == AUTOHINT_TRUE )
mnLoadFlags |= FT_LOAD_FORCE_AUTOHINT;
if( (mnSin != 0) && (mnCos != 0) ) // hinting for 0/90/180/270 degrees only
mnLoadFlags |= FT_LOAD_NO_HINTING;
mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334#
- if (mpFontInfo->DontUseAntiAlias())
- mnPrioAntiAlias = 0;
- if (mpFontInfo->DontUseEmbeddedBitmaps())
- mnPrioEmbedded = 0;
+ if( rFontOptions.DontUseAntiAlias() )
+ mnPrioAntiAlias = 0;
+ if( rFontOptions.DontUseEmbeddedBitmaps() )
+ mnPrioEmbedded = 0;
+ if( rFontOptions.DontUseHinting() )
+ mnPrioAutoHint = 0;
#if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
- if( nDefaultPrioAutoHint <= 0 )
+ if( mnPrioAutoHint <= 0 )
#endif
mnLoadFlags |= FT_LOAD_NO_HINTING;
-#ifdef FT_LOAD_TARGET_LIGHT
- // enable "light hinting" if available
+#if defined(FT_LOAD_TARGET_LIGHT) && defined(FT_LOAD_TARGET_NORMAL)
if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103))
- mnLoadFlags |= FT_LOAD_TARGET_LIGHT;
+ {
+ mnLoadFlags |= FT_LOAD_TARGET_NORMAL;
+ switch( rFontOptions.GetHintStyle() )
+ {
+ case HINT_NONE:
+ mnLoadFlags |= FT_LOAD_NO_HINTING;
+ break;
+ case HINT_SLIGHT:
+ mnLoadFlags |= FT_LOAD_TARGET_LIGHT;
+ break;
+ case HINT_MEDIUM:
+ break;
+ case HINT_FULL:
+ default:
+ break;
+ }
+ }
#endif
-
- if( ((mnCos != 0) && (mnSin != 0)) || (mnPrioEmbedded <= 0) )
- mnLoadFlags |= FT_LOAD_NO_BITMAP;
}
// -----------------------------------------------------------------------
@@ -1231,13 +1248,15 @@ int FreetypeServerFont::FixupGlyphIndex( int nGlyphIndex, sal_UCS4 aChar ) const
}
}
-#if !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
+#if 0
// #95556# autohinting not yet optimized for non-western glyph styles
if( !(mnLoadFlags & (FT_LOAD_NO_HINTING | FT_LOAD_FORCE_AUTOHINT) )
&& ( (aChar >= 0x0600 && aChar < 0x1E00) // south-east asian + arabic
||(aChar >= 0x2900 && aChar < 0xD800) // CJKV
||(aChar >= 0xF800) ) ) // presentation + symbols
+ {
nGlyphFlags |= GF_UNHINTED;
+ }
#endif
if( nGlyphIndex != 0 )
@@ -1377,13 +1396,13 @@ bool FreetypeServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& rRawBitmap
nLoadFlags |= FT_LOAD_NO_BITMAP;
#if (FTVERSION >= 2002)
- // for 0/90/180/270 degree fonts enable autohinting even if not advisable
+ // for 0/90/180/270 degree fonts enable hinting even if not advisable
// non-hinted and non-antialiased bitmaps just look too ugly
- if( (mnCos==0 || mnSin==0) && (nDefaultPrioAutoHint > 0) )
+ if( (mnCos==0 || mnSin==0) && (mnPrioAutoHint > 0) )
nLoadFlags &= ~FT_LOAD_NO_HINTING;
#endif
- if( mnPrioEmbedded <= nDefaultPrioAutoHint )
+ if( mnPrioEmbedded <= mnPrioAutoHint )
nLoadFlags |= FT_LOAD_NO_BITMAP;
FT_Error rc = -1;
@@ -1548,7 +1567,7 @@ bool FreetypeServerFont::GetGlyphBitmap8( int nGlyphIndex, RawBitmap& rRawBitmap
// autohinting in FT<=2.0.4 makes antialiased glyphs look worse
nLoadFlags |= FT_LOAD_NO_HINTING;
#else
- if( (nGlyphFlags & GF_UNHINTED) || (nDefaultPrioAutoHint < mnPrioAntiAlias) )
+ if( (nGlyphFlags & GF_UNHINTED) || (mnPrioAutoHint < mnPrioAntiAlias) )
nLoadFlags |= FT_LOAD_NO_HINTING;
#endif
diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
index 2a181b494c9f..5ebe70bcbdf9 100644
--- a/vcl/source/glyphs/gcach_ftyp.hxx
+++ b/vcl/source/glyphs/gcach_ftyp.hxx
@@ -33,6 +33,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+
class FreetypeServerFont;
struct FT_GlyphRec_;
@@ -85,10 +86,6 @@ public:
int GetFaceNum() const { return mnFaceNum; }
int GetSynthetic() const { return mnSynthetic; }
sal_IntPtr GetFontId() const { return mnFontId; }
- bool DontUseAntiAlias() const
- { return maDevFontAttributes.UseAntiAlias() == ANTIALIAS_FALSE; }
- bool DontUseEmbeddedBitmaps() const
- { return maDevFontAttributes.UseEmbeddedBitmap() == EMBEDDEDBITMAP_FALSE; }
bool IsSymbolFont() const { return maDevFontAttributes.IsSymbolFont(); }
const ImplFontAttributes& GetFontAttributes() const { return maDevFontAttributes; }
@@ -178,6 +175,7 @@ public:
virtual int GetFontFaceNum() const { return mpFontInfo->GetFaceNum(); }
virtual bool TestFont() const;
virtual void* GetFtFace() const;
+ virtual void SetFontOptions( const ImplFontOptions&);
virtual int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); }
virtual bool NeedsArtificialBold() const { return mbArtBold; }
virtual bool NeedsArtificialItalic() const { return mbArtItalic; }
@@ -213,6 +211,7 @@ private:
int mnWidth;
int mnPrioEmbedded;
int mnPrioAntiAlias;
+ int mnPrioAutoHint;
FtFontInfo* mpFontInfo;
FT_Int mnLoadFlags;
double mfStretch;
diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx
index 34133a39ac95..ea0f18896b7a 100644
--- a/vcl/source/glyphs/glyphcache.cxx
+++ b/vcl/source/glyphs/glyphcache.cxx
@@ -69,13 +69,22 @@ GlyphCache::GlyphCache( GlyphCachePeer& rPeer )
GlyphCache::~GlyphCache()
{
-// TODO:
-// for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it )
-// delete const_cast<ServerFont*>( it->second );
+ InvalidateAllGlyphs();
if( mpFtManager )
delete mpFtManager;
}
+// -----------------------------------------------------------------------
+
+void GlyphCache::InvalidateAllGlyphs()
+{
+#if 0 // TODO: implement uncaching of all glyph shapes and metrics
+ for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it )
+ delete const_cast<ServerFont*>( it->second );
+ maFontList.clear();
+ mpCurrentGCFont = NULL;
+#endif
+}
// -----------------------------------------------------------------------
@@ -582,3 +591,4 @@ int ExtraKernInfo::GetUnscaledKernValue( sal_Unicode cLeft, sal_Unicode cRight )
}
// =======================================================================
+