DPI resolution

From campisano.org
Jump to navigation Jump to search

DPI resolution

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

    <dir prefix="xdg">/usr/share/fonts</dir>



    <!-- from https://www.freedesktop.org/software/fontconfig/fontconfig-user.html -->
    <!--
        use rgb sub-pixel ordering to improve glyph appearance on
        LCD screens.  Changes affecting rendering, but not matching
        should always use target="font".
    -->
    <match target="font">
        <edit name="rgba" mode="assign">
            <const>rgb</const>
        </edit>
    </match>



    <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="autohint" mode="assign">
            <bool>false</bool>
        </edit>
    </match>


    <!-- from https://www.freedesktop.org/software/fontconfig/fontconfig-user.html -->
    <!--
        Accept deprecated 'mono' alias, replacing it with 'monospace'
    -->
    <match target="pattern">
        <test qual="any" name="family"><string>mono</string></test>
        <edit name="family" mode="assign"><string>monospace</string></edit>
    </match>



    <!-- from http://xpt.sourceforge.net/techdocs/nix/x/fonts/xf21-XOrgFontConfiguration/single/ -->
    <!--
        Most applications use the font names sans-serif (or the equivalent sans), serif, or monospace
        Users can easily add rules to ~/.fonts.conf to resolve these aliases to their favorite fonts:
    -->
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>DejaVuSans</family>
        </prefer>
    </alias>
    <alias>
        <family>sans</family>
        <prefer>
            <family>DejaVuSans</family>
        </prefer>
    </alias>
    <alias>
        <family>serif</family>
        <prefer>
            <family>DejaVuSerif</family>
        </prefer>
    </alias>
    <alias>
        <family>monospace</family>
        <prefer>
            <family>DejaVuSansMono</family>
        </prefer>
    </alias>
    <alias>
        <family>mono</family>
        <prefer>
            <family>DejaVuSansMono</family>
        </prefer>
    </alias>



    <!-- from https://www.freedesktop.org/software/fontconfig/fontconfig-user.html -->
    <!--
        Alias well known font names to available TrueType fonts.
        These substitute TrueType faces for similar Type1
        faces to improve screen appearance.
    -->
    <alias>
        <family>Times</family>
        <prefer><family>Times New Roman</family></prefer>
        <default><family>serif</family></default>
    </alias>
    <alias>
        <family>Helvetica</family>
        <prefer><family>Arial</family></prefer>
        <default><family>sans</family></default>
    </alias>
    <alias>
        <family>Courier</family>
        <prefer><family>Courier New</family></prefer>
        <default><family>monospace</family></default>
    </alias>

</fontconfig>

  • setup .Xresources
! Xft
!!! define X11 global font settings
    Xft.dpi: 120

!!! from https://wiki.archlinux.org/index.php/HiDPI#X_Resources
!!! and https://wiki.archlinux.org/index.php/Font_configuration#Applications_without_fontconfig_support
    Xft.lcdfilter: lcddefault
    Xft.antialias: true
    Xft.hinting:   true
    Xft.autohint:  false
    Xft.hintstyle: hintfull
    Xft.rgba:      rgb
! /Xft

! XTerm
!!! Adjust line spacing
    XTerm.scaleHeight: 1.10

!!! Select the font for xterm
!!! use 'fc-list | cut -f2 -d: | sort -u | grep -i mono' to see what is available
    XTerm.vt100.renderFont: true
    XTerm.vt100.faceName:   DejaVu Sans Mono:style=Book:antialias=true
    XTerm.vt100.faceSize:   10
    XTerm.vt100.faceSize1:  2
    XTerm.vt100.faceSize2:  4
    XTerm.vt100.faceSize3:  6
    XTerm.vt100.faceSize4:  8
    XTerm.vt100.faceSize5:  10
    XTerm.vt100.faceSize6:  12
! /XTerm
  • setup .xsession
# configure X DPI resolution
# from https://wiki.archlinux.org/index.php/HiDPI#GTK+_vs_Gnome_Shell_elements_on_Xorg
#  and https://developer.gnome.org/gtk3/stable/gtk-x11.html
#export GDK_SCALE=2       # scale UI elements
#export GDK_DPI_SCALE=0.5 # to un-scale some fonts that would be scaled twice in gtk apps
#export QT_FONT_DPI=120   # to avoid double-scaling of fonts in qt apps



# from http://xpt.sourceforge.net/techdocs/nix/x/fonts/xf21-XOrgFontConfiguration/single/
# GTK+2.0 needs to have a variable set in order to use xft. Gtk+2.2 uses Xft by default.
export GDK_USE_XFT=1

References