[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/inc vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Nov 24 12:32:13 UTC 2016
vcl/inc/unx/cairotextrender.hxx | 6 ++++-
vcl/inc/unx/fc_fontoptions.hxx | 3 +-
vcl/inc/unx/freetype_glyphcache.hxx | 1
vcl/inc/unx/glyphcache.hxx | 3 +-
vcl/unx/generic/fontmanager/fontconfig.cxx | 29 ++++++++++++-------------
vcl/unx/generic/gdi/cairotextrender.cxx | 9 ++-----
vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 17 ++++++++++----
7 files changed, 39 insertions(+), 29 deletions(-)
New commits:
commit 65bc0588eb9e9212238768b3418711fbe881510f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Nov 23 14:54:50 2016 +0000
with wayland scaling cairo is meddling with our font
so I see mixed large scaled and small unscaled letters in the writer header/footer
widget among other places
so don't give it our FreeType font face (FC_FT_FACE), keep that for ourselves,
but instead set the filename and face index and let it make a new one itself.
Reviewed-on: https://gerrit.libreoffice.org/31127
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 8c3e1465223bd8c824c4cecfd0e6fc387583e592)
Change-Id: I2e5eceb7bf590ccfeb06123d0404120feacfff97
Reviewed-on: https://gerrit.libreoffice.org/31155
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 612daae..6427951 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -28,8 +28,10 @@
typedef struct FT_FaceRec_* FT_Face;
+class FontConfigFontOptions;
class ServerFont;
class GlyphCache;
+class FontConfigFontOptions;
typedef struct _cairo cairo_t;
class VCL_DLLPUBLIC CairoFontsCache
@@ -38,7 +40,7 @@ public:
struct CacheId
{
FT_Face maFace;
- const void *mpOptions;
+ const FontConfigFontOptions *mpOptions;
bool mbEmbolden;
bool mbVerticalMetrics;
bool operator ==(const CacheId& rOther) const
@@ -124,6 +126,8 @@ public:
#endif
};
+FontConfigFontOptions* GetFCFontOptions( const FontAttributes& rFontAttributes, int nSize);
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/fc_fontoptions.hxx b/vcl/inc/unx/fc_fontoptions.hxx
index d085e26..5a2af5d 100644
--- a/vcl/inc/unx/fc_fontoptions.hxx
+++ b/vcl/inc/unx/fc_fontoptions.hxx
@@ -51,7 +51,8 @@ public:
bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == FontHintStyle::NONE); }
- void* GetPattern(void * /*pFace*/, bool /*bEmbolden*/) const;
+ void SyncPattern(const OString& rFileName, int nFontFace, bool bEmbolden);
+ FcPattern* GetPattern() const;
private:
FcPattern* mpPattern;
};
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 3b8d315..7acdbd6 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -72,6 +72,7 @@ public:
void ReleaseFaceFT();
const OString& GetFontFileName() const { return mpFontFile->GetFileName(); }
+ int GetFontFaceIndex() const { return mnFaceNum; }
sal_IntPtr GetFontId() const { return mnFontId; }
bool IsSymbolFont() const { return maDevFontAttributes.IsSymbolFont(); }
const FontAttributes& GetFontAttributes() const { return maDevFontAttributes; }
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 04723cb..f605e16 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -151,6 +151,7 @@ public:
virtual ~ServerFont();
const OString& GetFontFileName() const;
+ int GetFontFaceIndex() const;
bool TestFont() const { return mbFaceOk;}
FT_Face GetFtFace() const;
int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); }
@@ -229,7 +230,7 @@ private:
FT_FaceRec_* maFaceFT;
FT_SizeRec_* maSizeFT;
- std::shared_ptr<FontConfigFontOptions> mxFontOptions;
+ mutable std::shared_ptr<FontConfigFontOptions> mxFontOptions;
bool mbFaceOk;
bool mbArtItalic;
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 957afb14..79971d5 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -1143,21 +1143,20 @@ FontConfigFontOptions::~FontConfigFontOptions()
FcPatternDestroy(mpPattern);
}
- void *FontConfigFontOptions::GetPattern(void * face, bool bEmbolden) const
- {
- FcValue value;
- value.type = FcTypeFTFace;
- value.u.f = face;
- FcPatternDel(mpPattern, FC_FT_FACE);
- FcPatternAdd (mpPattern, FC_FT_FACE, value, FcTrue);
- FcPatternDel(mpPattern, FC_EMBOLDEN);
- FcPatternAddBool(mpPattern, FC_EMBOLDEN, bEmbolden ? FcTrue : FcFalse);
-#if 0
- FcPatternDel(mpPattern, FC_VERTICAL_LAYOUT);
- FcPatternAddBool(mpPattern, FC_VERTICAL_LAYOUT, bVerticalLayout ? FcTrue : FcFalse);
-#endif
- return mpPattern;
- }
+FcPattern *FontConfigFontOptions::GetPattern() const
+{
+ return mpPattern;
+}
+
+void FontConfigFontOptions::SyncPattern(const OString& rFileName, int nIndex, bool bEmbolden)
+{
+ FcPatternDel(mpPattern, FC_FILE);
+ FcPatternAddString(mpPattern, FC_FILE, reinterpret_cast<FcChar8 const *>(rFileName.getStr()));
+ FcPatternDel(mpPattern, FC_INDEX);
+ FcPatternAddInteger(mpPattern, FC_INDEX, nIndex);
+ FcPatternDel(mpPattern, FC_EMBOLDEN);
+ FcPatternAddBool(mpPattern, FC_EMBOLDEN, bEmbolden ? FcTrue : FcFalse);
+}
FontConfigFontOptions* PrintFontManager::getFontOptions(
const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*))
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 513f5e5..c904fa0 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -244,12 +244,9 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout )
cairo_font_face_t* font_face = static_cast<cairo_font_face_t*>(CairoFontsCache::FindCachedFont(aId));
if (!font_face)
{
- const FontConfigFontOptions *pOptions = rFont.GetFontOptions().get();
- void *pPattern = pOptions ? pOptions->GetPattern(aFace, aId.mbEmbolden) : nullptr;
- if (pPattern)
- font_face = cairo_ft_font_face_create_for_pattern(static_cast<FcPattern*>(pPattern));
- if (!font_face)
- font_face = cairo_ft_font_face_create_for_ft_face(reinterpret_cast<FT_Face>(aFace), rFont.GetLoadFlags());
+ const FontConfigFontOptions *pOptions = aId.mpOptions;
+ FcPattern *pPattern = pOptions->GetPattern();
+ font_face = cairo_ft_font_face_create_for_pattern(pPattern);
CairoFontsCache::CacheFont(font_face, aId);
}
cairo_set_font_face(cr, font_face);
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index e12fcb8..db656d3 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -20,6 +20,7 @@
#include <vcl/fontcharmap.hxx>
+#include <unx/cairotextrender.hxx>
#include "unx/freetype_glyphcache.hxx"
#include <vcl/svapp.hxx>
@@ -510,11 +511,7 @@ ServerFont::ServerFont( const FontSelectPattern& rFSD, FreetypeFontInfo* pFI )
ApplyGSUB( rFSD );
// TODO: query GASP table for load flags
- mnLoadFlags = FT_LOAD_DEFAULT;
-#if 1 // #i97326# cairo sometimes uses FT_Set_Transform() on our FT_FACE
- // we are not using FT_Set_Transform() yet, so just ignore it for now
- mnLoadFlags |= FT_LOAD_IGNORE_TRANSFORM;
-#endif
+ mnLoadFlags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_TRANSFORM;
mbArtItalic = (rFSD.GetItalic() != ITALIC_NONE && pFI->GetFontAttributes().GetItalic() == ITALIC_NONE);
mbArtBold = (rFSD.GetWeight() > WEIGHT_MEDIUM && pFI->GetFontAttributes().GetWeight() <= WEIGHT_MEDIUM);
@@ -592,6 +589,12 @@ void ServerFont::SetFontOptions(const std::shared_ptr<FontConfigFontOptions>& xF
const std::shared_ptr<FontConfigFontOptions>& ServerFont::GetFontOptions() const
{
+ if (!mxFontOptions)
+ {
+ SAL_WARN("vcl", "this doesn't happen in practice I believe");
+ mxFontOptions.reset(GetFCFontOptions(mpFontInfo->GetFontAttributes(), maFontSelData.mnHeight));
+ }
+ mxFontOptions->SyncPattern(GetFontFileName(), GetFontFaceIndex(), NeedsArtificialBold());
return mxFontOptions;
}
@@ -600,6 +603,10 @@ const OString& ServerFont::GetFontFileName() const
return mpFontInfo->GetFontFileName();
}
+int ServerFont::GetFontFaceIndex() const
+{
+ return mpFontInfo->GetFontFaceIndex();
+}
ServerFont::~ServerFont()
{
More information about the Libreoffice-commits
mailing list