summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-10-28 13:41:10 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2018-10-30 20:42:19 +0100
commit996d7f36ddcd6d518f4b44d132b3c5e3300f0c24 (patch)
tree5fb211f185c06dac6c2ff620b4c5982dca25dc86 /vcl
parent0ea92ad5332ddb6583c82275071c3be3939ebf28 (diff)
Move SalGraphics glyph functions into FontInstance
As we already rely on the GlyphItem's font instance, consequently this removes the SalGraphics GlyphItem based functions. Also unifies the glyph bound rect cache handling. An interesting aspect is the rotated glyph bounding box handling moved from CairoTextRender to FreetypeFont. It doesn't look like an implementation detail for Cairo, so it may have been a bug. Change-Id: I81bbb5d8ee98fb77a1eee05568c456f9e4553023 Reviewed-on: https://gerrit.libreoffice.org/62503 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svptext.cxx10
-rw-r--r--vcl/inc/PhysicalFontFace.hxx2
-rw-r--r--vcl/inc/fontinstance.hxx6
-rw-r--r--vcl/inc/headless/svpgdi.hxx2
-rw-r--r--vcl/inc/impglyphitem.hxx12
-rw-r--r--vcl/inc/qt5/Qt5Font.hxx3
-rw-r--r--vcl/inc/qt5/Qt5Graphics.hxx3
-rw-r--r--vcl/inc/quartz/salgdi.h11
-rw-r--r--vcl/inc/salgdi.hxx3
-rw-r--r--vcl/inc/sallayout.hxx2
-rw-r--r--vcl/inc/textrender.hxx2
-rw-r--r--vcl/inc/unx/cairotextrender.hxx2
-rw-r--r--vcl/inc/unx/freetype_glyphcache.hxx11
-rw-r--r--vcl/inc/unx/genpspgraphics.h2
-rw-r--r--vcl/inc/unx/glyphcache.hxx4
-rw-r--r--vcl/inc/unx/salgdi.h2
-rw-r--r--vcl/inc/win/salgdi.h3
-rw-r--r--vcl/inc/win/winlayout.hxx7
-rw-r--r--vcl/qt5/Qt5Font.cxx9
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx13
-rw-r--r--vcl/quartz/ctfonts.cxx16
-rw-r--r--vcl/quartz/salgdi.cxx10
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx5
-rw-r--r--vcl/source/font/fontinstance.cxx17
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx25
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx16
-rw-r--r--vcl/source/gdi/sallayout.cxx14
-rw-r--r--vcl/source/outdev/font.cxx2
-rw-r--r--vcl/source/outdev/text.cxx6
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx36
-rw-r--r--vcl/unx/generic/gdi/font.cxx11
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx30
-rw-r--r--vcl/unx/generic/glyphs/glyphcache.cxx16
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx19
-rw-r--r--vcl/win/gdi/DWriteTextRenderer.cxx2
-rw-r--r--vcl/win/gdi/salfont.cxx50
-rw-r--r--vcl/win/gdi/winlayout.cxx4
37 files changed, 157 insertions, 231 deletions
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index aab960a576a7..aead84a1467b 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -92,16 +92,6 @@ void SvpSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
m_aTextRenderImpl.GetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
}
-bool SvpSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- return m_aTextRenderImpl.GetGlyphBoundRect(rGlyph, rRect);
-}
-
-bool SvpSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly)
-{
- return m_aTextRenderImpl.GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
std::unique_ptr<SalLayout> SvpSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
{
if (utl::ConfigManager::IsFuzzing())
diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index c350a6c81649..23af5be9169e 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -54,7 +54,7 @@ public:
class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes, public salhelper::SimpleReferenceObject
{
public:
- virtual rtl::Reference<LogicalFontInstance> CreateFontInstance(const FontSelectPattern&) const;
+ virtual rtl::Reference<LogicalFontInstance> CreateFontInstance(const FontSelectPattern&) const = 0;
int GetHeight() const { return mnHeight; }
int GetWidth() const { return mnWidth; }
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 6f171ce72e49..5e1d70ad9600 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -70,8 +70,8 @@ public: // TODO: make data members private
const PhysicalFontFace* GetFontFace() const { return m_pFontFace.get(); }
const ImplFontCache* GetFontCache() const { return mpFontCache; }
- bool GetCachedGlyphBoundRect(sal_GlyphId, tools::Rectangle &) const;
- void CacheGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &) const;
+ bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
+ virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const = 0;
int GetKashidaWidth();
@@ -81,6 +81,8 @@ public: // TODO: make data members private
protected:
explicit LogicalFontInstance(const PhysicalFontFace&, const FontSelectPattern&);
+ virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const = 0;
+
// Takes ownership of pHbFace.
hb_font_t* InitHbFont(hb_face_t* pHbFace) const;
virtual hb_font_t* ImplInitHbFont() { assert(false); return nullptr; }
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index d1a4d9264ecc..1b24f2fa8c5d 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -191,8 +191,6 @@ public:
bool bVertical,
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout( const GenericSalLayout& ) override;
diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index d4c944717419..4c7673ed2077 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -76,18 +76,18 @@ struct VCL_DLLPUBLIC GlyphItem
bool IsDropped() const { return ((m_nFlags & IS_DROPPED) != 0); }
bool IsClusterStart() const { return ((m_nFlags & IS_CLUSTER_START) != 0); }
- inline bool GetCachedGlyphBoundRect(tools::Rectangle& rRect) const;
- inline void CacheGlyphBoundRect(tools::Rectangle& rRect) const;
+ inline bool GetGlyphBoundRect(tools::Rectangle&) const;
+ inline bool GetGlyphOutline(basegfx::B2DPolyPolygon&) const;
};
-VCL_DLLPUBLIC bool GlyphItem::GetCachedGlyphBoundRect(tools::Rectangle& rRect) const
+VCL_DLLPUBLIC bool GlyphItem::GetGlyphBoundRect(tools::Rectangle& rRect) const
{
- return m_pFontInstance->GetCachedGlyphBoundRect(m_aGlyphId, rRect);
+ return m_pFontInstance->GetGlyphBoundRect(m_aGlyphId, rRect, IsVertical());
}
-VCL_DLLPUBLIC void GlyphItem::CacheGlyphBoundRect(tools::Rectangle& rRect) const
+VCL_DLLPUBLIC bool GlyphItem::GetGlyphOutline(basegfx::B2DPolyPolygon& rPoly) const
{
- m_pFontInstance->CacheGlyphBoundRect(m_aGlyphId, rRect);
+ return m_pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical());
}
class SalLayoutGlyphsImpl : public std::vector<GlyphItem>
diff --git a/vcl/inc/qt5/Qt5Font.hxx b/vcl/inc/qt5/Qt5Font.hxx
index de5cd16039f1..0720be93112b 100644
--- a/vcl/inc/qt5/Qt5Font.hxx
+++ b/vcl/inc/qt5/Qt5Font.hxx
@@ -30,6 +30,9 @@ class Qt5Font final : public QFont, public LogicalFontInstance
friend rtl::Reference<LogicalFontInstance>
Qt5FontFace::CreateFontInstance(const FontSelectPattern&) const;
+ bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
+ bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
+
virtual hb_font_t* ImplInitHbFont() override;
explicit Qt5Font(const PhysicalFontFace&, const FontSelectPattern&);
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index 76c39146728c..d60a42c8c496 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -195,9 +195,6 @@ public:
virtual void GetGlyphWidths(const PhysicalFontFace*, bool bVertical,
std::vector<sal_Int32>& rWidths, Ucs2UIntMap& rUnicodeEnc) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
-
virtual std::unique_ptr<SalLayout> GetTextLayout(ImplLayoutArgs&, int nFallbackLevel) override;
virtual void DrawTextLayout(const GenericSalLayout&) override;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 0fb20bb490cc..b79bf4425534 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -77,7 +77,7 @@ private:
mutable bool mbFontCapabilitiesRead;
};
-class CoreTextStyle : public LogicalFontInstance
+class CoreTextStyle final : public LogicalFontInstance
{
friend rtl::Reference<LogicalFontInstance> CoreTextFontFace::CreateFontInstance(const FontSelectPattern&) const;
@@ -85,8 +85,7 @@ public:
~CoreTextStyle() override;
void GetFontMetric( ImplFontMetricDataRef const & );
- bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&);
- bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) const;
+ bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
@@ -98,7 +97,8 @@ public:
private:
explicit CoreTextStyle(const PhysicalFontFace&, const FontSelectPattern&);
- virtual hb_font_t* ImplInitHbFont() override;
+ hb_font_t* ImplInitHbFont() override;
+ bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
/// CoreText text style object
CFMutableDictionaryRef mpStyleDict;
@@ -373,9 +373,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
-
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout( const GenericSalLayout& ) override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index eb96cfa22a13..e2d6a62278eb 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -189,9 +189,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) = 0;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) = 0;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) = 0;
-
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0;
virtual void DrawTextLayout( const GenericSalLayout& ) = 0;
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 56c25f9d70c4..cd2b02f105aa 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -133,7 +133,7 @@ public:
bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart,
const PhysicalFontFace** pFallbackFont = nullptr,
int* const pFallbackLevel = nullptr) const override;
- bool GetOutline(SalGraphics&, basegfx::B2DPolyPolygonVector&) const override;
+ bool GetOutline(basegfx::B2DPolyPolygonVector&) const override;
bool IsKashidaPosValid(int nCharPos) const override;
// used only by OutputDevice::ImplLayout, TODO: make friend
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index 33c803dba82b..31bcb04c7628 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -59,8 +59,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) = 0;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) = 0;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) = 0;
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0;
virtual void DrawTextLayout(const GenericSalLayout&, const SalGraphics&) = 0;
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 8d18836be91b..25272b92637e 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -75,8 +75,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout(const GenericSalLayout&, const SalGraphics&) override;
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 58cd4eba38b1..774eec877957 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -107,6 +107,7 @@ class VCL_DLLPUBLIC FreetypeFontInstance : public LogicalFontInstance
FreetypeFont* mpFreetypeFont;
virtual hb_font_t* ImplInitHbFont() override;
+ virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
protected:
explicit FreetypeFontInstance(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP);
@@ -116,15 +117,9 @@ public:
void SetFreetypeFont(FreetypeFont* p);
FreetypeFont* GetFreetypeFont() const { return mpFreetypeFont; }
-};
-inline FreetypeFont* getFreetypeFontFromGlyph(const GlyphItem& rGlyph)
-{
- assert(rGlyph.m_pFontInstance);
- if (!rGlyph.m_pFontInstance)
- return nullptr;
- return static_cast<FreetypeFontInstance*>(rGlyph.m_pFontInstance)->GetFreetypeFont();
-}
+ virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
+};
#endif // INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index bddcb888ebc6..e7314cb2ace3 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -111,8 +111,6 @@ public:
bool bVertical,
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout( const GenericSalLayout& ) override;
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 9fe3bd3dc7cf..185d42cb683d 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -111,8 +111,8 @@ public:
const FontCharMapRef GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities &) const;
- bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&);
- bool GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon&) const;
+ bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
+ bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const;
bool GetAntialiasAdvice() const;
FreetypeFontInstance* GetFontInstance() const { return mpFontInstance.get(); }
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 94f4a9a00a06..4fd30762d045 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -141,8 +141,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout( const GenericSalLayout& ) override;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index e8fe72cc4ca7..4b829f36d886 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -373,9 +373,6 @@ public:
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc ) override;
- virtual bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) override;
- virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override;
-
virtual std::unique_ptr<SalLayout>
GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override;
virtual void DrawTextLayout( const GenericSalLayout& ) override;
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 036c1d3bcbbd..042e30e9f299 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -148,7 +148,7 @@ class WinFontInstance : public LogicalFontInstance
friend rtl::Reference<LogicalFontInstance> WinFontFace::CreateFontInstance(const FontSelectPattern&) const;
public:
- virtual ~WinFontInstance() override;
+ ~WinFontInstance() override;
bool hasHScale() const;
@@ -167,10 +167,13 @@ public:
bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics);
OpenGLGlyphCache& GetOpenGLGlyphCache() { return maOpenGLGlyphCache; }
+ bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
+
private:
explicit WinFontInstance(const WinFontFace&, const FontSelectPattern&);
- virtual hb_font_t* ImplInitHbFont() override;
+ hb_font_t* ImplInitHbFont() override;
+ bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override;
WinSalGraphics *m_pGraphics;
HFONT m_hFont;
diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx
index 04516dffa367..be00f7a9ec5f 100644
--- a/vcl/qt5/Qt5Font.cxx
+++ b/vcl/qt5/Qt5Font.cxx
@@ -101,4 +101,13 @@ hb_font_t* Qt5Font::ImplInitHbFont()
return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr));
}
+bool Qt5Font::GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const { return false; }
+
+bool Qt5Font::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool) const
+{
+ QRawFont aRawFont(QRawFont::fromFont(*this));
+ rRect = toRectangle(aRawFont.boundingRect(nId).toAlignedRect());
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 79b5c8fe1f8e..ba7133f7b53e 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -152,19 +152,6 @@ void Qt5Graphics::GetGlyphWidths(const PhysicalFontFace* /*pPFF*/, bool /*bVerti
{
}
-bool Qt5Graphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- Qt5Font* pFont = static_cast<Qt5Font*>(rGlyph.m_pFontInstance);
- if (!pFont)
- return false;
-
- QRawFont aRawFont(QRawFont::fromFont(*pFont));
- rRect = toRectangle(aRawFont.boundingRect(rGlyph.m_aGlyphId).toAlignedRect());
- return true;
-}
-
-bool Qt5Graphics::GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) { return false; }
-
class Qt5CommonSalLayout : public GenericSalLayout
{
public:
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index fee6a676ac6c..e98fac83b0f6 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -138,13 +138,9 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric )
rxFontMetric->SetMinKashida(GetKashidaWidth());
}
-bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect )
+bool CoreTextStyle::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bVertical) const
{
- assert(this == rGlyph.m_pFontInstance);
- if (rGlyph.GetCachedGlyphBoundRect(rRect))
- return true;
-
- CGGlyph nCGGlyph = rGlyph.m_aGlyphId;
+ CGGlyph nCGGlyph = nId;
CTFontRef aCTFontRef = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName ));
SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.11 kCTFontDefaultOrientation
@@ -153,7 +149,7 @@ bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle&
CGRect aCGRect = CTFontGetBoundingRectsForGlyphs(aCTFontRef, aFontOrientation, &nCGGlyph, nullptr, 1);
// Apply font rotation to non-vertical glyphs.
- if (mfFontRotation && !rGlyph.IsVertical())
+ if (mfFontRotation && !bVertical)
aCGRect = CGRectApplyAffineTransform(aCGRect, CGAffineTransformMakeRotation(mfFontRotation));
long xMin = floor(aCGRect.origin.x);
@@ -161,8 +157,6 @@ bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle&
long xMax = ceil(aCGRect.origin.x + aCGRect.size.width);
long yMax = ceil(aCGRect.origin.y + aCGRect.size.height);
rRect = tools::Rectangle(xMin, -yMax, xMax, -yMin);
-
- rGlyph.CacheGlyphBoundRect(rRect);
return true;
}
@@ -218,11 +212,11 @@ static void MyCGPathApplierFunc( void* pData, const CGPathElement* pElement )
}
}
-bool CoreTextStyle::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rResult) const
+bool CoreTextStyle::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rResult, bool) const
{
rResult.clear();
- CGGlyph nCGGlyph = rGlyph.m_aGlyphId;
+ CGGlyph nCGGlyph = nId;
CTFontRef pCTFont = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName ));
SAL_WNODEPRECATED_DECLARATIONS_PUSH
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 639f54a74144..d64fc8677ce7 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -370,16 +370,6 @@ bool AquaSalGraphics::AddTempDevFont( PhysicalFontCollection*,
return ::AddTempDevFont(rFontFileURL);
}
-bool AquaSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly)
-{
- return static_cast<CoreTextStyle*>(rGlyph.m_pFontInstance)->GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
-bool AquaSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect )
-{
- return static_cast<CoreTextStyle*>(rGlyph.m_pFontInstance)->GetGlyphBoundRect(rGlyph, rRect);
-}
-
void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
{
#ifdef IOS
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 1b0940c8fb76..ccf81781b982 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -37,11 +37,6 @@ PhysicalFontFace::PhysicalFontFace( const FontAttributes& rDFA )
SetSymbolFlag( true );
}
-rtl::Reference<LogicalFontInstance> PhysicalFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
-{
- return new LogicalFontInstance(*this, rFSD);
-}
-
sal_Int32 PhysicalFontFace::CompareIgnoreSize( const PhysicalFontFace& rOther ) const
{
// compare their width, weight, italic, style name and family name
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 7cdf4b931978..5b83587c0261 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -142,18 +142,15 @@ void LogicalFontInstance::IgnoreFallbackForUnicode( sal_UCS4 cChar, FontWeight e
mpUnicodeFallbackList->erase( it );
}
-bool LogicalFontInstance::GetCachedGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &rRect) const
+bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &rRect, bool bVertical) const
{
- if (!mpFontCache)
- return false;
- return mpFontCache->GetCachedGlyphBoundRect(this, nID, rRect);
-}
+ if (mpFontCache && mpFontCache->GetCachedGlyphBoundRect(this, nID, rRect))
+ return true;
-void LogicalFontInstance::CacheGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &rRect) const
-{
- if (!mpFontCache)
- return;
- mpFontCache->CacheGlyphBoundRect(this, nID, rRect);
+ bool res = ImplGetGlyphBoundRect(nID, rRect, bVertical);
+ if (mpFontCache && res)
+ mpFontCache->CacheGlyphBoundRect(this, nID, rRect);
+ return res;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index ba20619a5118..bcba21cf97d0 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2186,11 +2186,30 @@ static FontAttributes GetDevFontAttributes( const PDFWriterImpl::BuiltinFont& rB
return aDFA;
}
-PdfBuiltinFontFace::PdfBuiltinFontFace( const PDFWriterImpl::BuiltinFont& rBuiltin )
-: PhysicalFontFace( GetDevFontAttributes(rBuiltin) ),
- mrBuiltin( rBuiltin )
+PdfBuiltinFontInstance::PdfBuiltinFontInstance(const PhysicalFontFace& rFontFace, const FontSelectPattern& rFSP)
+ : LogicalFontInstance(rFontFace, rFSP)
{}
+bool PdfBuiltinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const
+{
+ return false;
+}
+
+bool PdfBuiltinFontInstance::GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const
+{
+ return false;
+}
+
+PdfBuiltinFontFace::PdfBuiltinFontFace(const PDFWriterImpl::BuiltinFont& rBuiltin)
+ : PhysicalFontFace(GetDevFontAttributes(rBuiltin))
+ , mrBuiltin(rBuiltin)
+{}
+
+rtl::Reference<LogicalFontInstance> PdfBuiltinFontFace::CreateFontInstance(const FontSelectPattern& rFSP) const
+{
+ return new PdfBuiltinFontInstance(*this, rFSP);
+}
+
void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
{
endPage();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index ae1d3bdc07c1..ef08fd56ce79 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -1270,11 +1270,22 @@ public:
void MARK( const char* pString );
};
-class PdfBuiltinFontFace : public PhysicalFontFace
+class PdfBuiltinFontInstance final : public LogicalFontInstance
+{
+ bool ImplGetGlyphBoundRect(sal_GlyphId nID, tools::Rectangle &rRect, bool) const override;
+
+public:
+ PdfBuiltinFontInstance(const PhysicalFontFace&, const FontSelectPattern&);
+
+ bool GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rPoly, bool) const override;
+};
+
+class PdfBuiltinFontFace final : public PhysicalFontFace
{
-private:
const PDFWriterImpl::BuiltinFont& mrBuiltin;
+ rtl::Reference<LogicalFontInstance> CreateFontInstance(const FontSelectPattern& rFSD) const override;
+
public:
explicit PdfBuiltinFontFace( const PDFWriterImpl::BuiltinFont& );
const PDFWriterImpl::BuiltinFont& GetBuiltinFont() const { return mrBuiltin; }
@@ -1282,7 +1293,6 @@ public:
virtual sal_IntPtr GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); }
};
-
}
#endif //_VCL_PDFEXPORT_HXX
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 4ecf9a26193d..68319505a3fc 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -633,8 +633,7 @@ static int lcl_CalcAsianKerning( sal_UCS4 c, bool bLeft, bool /*TODO:? bVertical
return nResult;
}
-bool SalLayout::GetOutline( SalGraphics& rSalGraphics,
- basegfx::B2DPolyPolygonVector& rVector ) const
+bool SalLayout::GetOutline(basegfx::B2DPolyPolygonVector& rVector) const
{
bool bAllOk = true;
bool bOneOk = false;
@@ -647,7 +646,7 @@ bool SalLayout::GetOutline( SalGraphics& rSalGraphics,
while (GetNextGlyph(&pGlyph, aPos, nStart))
{
// get outline of individual glyph, ignoring "empty" glyphs
- bool bSuccess = rSalGraphics.GetGlyphOutline(*pGlyph, aGlyphOutline);
+ bool bSuccess = pGlyph->GetGlyphOutline(aGlyphOutline);
bAllOk &= bSuccess;
bOneOk |= bSuccess;
// only add non-empty outlines
@@ -666,7 +665,7 @@ bool SalLayout::GetOutline( SalGraphics& rSalGraphics,
return (bAllOk && bOneOk);
}
-bool SalLayout::GetBoundRect( SalGraphics& rSalGraphics, tools::Rectangle& rRect ) const
+bool SalLayout::GetBoundRect(tools::Rectangle& rRect) const
{
bool bRet = false;
rRect.SetEmpty();
@@ -679,7 +678,7 @@ bool SalLayout::GetBoundRect( SalGraphics& rSalGraphics, tools::Rectangle& rRect
while (GetNextGlyph(&pGlyph, aPos, nStart))
{
// get bounding rectangle of individual glyph
- if (rSalGraphics.GetGlyphBoundRect(*pGlyph, aRectangle))
+ if (pGlyph->GetGlyphBoundRect(aRectangle))
{
// merge rectangle
aRectangle += aPos;
@@ -1535,8 +1534,7 @@ bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph,
return false;
}
-bool MultiSalLayout::GetOutline( SalGraphics& rGraphics,
- basegfx::B2DPolyPolygonVector& rPPV ) const
+bool MultiSalLayout::GetOutline(basegfx::B2DPolyPolygonVector& rPPV) const
{
bool bRet = false;
@@ -1546,7 +1544,7 @@ bool MultiSalLayout::GetOutline( SalGraphics& rGraphics,
rLayout.DrawBase() = maDrawBase;
rLayout.DrawOffset() += maDrawOffset;
rLayout.InitFont();
- bRet |= rLayout.GetOutline( rGraphics, rPPV );
+ bRet |= rLayout.GetOutline(rPPV);
rLayout.DrawOffset() -= maDrawOffset;
}
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 44c010869df6..8cdaebb612df 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1251,7 +1251,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
int nStart = 0;
while (rSalLayout.GetNextGlyph(&pGlyph, aOutPoint, nStart))
{
- if (!mpGraphics->GetGlyphBoundRect(*pGlyph, aRectangle ) )
+ if (!pGlyph->GetGlyphBoundRect(aRectangle))
continue;
if (!pGlyph->IsSpacing())
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index cdb5e5c9e597..e2e135812ff8 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -201,7 +201,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
tools::Rectangle aBoundRect;
rSalLayout.DrawBase() = Point( 0, 0 );
rSalLayout.DrawOffset() = Point( 0, 0 );
- if( !rSalLayout.GetBoundRect( *mpGraphics, aBoundRect ) )
+ if (!rSalLayout.GetBoundRect(aBoundRect))
{
// guess vertical text extents if GetBoundRect failed
long nRight = rSalLayout.GetTextWidth();
@@ -2360,7 +2360,7 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
tools::Rectangle aPixelRect;
if( pSalLayout )
{
- bRet = pSalLayout->GetBoundRect( *mpGraphics, aPixelRect );
+ bRet = pSalLayout->GetBoundRect(aPixelRect);
if( bRet )
{
@@ -2438,7 +2438,7 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
pSalLayout = ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray );
if( pSalLayout )
{
- bRet = pSalLayout->GetOutline( *mpGraphics, rVector );
+ bRet = pSalLayout->GetOutline(rVector);
if( bRet )
{
// transform polygon to pixel units
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 13c8e156dc5b..c8956d02226b 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -442,42 +442,6 @@ void CairoTextRender::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nF
mpFreetypeFont[nFallbackLevel]->GetFontMetric(rxFontMetric);
}
-bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- tools::Rectangle aRect;
- if (!pSF->GetGlyphBoundRect(rGlyph, aRect))
- return false;
-
- if ( pSF->mnCos != 0x10000 && pSF->mnSin != 0 )
- {
- double nCos = pSF->mnCos / 65536.0;
- double nSin = pSF->mnSin / 65536.0;
- rRect.SetLeft( nCos*aRect.Left() + nSin*aRect.Top() );
- rRect.SetTop( -nSin*aRect.Left() - nCos*aRect.Top() );
-
- rRect.SetRight( nCos*aRect.Right() + nSin*aRect.Bottom() );
- rRect.SetBottom( -nSin*aRect.Right() - nCos*aRect.Bottom() );
- }
- else
- rRect = aRect;
-
- return true;
-}
-
-bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rPolyPoly )
-{
- const FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
std::unique_ptr<SalLayout> CairoTextRender::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
{
if (!mpFreetypeFont[nFallbackLevel])
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 381e79373953..85ad6600dd99 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -105,17 +105,6 @@ X11SalGraphics::GetFontMetric( ImplFontMetricDataRef &rxFontMetric, int nFallbac
mxTextRenderImpl->GetFontMetric(rxFontMetric, nFallbackLevel);
}
-bool X11SalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- return mxTextRenderImpl->GetGlyphBoundRect(rGlyph, rRect);
-}
-
-bool X11SalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rPolyPoly )
-{
- return mxTextRenderImpl->GetGlyphOutline(rGlyph, rPolyPoly);
-}
-
std::unique_ptr<SalLayout> X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
{
return mxTextRenderImpl->GetTextLayout(rArgs, nFallbackLevel);
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 50f1b8d451c6..42bf6d0a98b9 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -589,14 +589,11 @@ void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const
}
}
-bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
+bool FreetypeFont::GetGlyphBoundRect(sal_GlyphId nID, tools::Rectangle& rRect, bool bVertical) const
{
- if (rGlyph.GetCachedGlyphBoundRect(rRect))
- return true;
-
FT_Activate_Size( maSizeFT );
- FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.m_aGlyphId, mnLoadFlags);
+ FT_Error rc = FT_Load_Glyph(maFaceFT, nID, mnLoadFlags);
if (rc != FT_Err_Ok)
return false;
@@ -609,14 +606,24 @@ bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle&
if (rc != FT_Err_Ok)
return false;
- ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT);
+ ApplyGlyphTransform(bVertical, pGlyphFT);
FT_BBox aBbox;
FT_Glyph_Get_CBox( pGlyphFT, FT_GLYPH_BBOX_PIXELS, &aBbox );
FT_Done_Glyph( pGlyphFT );
- rRect = tools::Rectangle(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin);
- rGlyph.CacheGlyphBoundRect(rRect);
+ tools::Rectangle aRect(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin);
+ if (mnCos != 0x10000 && mnSin != 0)
+ {
+ const double nCos = mnCos / 65536.0;
+ const double nSin = mnSin / 65536.0;
+ rRect.SetLeft( nCos*aRect.Left() + nSin*aRect.Top() );
+ rRect.SetTop( -nSin*aRect.Left() - nCos*aRect.Top() );
+ rRect.SetRight( nCos*aRect.Right() + nSin*aRect.Bottom() );
+ rRect.SetBottom( -nSin*aRect.Right() - nCos*aRect.Bottom() );
+ }
+ else
+ rRect = aRect;
return true;
}
@@ -876,8 +883,7 @@ static int FT_cubic_to( const FT_Vector* p1, const FT_Vector* p2, const FT_Vecto
} // extern "C"
-bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rB2DPolyPoly ) const
+bool FreetypeFont::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rB2DPolyPoly, bool bIsVertical) const
{
if( maSizeFT )
FT_Activate_Size( maSizeFT );
@@ -891,7 +897,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
nLoadFlags |= FT_LOAD_TARGET_LIGHT;
#endif
- FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.m_aGlyphId, nLoadFlags);
+ FT_Error rc = FT_Load_Glyph(maFaceFT, nId, nLoadFlags);
if( rc != FT_Err_Ok )
return false;
@@ -929,7 +935,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph,
tools::PolyPolygon aToolPolyPolygon;
PolyArgs aPolyArg( aToolPolyPolygon, nMaxPoints );
- ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT);
+ ApplyGlyphTransform(bIsVertical, pGlyphFT);
FT_Outline_Funcs aFuncs;
aFuncs.move_to = &FT_move_to;
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index f008a0294df0..29e0d1ba65b6 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -299,4 +299,20 @@ hb_font_t* FreetypeFontInstance::ImplInitHbFont()
return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr));
}
+bool FreetypeFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bVertical) const
+{
+ assert(mpFreetypeFont);
+ if (!mpFreetypeFont)
+ return false;
+ return mpFreetypeFont->GetGlyphBoundRect(nId, rRect, bVertical);
+}
+
+bool FreetypeFontInstance::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rPoly, bool bVertical) const
+{
+ assert(mpFreetypeFont);
+ if (!mpFreetypeFont)
+ return false;
+ return mpFreetypeFont->GetGlyphOutline(nId, rPoly, bVertical);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 67621170b999..3043d99e01be 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -733,25 +733,6 @@ void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFal
m_pFreetypeFont[nFallbackLevel]->GetFontMetric(rxFontMetric);
}
-bool GenPspGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphBoundRect(rGlyph, rRect);
-}
-
-bool GenPspGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rB2DPolyPoly )
-{
- FreetypeFont* pSF = getFreetypeFontFromGlyph(rGlyph);
- if( !pSF )
- return false;
-
- return pSF->GetGlyphOutline(rGlyph, rB2DPolyPoly);
-}
-
std::unique_ptr<SalLayout> GenPspGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel)
{
if (!m_pFreetypeFont[nFallbackLevel])
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx
index f8aa907180eb..6dbfdbf403c3 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -272,7 +272,7 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
return false;
tools::Rectangle bounds;
- bool succeeded = rLayout.GetBoundRect(rGraphics, bounds);
+ bool succeeded = rLayout.GetBoundRect(bounds);
if (succeeded)
{
hr = BindDC(hDC, bounds); // Update the bounding rect.
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 2303f7ba0bc1..155c08e962fb 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -46,6 +46,7 @@
#include <vcl/metric.hxx>
#include <vcl/fontcharmap.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
+#include <comphelper/scopeguard.hxx>
#include <fontsubset.hxx>
#include <outdev.h>
@@ -1326,19 +1327,18 @@ void WinSalGraphics::ClearDevFontCache()
//anything to do here ?
}
-bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect)
+bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool) const
{
- if (rGlyph.GetCachedGlyphBoundRect(rRect))
- return true;
-
- WinFontInstance* pFont = static_cast<WinFontInstance*>(rGlyph.m_pFontInstance);
+ assert(m_pGraphics);
+ HDC hDC = m_pGraphics->getHDC();
+ const HFONT hOrigFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
+ const HFONT hFont = GetHFONT();
+ if (hFont != hOrigFont)
+ SelectObject(hDC, hFont);
- HDC hDC = getHDC();
- HFONT hFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
- float fFontScale = 1.0;
- if (hFont != pFont->GetHFONT())
- SelectObject(hDC, pFont->GetHFONT());
- fFontScale = pFont->GetScale();
+ const ::comphelper::ScopeGuard aFontRestoreScopeGuard([hFont, hOrigFont, hDC]()
+ { if (hFont != hOrigFont) SelectObject(hDC, hOrigFont); });
+ const float fFontScale = GetScale();
// use unity matrix
MAT2 aMat;
@@ -1351,9 +1351,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
GLYPHMETRICS aGM;
aGM.gmptGlyphOrigin.x = aGM.gmptGlyphOrigin.y = 0;
aGM.gmBlackBoxX = aGM.gmBlackBoxY = 0;
- DWORD nSize = ::GetGlyphOutlineW(hDC, rGlyph.m_aGlyphId, nGGOFlags, &aGM, 0, nullptr, &aMat);
- if (hFont != pFont->GetHFONT())
- SelectObject(hDC, hFont);
+ DWORD nSize = ::GetGlyphOutlineW(hDC, nId, nGGOFlags, &aGM, 0, nullptr, &aMat);
if (nSize == GDI_ERROR)
return false;
@@ -1363,17 +1361,22 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle
rRect.SetRight(static_cast<int>( fFontScale * rRect.Right() ) + 1);
rRect.SetTop(static_cast<int>( fFontScale * rRect.Top() ));
rRect.SetBottom(static_cast<int>( fFontScale * rRect.Bottom() ) + 1);
-
- rGlyph.CacheGlyphBoundRect(rRect);
return true;
}
-bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
- basegfx::B2DPolyPolygon& rB2DPolyPoly )
+bool WinFontInstance::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rB2DPolyPoly, bool) const
{
rB2DPolyPoly.clear();
- HDC hDC = getHDC();
+ assert(m_pGraphics);
+ HDC hDC = m_pGraphics->getHDC();
+ const HFONT hOrigFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT));
+ const HFONT hFont = GetHFONT();
+ if (hFont != hOrigFont)
+ SelectObject(hDC, hFont);
+
+ const ::comphelper::ScopeGuard aFontRestoreScopeGuard([hFont, hOrigFont, hDC]()
+ { if (hFont != hOrigFont) SelectObject(hDC, hOrigFont); });
// use unity matrix
MAT2 aMat;
@@ -1384,14 +1387,14 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
nGGOFlags |= GGO_GLYPH_INDEX;
GLYPHMETRICS aGlyphMetrics;
- const DWORD nSize1 = ::GetGlyphOutlineW(hDC, rGlyph.m_aGlyphId, nGGOFlags, &aGlyphMetrics, 0, nullptr, &aMat);
+ const DWORD nSize1 = ::GetGlyphOutlineW(hDC, nId, nGGOFlags, &aGlyphMetrics, 0, nullptr, &aMat);
if( !nSize1 ) // blank glyphs are ok
return true;
else if( nSize1 == GDI_ERROR )
return false;
BYTE* pData = new BYTE[ nSize1 ];
- const DWORD nSize2 = ::GetGlyphOutlineW(hDC, rGlyph.m_aGlyphId, nGGOFlags,
+ const DWORD nSize2 = ::GetGlyphOutlineW(hDC, nId, nGGOFlags,
&aGlyphMetrics, nSize1, pData, &aMat );
if( nSize1 != nSize2 )
@@ -1541,10 +1544,7 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
// rescaling needed for the tools::PolyPolygon conversion
if( rB2DPolyPoly.count() )
{
- rtl::Reference<WinFontInstance> pFont = static_cast<WinFontInstance*>(rGlyph.m_pFontInstance);
- assert(pFont.is());
- float fFontScale = pFont.is() ? pFont->GetScale() : 1.0;
- const double fFactor(fFontScale/256);
+ const double fFactor(GetScale()/256);
rB2DPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(fFactor, fFactor));
}
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 71204b072c85..91e82e8ba40e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -419,7 +419,7 @@ bool WinSalGraphics::DrawCachedGlyphs(const GenericSalLayout& rLayout)
HDC hDC = getHDC();
tools::Rectangle aRect;
- rLayout.GetBoundRect(*this, aRect);
+ rLayout.GetBoundRect(aRect);
COLORREF color = GetTextColor(hDC);
Color salColor = Color(GetRValue(color), GetGValue(color), GetBValue(color));
@@ -511,7 +511,7 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
// switch to that if it performs well.
tools::Rectangle aRect;
- rLayout.GetBoundRect(*this, aRect);
+ rLayout.GetBoundRect(aRect);
WinOpenGLSalGraphicsImpl *pImpl = dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get());