4 Comments

Fonts and DPI

Making nice looking fonts on your screen takes a little bit on know how. A great help to improve the fonts is to learn the correct DPI for your screen. When a person in the forums mentioned that my fonts looked fuzzy, I never considered the the DPI was set incorrectly for my monitor. The problem was that I had been using the original DPI the X server choose when installed and the X server doesn’t always know how to the correct value. If the X server cannot determine the size of the screen it will set a default value and your fonts will appear hazy.

First place to look to find the DPI for the monitor, is in the user guide that came with your computer or the manufactures website may also have this information. However, if it isn’t it isn’t very difficult to figure out.

First see if X recognizes the monitor’s physical size:

xdpyinfo | grep dimensions

If X server knows this value, then it can calculate the correct DPI. If the dimensions are correct then the correct DPI will be calculated:

xdpyinfo | grep resolution
grep DPI /var/log/Xorg.0.log

The X server will default to 75×75 if it cannot discover a value. If the DPIs are wrong, you’ll have to tell X server the correct dimension of your monitor. Since most specifications now just list the diagonal length of the screen, I’m going to use that. The MacBook I use has a 13.3″ (diagonal) LCD screen with 1280 x 800 resolution. With the Pythagorean theorem you can discover your horizontal and vertical measurements.

Using bc (a command line calculator) this will give us the diagonal resolution:

echo 'scale=5;sqrt(1280^2+800^2)' | bc

Using the diagonal length divided by the diagonal resolution will give the aspect percentage and multiplying as aspect percentage times the horizontal and vertical resolutions will give the monitor’s horizontal and vertical lengths.

echo 'scale=5;(13.3/1509)*1280' | bc
11.27680
echo 'scale=5;(13.3/1509)*800' | bc
7.04800

With this I know my monitors physical dimensions are 11.27680 wide by 7.04800 high. Now X server needs to be told of these values. X server doesn’t use inches though and the values has to be calculated for metric. I like to do this with Google, just type in “11.2768 inches in millimeters”.

Now tell X server in whole values in the “/etc/X11/xorg.conf” file in the Monitor section:

    Section "Monitor"
    Identifier "Monitor0"
    DisplaySize 286 179

Kill the X server and restart and the new values for DPI will take effect.

Gnome and KDE have their own DPI settings that might override the correct DPI. Gnome only has the ability to set one value for DPI, if horizontal and vertical DPI differ, choose a medium in between. In KDE 4, users have the ability to disabled KDE’s DPI setting and use the X servers.

Fonts and Web Browsers

Firefox in particular, has a built-in way of how it renders fonts, so fonts in Firefox may not look as good as your other applications. To set up sizes of fonts in your web browser a good way is to set the fonts to corresponding css values. Adjust what regular size reading font you want in your web browser with the corresponding to font size medium in css samples, and set xx-small to the smallest readable size.

Thanks

Thanks to Padaa for showing me that my fonts weren’t up snuff, though I berated him for getting off topic ;) .

About these ads

About Gen2ly

<3's linux

4 comments on “Fonts and DPI

  1. Unless I’ve missed something ‘newspr’ isn’t a USE flag for libXft or cairo. Even ‘euse -i newpr’ returns nothing.

    Via grep
    Checked cairo:
    1.2.6
    1.4.4
    1.4.6
    1.4.8
    1.4.10

    Checked libXft:
    2.1.10
    2.1.12

    When I ‘xdpyinfo|grep resloution’ I get “resolution: 129×126 dots per inch” as an answer. Which number should I use?

  2. I haven’t located a description yet either jfb3 but I can clearly see them:

    emerge -pv cairo libXft

    These are the packages that would be merged, in order:

    Calculating dependencies… done!
    [ebuild R ] x11-libs/cairo-1.4.10 USE=”X glitz opengl newspr svg -debug -directfb -doc -xcb” 0 kB
    [ebuild R ] x11-libs/libXft-2.1.12 USE=”newspr -debug” 0 kB

    Alot of changes I’ve noticed in portage lately, maybe it’s your best bet to try “emerge –sync” again. Also I noticed a could people have it in their overlays.

    As for the DPI, there isn’t much that I know of that you can do. Since the font manager figures DPI in a square number… perhaps a different resolution?

  3. I *did* a sync immediately prior to checking for newspr in cairo and libXft.

    My guess is that you’re using overlays of cairo and libXft not the standard ebuilds

    My screen resolution on my laptop is 1680×1050 and no, a different resolution isn’t a proper option that’s the native resolution of the lcd.

  4. Very very interesting. Yes I do use an overlay, but I deleted the overlay and pretend emerged, from Gentoo portage, cairo and libXft and saw the “newspr” flag. There must be a central repository for USE, hmm. Yeah ok, use the “xeffects” overlay it has them in there, it’s part of layman so it’s simple to add.

    “When I ‘xdpyinfo|grep resloution’ I get “resolution: 129×126 dots per inch” as an answer. Which number should I use?”

    It doesn’t hurt to enter DPI value into font preferences, they are so close to each other that it probably doesn’t matter.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 51 other followers

%d bloggers like this: