2

I use cutycapt to make screenshots of web pages. When I switched from Kubuntu 16.04 to Kubuntu 20.04 I noticed that font rendering quality degraded significantly. I made several screenshots of the same page and enlarged the same fragment on both screenshots for comparison. Command which was used:

cutycapt --out=screenshot.png --url=http://www.debianadmin.com/how-to-disable-ipv6-in-debian.html

Here's the one made in Kubuntu 16.04 (cutycapt version 0.0~svn6-3.1, depends on libqtwebkit4 version 2.3.2-0ubuntu11):

Kubuntu 16.04

My system is set to full hinting. Letter stems on this screenshot are sharp and their hinting is obviously set to "full".
Now the screenshot made in Kubuntu 20.04 (cutycapt version 0.0~svn10-0.1build1, depends on libqt5webkit5 version 5.212.0~alpha4-1ubuntu2):

Kubuntu 20.04

All letters are surrounded by gray fringe. Take a look at the word "comment" — all stems in letter "m" have different thickness. It looks like "slight" hinting to me or even no hinting at all.
I'm quite confident that both systems are properly configured to use full hinting (in System Settings > Fonts and in /etc/fonts/conf.d/) and all other fonts obey these settings.

I tried adding .config/fontconfig/fonts.conf with contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="font">
        <edit name="antialias" mode="assign"><bool>true</bool></edit>
        <edit name="hinting" mode="assign"><bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
        <edit name="rgba" mode="assign"><const>rgb</const></edit>
        <edit name="autohint" mode="assign"><bool>false</bool></edit>
        <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
    </match>
</fontconfig>

But these settings were ignored.
As far as I know cutycapt uses QtWebKit library. I don't know whether these rendering settings are controlled by Qt or WebKit engine directly. I also tried PhantomJS and wkhtmltoimage to capture screenshots in 20.04 but they produce the same blurred text. Any advices regarding tuning hinting or alternative software are welcome.

P.S. If someone knows how I can also enable subpixel antialiasing on these screenshots it would be nice.

4
  • 1
    Could you provide the version of cutycapt.you are using and exactly the steps to reproduce the issue? There is any metric you are using to compare? Maybe the resolution using Imagemagick's identify? Nov 4, 2021 at 2:06
  • @PabloBianchi Updated my post. URL can be any (I used http protocol for my example because older cutycapt have troubles opening https). identify shows a bit different vertical resolution for the screenshots due to more sparse rendering of text lines in the 2nd example. You can save my examples and compare them switching images by Alt+Tab -- the difference is pretty obvious.
    – whtyger
    Nov 4, 2021 at 8:08
  • You may try raising size using --min-width ... --min-height ... (as resolution is not in the options) , like in this post unix.stackexchange.com/questions/231482/… . Another option is to use SVG as initial output then convert it with resolution you require.
    – user.dz
    Nov 4, 2021 at 8:10
  • 1
    @user.dz Size is not the case, I'm aiming at text clarity. SVG output improves this clarity indeed but it is lost when this SVG is converted into PNG (I used convert command from ImageMagick). Moreover, convert fails on large images with an error too many bezier coordinates.
    – whtyger
    Nov 4, 2021 at 19:39

1 Answer 1

0

Vector format

While I recommended any vector format (svg, ps, pdf,..) if bitmap is not a must. I expect svg and pdf to have good rendering tool support.

Fix resolution

Anyway I give it another try. Found one that works very good using a combination of --min-width and --zoom-factor.

cutycapt --min-width=3200 --zoom-factor=4 --out=screenshot.png --url=http://www.debianadmin.com/how-to-disable-ipv6-in-debian.html

I used min-width (default width 800px x zoom-factor 4 in my case).

Advanced font settings using fontconfig

Also I was able to control font properties using this fontconfig rule as example. If required like to enabling full hinting.

~/.config/fontconfig/conf.d/00-custom.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

  <match>
    <test name="prgname"><string>cutycapt</string></test>

    <edit name="dpi" mode="assign"><double>96</double></edit>
    <edit name="antialias" mode="assign"><bool>false</bool></edit>
    <edit name="hinting" mode="assign"><bool>true</bool></edit>
    <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
    <edit name="rgba" mode="assign"><const>none</const></edit>
    <edit name="autohint" mode="assign"><bool>false</bool></edit>
    <edit name="lcdfilter" mode="assign"><const>lcdnone</const></edit>
  </match>

</fontconfig>

and may debug it using:

FC_DEBUG=1 cutycapt --min-width=3200 --zoom-factor=4 --out=screenshot-mod.png --url=http://www.debianadmin.com/how-to-disable-ipv6-in-debian.html > cutycapt.fontconfig.log

check result log cutycapt.fontconfig.log

Example of cutycapt result with above fontconfig, this settings are just for testing because it is easy to notice effects.

example image of cutycapt result with above fontconfig

3
  • 1
    I made two screenshots -- one without your 00-custom.conf and one with it. Debug logs show that fontconfig parameters have changed, indeed. BUT two screenshots which are placed one above the other look absolutely the same. It seems that cutycapt somehow ignores these settings added by "prgname" rule. The screenshot which you provided looks great, but it is rendered with four-time increase in size. As soon as it will be converted back to its normal size, the letters will become jagged again.
    – whtyger
    Apr 30 at 16:13
  • @whtyger What i presented is extreme example just for testing. PNG format does have density property and It is expected to handle that externally, for by scaling coefficient for example 72ppi to 96ppi ratio is 1.33, you don't have to go up to 4. Also lcd filter is useless as it is not directly displayed on screen (by going to bitmaps/PNG then to screen/LCD). You have to know end users display density then generate bitmaps depending on that.
    – user.dz
    Apr 30 at 20:16
  • I tried changing dpi parameter in this config file to <edit name="dpi" mode="assign"><double>300</double></edit> hoping that if I later downscale the image to its real resolution, this would improve its quality. Alas, despite debug log showed dpi change, the resulting image still has got 96 ppi resolution according to GIMP. So it seems that altering fontconfig settings won't help in font rendering in cutycapt.
    – whtyger
    May 3 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.