Fonts in emacs look different than in gedit or gnome-terminal
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
emacs23 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
The same scalable font looks different in emacs than in gedit or gnome-terminal.
Attached are screenshots of 1) gedit with the Monospace 8 font and 2) emacs with the same font. Although each glyph rendering is nearly identical (you can zoom in with gimp), the emacs character spacing is wider (more space between glyphs).
When gedit renders text, the font size is scaled to the font library's dpi (the scaling is done by the pango library). Xft is typically set to 96 dpi resulting in a 1.3333 scale factor; so a font size of 8 becomes 10.666667.
Although a similiar scaling approach is employed by emacs, because the emacs font driver interface (which emacs uses to abstract the platform for rendering text) defines an *integer* pixelsize parameter, the same font size of 8 becomes 11 (emacs rounds the font size up). This accounts for the slightly exaggerated glyph spacing.
Attached is a workaround patch that does the dpi scaling in the emacs Xft font driver. This works by scaling the pixelsize by the frame's y-axis dpi. Thus it's necessary to explicitly set the font's pixelsize in either the .Xresources file or via the command line option --fn (see http:// www.gnu. org/software/ emacs/manual/ html_node/ emacs/Fonts. html for font setting methods and parameters).
AFAIK, the pixelsize cannot be set using the .emacs font setting method.
NB: Because of the different emacs binary names in ubuntu, if using the .Xresources font setting method, the resource should be wildcarded. Eg., pixelsize= 8
emacs*font: Monospace: