QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10355|回复: 23

X的默认dpi是哪里设置的?

[复制链接]
发表于 2006-7-6 22:31:39 | 显示全部楼层 |阅读模式
是否是在编译X的时候?
xinit启动后,dpi不受/etc/X11/xinit/xserverrc的限制。如果不改家目录下的.xserverrc,也不给X用-- -dpi的参数,是否只能自行重编X
发表于 2006-7-8 09:15:10 | 显示全部楼层
按理说,命令行参数->~/.xserverrc->全局xserverrc->全没有的话根据xorg.conf中displaysize->还没有的话xserver自己猜测->猜不出fallback到75dpi。
回复

使用道具 举报

发表于 2006-7-8 13:00:28 | 显示全部楼层
[code:1]yangtse@yangtse:~$ cat ~/.Xresources
Xft.dpi: 96
[/code:1]

你说的是这个吗?
回复

使用道具 举报

发表于 2006-7-8 20:04:01 | 显示全部楼层
[quote:9b55a28db9="种草得草"]你说的是这个吗?[/quote]
不是。对于不支持Xft的程序这是无效的。
回复

使用道具 举报

 楼主| 发表于 2006-7-8 21:23:20 | 显示全部楼层
[quote:8c3af7e18a="fakeroot"]按理说,命令行参数->~/.xserverrc->全局xserverrc->全没有的话根据xorg.conf中displaysize->还没有的话xserver自己猜测->猜不出fallback到75dpi。[/quote]
75哪来的?编译时候给的?还是源码里写定的?
回复

使用道具 举报

发表于 2006-7-8 22:45:58 | 显示全部楼层
我是写到 /etc/X11/xorg.conf

Section "Monitor"
.....

      # DisplaySize     270     203     # 1024x768 96dpi
      # DisplaySize     338     254     # 1280x960 96dpi
      # DisplaySize     338     270     # 1280x1024 96dpi
      # DisplaySize     370     277     # 1400x1050 96dpi
      # DisplaySize     423     370     # 1600x1400 96dpi
......

EndSection

计算公式:
displaysize = <screen_resolution>/96*25.4
查看:
$ xdpyinfo | grep dimensions
$ xdpyinfo | grep resolution

不过好像有点问题,正确应该是显示器的 dotpitch 或 pixelpitch
乘以 pixel_size
具体看下面的帖子:
http://wiki.x.org/wiki/FAQVideoModes

也可能说的不对。
回复

使用道具 举报

发表于 2006-7-9 01:06:31 | 显示全部楼层
几个术语容易搞混,以我的理解解释一下:
dpi: dots per inch 点每英寸
即每英寸所包含的点数。
dpi 是一个术语,通常用来描述打印机的解析度(resolution),即在页面上一英寸的直线范围内打印机所能放置的彩色墨点个数,反映的是一个设备的物理能力。

ppi: pixels per inch 像素每英寸
即每英寸所包含的像素。
ppi 也是一个术语,通常用来指示某个图像文件(JPEG, TIFF,etc) 的解析度(resolution),ppi 越高,单位度量所包含的图像细节就越多。

严格来讲,dpi 和 ppi 是两个不同领域的术语,不能混淆。从技术角度说,“像素”(P)只存在于计算机显示领域,而“点”(d)只出现于打印或印刷领域。
更详尽的解释见:
http://www.steves-digicams.com/techcorner/January_2005.html

但从 freetype  的字形规约(Glyph Conventions)
http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-2.html#section-1
中,个人感觉概念有点混淆。
比如:
[code:1]"For example, a printer with a resolution of 300x600 dpi has 300 pixels per inch in the horizontal direction, and 600 in the vertical one......".[/code:1]
这里的 pixel 应该指的是 dot, 而不该翻译成像素。

[code:1]“The resolution of a typical computer monitor varies with its size (15" and 17" monitors don't have the same pixel sizes at 640x480), and of course the graphics mode resolution.”[/code:1]
这里的 pixel 才是像素,说的是 15寸和 17寸显示器即使在同一个屏幕分辨率(640x480)下像素的大小不同。这里 pixel size 指的是单个 pixel 所占据的物理范围(the physical dimensions of a given pixel)。想象一下 640x480 约 30万个像素分割不同大小屏幕,单位像素所获得的空间自然不同。

规约中还提到一个重要概念 point:
[code:1]"As a consequence, the size of text is usually given in points, rather than device-specific pixels. Points are a simple physical unit, where 1 point = 1/72th of an inch, in digital typography."[/code:1]
因为 pixel 大小都是设备相关的,所以引入一个与设备无关的物理单位 point, 而且牢记 1 point = 1/72 inch。
由于上诉原因,文字的大小一般以 point 为单位给出。
比如:
[code:1]$ fcmatch -v
......
        dpi: 75(f)(s)
        antialias: FcTrue(w)
        pixelsize: 12.5(f)(s)
        size: 12(f)(s)
......[/code:1]
该处 size 应该指的是 size of text in point,
而 pixelsize 指的是 size of text in pixel。

再看一下导出某个文字在不同单位 pixel 或 point 下大小的换算公式:
[code:1]It is thus possible to compute the size of text in pixels from the size in points with the following formula:
pixel_size = point_size * resolution / 72

The resolution is expressed in dpi. Since horizontal and vertical resolutions may differ, a single point size usually defines a different text width and height in pixels.[/code:1]

(这里要注意区分 resolution 的含义,这里是 dpi, 千万别把他和屏幕分辨率(screen resolution)搞混了,完全两个概念,虽然有时候英文相同,可以这样来区分,dpi 单位是 1 inch,而screen resolution 考虑是一个屏幕的宽度或高度。)
公式可以这样来理解:
[code:1]pixel_size / resolution = point_size * 1/72[/code:1]

左边 pixel_size(size of text in pixels) 表示以 pixel 为单位字体的大小,或理解为表示一个文字宽或高需要 pixel 的数量,而 resolution(即dpi) 表示每英寸所包含的 pixel 数目,因此 pixel_size / resolution 单位为英寸。

右边 point_size(size of text in points), 表示以 point 为单位字体的大小,或理解为表示一个文字宽或高需要 point 的数量,而每一个 point = 1/72 英寸,故 point_size * 1/72 同样单位为英寸。

在上一帖中我提到下面概念:
# DisplaySize 270 203 # 1024x768 96dpi
displaysize = <screen_resolution>/96*25.4

解释一下,比如 1024x768 @ 96dpi,即水平 screen_resolution = 1024, 此时 resolution(即dpi)=96, 因此  
<screen_resolution>/96 单位为 inch,而显示尺寸 DisplaySize 单位为 mm, 由 1 inch = 25.4 mm, 故得乘以 25.4。

http://wiki.x.org/wiki/FAQVideoModes
[code:1]"DisplaySize, if included really should be the actual size of your display in mm. This is best assessed by determining the LCD's native resolution and dotpitch and multiplying the two. For a Dell 2001FP, the native resolution is 1600x1200 and the dotpitch is .255 mm, thus the display size should be 408 306. The display size listed above will not correctly display paper sizes in word processing or other programs (e.g., openoffice, gv)."[/code:1]

我的不解之处是,液晶屏有固定的物理分辨率(native resolution)(CRT可能无此限制),在这个分辨率下,显示的画面最锐利。因此实际显示尺寸应该是屏幕物理分辨率乘以点距(dotpitch 或 pixelpitch),这样才能准确的显示图像。比方说屏幕物理分辨率为 1600x1200, 点距为 0.255mm, DisplaySize 水平为 1600x0.25, 垂直为 1200x0.255。

因为英文和中文理解上的差异,所以如果我理解有误,请多包涵。
回复

使用道具 举报

 楼主| 发表于 2006-7-9 13:34:11 | 显示全部楼层
多谢楼上,不过我的问题是想知道默认的dpi是哪来的?
回复

使用道具 举报

发表于 2006-7-9 14:07:40 | 显示全部楼层
http://scanline.ca/dpi/
你看看上面的这篇,能否解答你的疑问。
回复

使用道具 举报

 楼主| 发表于 2006-7-9 15:37:55 | 显示全部楼层
是从显示器的DDC阿,多谢了
回复

使用道具 举报

发表于 2006-7-9 20:41:51 | 显示全部楼层
cnhnln是什么意思?中国河南XX?

请教一下,我的kde桌面,以及桌面右键菜单字体不受~/.Xresources的影响。
我想全局设定dpi为96,在哪里设置啊?
回复

使用道具 举报

发表于 2006-7-9 20:46:01 | 显示全部楼层
yangtse@yangtse:~/mydocs/bak$ xdpyinfo | grep dimensions
  dimensions:    1024x768 pixels (333x250 millimeters)
yangtse@yangtse:~/mydocs/bak$ xdpyinfo | grep resolution
  resolution:    78x78 dots per inch
回复

使用道具 举报

发表于 2006-7-9 20:51:36 | 显示全部楼层
我认为不必通过 ddc 来设置,根据自己的显示设备直接写到 xorg.conf 就可以了。

比如我的 ibm 本本 LCD 14.1 寸屏幕的 native resolution 为 1024x769, pixel size 为 0.2798 mm,ratio 为 4:3。
很容易计算:
width  = 1024 x 0.2798 mm = 286.5 mm
height = 768   x 0.2798 mm = 214.9 mm

如果你找不到自己显示设备的相关数据,最简单方法是拿把尺子把屏幕的可视区域的宽和高量一下,同样可以得到以上数据,不妨动手实践一下。

那么
Section "Monitor"
......
DisplaySize 287 215
......
EndSection

重启 X 后,通过
$ xdpyinfo |grep resolution
  resolution:    90x90 dots per inch
可以看到适合我的 dpi 为 90.
同时我在
$ vi ~/.Xresources
Xft.dpi: 90
这样我的 Qt 和 Gtk+ 可以使用这个 dpi。
Debian 会自动读取 ~/.Xresources,其他 Distribution 可能不会自动这样处理。
如果不会自动读取,可以如下处理:
$ vi ~/.xsession
if [ -f $HOME/.Xresources ]; then
   xrdb -merge $HOME/.Xresources
fi

有关 notebook 的参数,可以查看下面连接:
http://www.prismo.ch/comparisons/notebook.php
你可以直接找到本本的 width 和 height, 省去计算过程。

当然把 dpi 设成 96, 应该也是不错的选择。
回复

使用道具 举报

发表于 2006-7-9 21:51:28 | 显示全部楼层
我也这样改,好了。
谢谢。
DisplaySize 287 215
回复

使用道具 举报

 楼主| 发表于 2006-7-9 22:09:58 | 显示全部楼层
呵呵,想通过ddc改也困难啊。改dpi我一直都是通过xserverrc和fonts.conf,觉得简单有效 只是想知道X默认的dpi是如何确定的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-20 20:24 , Processed in 0.085537 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表