sd/qa/unit/PNGExportTests.cxx | 42 ++++++++++++++++++++++++++++++++++++++++++ vcl/inc/win/salgdi.h | 2 +- vcl/win/gdi/salfont.cxx | 10 ++++++---- vcl/win/window/salframe.cxx | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-)
New commits: commit 907358d6a7107f6b0dbe1749aaf85bef30a9e328 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Aug 19 19:02:49 2024 +0500 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Oct 18 14:34:15 2024 +0200 Explicitly request antialiasing in a test See commit a8d677035a6565ebc051375206786dab3a353578 (Make sure to anti-alias fonts on Windows, when required, 2024-08-19). Change-Id: I67f863b61002da883a91ca09aa432162985c755b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172042 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175129 diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index 2f6ea964d803..a4f56d4daddc 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -1000,6 +1000,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf162259) css::uno::Sequence<css::beans::PropertyValue> aFilterData{ comphelper::makePropertyValue(u"PixelWidth"_ustr, sal_Int32(101)), comphelper::makePropertyValue(u"PixelHeight"_ustr, sal_Int32(151)), + comphelper::makePropertyValue(u"AntiAliasing"_ustr, true), }; css::uno::Sequence<css::beans::PropertyValue> aDescriptor{ commit 8c295f2b87998ab8f9e4b3276b1fe0b7ee7251bb Author: Mike Kaganski <[email protected]> AuthorDate: Sat Aug 17 10:50:06 2024 +0500 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Oct 18 14:34:09 2024 +0200 Support for non-AA text on Windows In commit 3ecd8f19a91ed7141304a2080fb11612b5ff30b3 (vcl cairo text renderer: support non-AA text, 2018-07-26) and its follow-up commit e6538f5bdd876911ea30f84a6512c03908e620fd (tdf#118966 vcl: add a flag to determine if AA of fonts is used from the system, 2018-07-28), non-antialiased text got supported in bitmap export using cairo. This change makes that support available on Windiws, including Skia. Change-Id: I1fae726539347f826e2d62246d35315e7954cf83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171967 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins (cherry picked from commit 52a2dd0eea2ecf62b1db5f379cf65aed705446cb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175060 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index 78135e3a5eba..2f6ea964d803 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -941,6 +941,47 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf155048) } } +CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testNoAntiAliasExport) +{ +#ifdef MACOSX +// See comment in testTdf155048 +#else + loadFromFile(u"svg/tdf162259.svg"); + + auto xGraphicExporter = drawing::GraphicExportFilter::create(getComponentContext()); + CPPUNIT_ASSERT(xGraphicExporter); + + auto xSupplier = mxComponent.queryThrow<css::drawing::XDrawPagesSupplier>(); + auto xPage = xSupplier->getDrawPages()->getByIndex(0).queryThrow<css::lang::XComponent>(); + xGraphicExporter->setSourceDocument(xPage); + + // 101 x 151 is current width x height ratio of the loaded SVG. FIXME: it should be 100 x 150. + css::uno::Sequence<css::beans::PropertyValue> aFilterData{ + comphelper::makePropertyValue(u"PixelWidth"_ustr, sal_Int32(101)), + comphelper::makePropertyValue(u"PixelHeight"_ustr, sal_Int32(151)), + comphelper::makePropertyValue(u"AntiAliasing"_ustr, false), + }; + + css::uno::Sequence<css::beans::PropertyValue> aDescriptor{ + comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL()), + comphelper::makePropertyValue(u"FilterName"_ustr, u"PNG"_ustr), + comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData) + }; + + xGraphicExporter->filter(aDescriptor); + BitmapEx bmp = vcl::PngImageReader(*maTempFile.GetStream(StreamMode::READ)).read(); + + std::set<Color> colors; + + for (tools::Long x = 0; x < bmp.GetSizePixel().Width(); ++x) + for (tools::Long y = 0; y < bmp.GetSizePixel().Height(); ++y) + colors.insert(bmp.GetPixelColor(x, y)); + + // With AntiAliasing = false, the text must be rendered aliased + CPPUNIT_ASSERT_EQUAL(size_t(2), colors.size()); +#endif +} + CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf162259) { // The top X in the SVG, having no skew, used a fast rendering path, and was output much wider diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 19edee0f4440..f8107a4a2a00 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -372,7 +372,7 @@ public: void ImplUpdateSysColorEntries(); int ImplIsSysColorEntry( Color nColor ); void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern&, - const vcl::font::PhysicalFontFace*, LOGFONTW& ); + const vcl::font::PhysicalFontFace*, LOGFONTW&, bool bAntiAliased); #define MAX_64KSALPOINTS ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS)) diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index fb9e004b708d..63effb158ee8 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -675,7 +675,7 @@ static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, const TEXTMETRICW* void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, const vcl::font::PhysicalFontFace* pFontFace, - LOGFONTW& rLogFont ) + LOGFONTW& rLogFont, bool bAntiAliased) { OUString aName; if (pFontFace) @@ -711,7 +711,6 @@ void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, rLogFont.lfEscapement = rFont.mnOrientation.get(); rLogFont.lfOrientation = rLogFont.lfEscapement; rLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; - rLogFont.lfQuality = DEFAULT_QUALITY; rLogFont.lfOutPrecision = OUT_TT_PRECIS; if ( rFont.mnOrientation ) rLogFont.lfClipPrecision |= CLIP_LH_ANGLES; @@ -719,7 +718,10 @@ void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, // disable antialiasing if requested if ( rFont.mbNonAntialiased ) rLogFont.lfQuality = NONANTIALIASED_QUALITY; - + else if (bAntiAliased || Application::GetSettings().GetStyleSettings().GetUseFontAAFromSystem()) + rLogFont.lfQuality = DEFAULT_QUALITY; + else + rLogFont.lfQuality = NONANTIALIASED_QUALITY; } std::tuple<HFONT,bool,sal_Int32> WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, @@ -729,7 +731,7 @@ std::tuple<HFONT,bool,sal_Int32> WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::fon HFONT hNewFont = nullptr; LOGFONTW aLogFont; - ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont ); + ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont, getAntiAlias()); bool bIsCJKVerticalFont = false; // select vertical mode for printing if requested and available diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 1661d3408fa8..783ca27192c6 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -2258,7 +2258,7 @@ static void ImplSalFrameSetInputContext( HWND hWnd, const SalInputContext* pCont { LOGFONTW aLogFont; ImplGetLogFontFromFontSelect(pContext->mpFont->GetFontSelectPattern(), - nullptr, aLogFont); + nullptr, aLogFont, true); ImmSetCompositionFontW( hIMC, &aLogFont ); ImmReleaseContext( pFrame->mhWnd, hIMC ); }
