vcl/inc/font/LogicalFontInstance.hxx | 12 ------------ vcl/source/font/LogicalFontInstance.cxx | 30 ------------------------------ vcl/source/gdi/CommonSalLayout.cxx | 13 ------------- 3 files changed, 55 deletions(-)
New commits: commit 005e787efec6c1e352e3cd17231d70508cd18d8e Author: Jeff Huang <[email protected]> AuthorDate: Wed Dec 10 14:19:03 2025 +0800 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Dec 18 15:04:57 2025 +0100 tdf#169920 Remove hardcoded DFKai-SB fix Commit 257bb11cbc5b1eb1f90014f528b9e7d6ccfeae86 introduced a compensation to glyph position miscalculation for DFKai-SB. After commit 6f4a949c07eb06345df08c722f8e59e97888a499, this causes over- compensation. This patch reverts commit 257bb11cbc5b1eb1f90014f528b9e7d6ccfeae86 Co-authored-by: Firefly <[email protected]> Change-Id: I0027f38d5eae58694c59b7590fc3315aae5deef0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195347 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/font/LogicalFontInstance.hxx b/vcl/inc/font/LogicalFontInstance.hxx index 8a199a4c5980..943fd2555558 100644 --- a/vcl/inc/font/LogicalFontInstance.hxx +++ b/vcl/inc/font/LogicalFontInstance.hxx @@ -97,9 +97,6 @@ public: // TODO: make data members private inline hb_font_t* GetHbFont(); SAL_DLLPRIVATE bool IsGraphiteFont(); - // NeedOffsetCorrection: Return if the font need offset correction in TTB direction. - // nYOffset is the original offset. It is used to check if the correction is necessary. - SAL_DLLPRIVATE bool NeedOffsetCorrection(sal_Int32 nYOffset); void SetAverageWidthFactor(double nFactor) { m_nAveWidthFactor = std::abs(nFactor); } double GetAverageWidthFactor() const { return m_nAveWidthFactor; } const vcl::font::FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; } @@ -152,15 +149,6 @@ private: rtl::Reference<vcl::font::PhysicalFontFace> m_pFontFace; std::optional<bool> m_xbIsGraphiteFont; - enum class FontFamilyEnum - { - Unclassified, - DFKaiSB - }; - - // The value is initialized and used in NeedOffsetCorrection(). - std::optional<FontFamilyEnum> m_xeFontFamilyEnum; - mutable hb_draw_funcs_t* m_pHbDrawFuncs = nullptr; basegfx::B2DPolygon m_aDrawPolygon; }; diff --git a/vcl/source/font/LogicalFontInstance.cxx b/vcl/source/font/LogicalFontInstance.cxx index 971965385164..e79b06bf15d9 100644 --- a/vcl/source/font/LogicalFontInstance.cxx +++ b/vcl/source/font/LogicalFontInstance.cxx @@ -243,36 +243,6 @@ bool LogicalFontInstance::IsGraphiteFont() return *m_xbIsGraphiteFont; } -bool LogicalFontInstance::NeedOffsetCorrection(sal_Int32 nYOffset) -{ - if (!m_xeFontFamilyEnum) - { - m_xeFontFamilyEnum = FontFamilyEnum::Unclassified; - - // DFKai-SB (ukai.ttf) is a built-in font under traditional Chinese - // Windows. It has wrong extent values in glyf table. The problem results - // in wrong positioning of glyphs in vertical writing. - // Check https://github.com/harfbuzz/harfbuzz/issues/3521 for reference. - if (GetFontFace()->GetName(vcl::font::NAME_ID_FONT_FAMILY) == "DFKai-SB") - m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB; - } - - bool bRet = true; - - switch (*m_xeFontFamilyEnum) - { - case FontFamilyEnum::DFKaiSB: - // -839: optimization for one third of ukai.ttf - if (nYOffset == -839) - bRet = false; - break; - default: - bRet = false; - } - - return bRet; -} - bool LogicalFontInstance::NeedsArtificialBold() const { return m_aFontSelData.GetWeight() > WEIGHT_MEDIUM && m_pFontFace->GetWeight() <= WEIGHT_MEDIUM; diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index e6ec3a176ce5..4c6f54139e03 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -794,19 +794,6 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay nAdvance = -pHbPositions[i].y_advance; nXOffset = -pHbPositions[i].y_offset; nYOffset = -pHbPositions[i].x_offset - nBaseOffset; - - if (GetFont().NeedOffsetCorrection(pHbPositions[i].y_offset)) - { - // We need glyph's advance, top bearing, and height to - // correct y offset. - basegfx::B2DRectangle aRect; - // Get cached bound rect value for the font, - GetFont().GetGlyphBoundRect(nGlyphIndex, aRect, true); - - nXOffset = -(aRect.getMinX() / nXScale + ( pHbPositions[i].y_advance - + ( aRect.getHeight() / nXScale ) ) / 2.0 ); - } - } else {
