Text rendering Skia vs Gdiplus

243 views
Skip to first unread message

Cedric

unread,
Jul 25, 2024, 7:16:21 AM7/25/24
to skia-discuss
I'm updating some existing code base which is using Gdiplus for rendering and replacing it for Skia instead. I saw that there's quite some difference on how the ani-aliasing is done between Skia and Gdiplus. This results in the text being displayed which looks less good when using Skia compared to Gdiplus.

Skia-Text.bmpGdiplus-Text.bmp
(Left is Skia, right is Gdiplus). It's particularly clear when you zoom on the text:Skia-Zoomed.bmpGdiplus-Zoomed.bmp
(first one is Skia, second one is Gdiplus).

I used the font manager based on DirectWrite (SkFontMgr_New_DirectWrite) and draw the text through the SkCanvas::drawSimpleText method (with anti-aliasing turned on).

I'm currently also not using any of the Skia extensions, so this is the content of my args.gn file:
clang_win = "C:\Program Files\LLVM" is_debug=false is_official_build=true is_component_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_system_icu=false skia_use_system_harfbuzz=false



Is there a way to improve the rendering of the text?







bungeman

unread,
Jul 25, 2024, 10:25:47 AM7/25/24
to skia-discuss
If you're looking for subpixel anti-aliasing, you will need to use `SkFont.setEdging(SkFont::Edging::kSubpixelAntiAlias)` and set the actual pixel geometry on your destination surface with something like `SkSurfaceProps(0, kRGB_H_SkPixelGeometry)` when the surface is created. Also, you will probably want to set `SkFont.setSubpixel(true)` and possibly change other font settings when drawing.

John Wiseman

unread,
Jul 25, 2024, 12:59:25 PM7/25/24
to skia-discuss

It may be more complicated than you thought to match windows' native font rendering:


 
Reply all
Reply to author
Forward
0 new messages