星期二, 12月 16, 2008

Bitmap Font File Format

點陣檔(bitmap file)是一種二元檔,用來存字元的點陣(bitmap)。
同時也會有一個相對應的索引檔,HBF file。
以下所描述的格式相當通用;特別是很多提供點陣字型的廠商可以直接使用,
而不需修改。

點陣字的結構
"寬x高" 大小的點陣字以列(row)為單位從上到下儲存,每列使用一整個位元數。
每一列佔 (寬 + 7)/8 位元組,以無條件捨去計算。
每列從左到右儲存,最左的圖點在第一個位元組的最高有效位(MSB)。
因此,每個點陣字會佔去 (高 * ((寬 + 7)/8) 位元組。例如:

16x16 點陣字佔去 16 * ((16 + 7)/8) = 32 bytes
15x16 點陣字佔去 16 * ((15 + 7)/8) = 32 bytes
16x15 點陣字佔去 15 * ((16 + 7)/8) = 30 bytes
64x64 點陣字佔去 64 * ((64 + 7)/8) = 512 bytes

位元值 1 表示字元的部份,位元值 0 表示背景。

點陣檔中點陣圖的排列
在HBF檔中的每個 HBF_CODE_RANGE 項目定出了點陣字在點陣檔中字元範圍的偏移量。
字元的點陣圖從第一碼到最後一碼連續地存在檔案中,但點陣圖在外部碼的定義被省略了。

例如,假設我們有 24x24 Big5 字型,每個點陣圖佔用 72 位元組。在 Big5,第二位元的範圍為

HBF_BYTE_2_RANGE 0x40-0x7E
HBF_BYTE_2_RANGE 0xA1-0xFE



HBF_CODE_RANGE 0xA440-0xC67E stdfont.24k 0

表示點陣圖的偏移量在檔案中為

0 bitmap for character A440
72 bitmap for character A441
... ...
4464 bitmap for character A47E
4536 bitmap for character A4A1
... ...
11232 bitmap for character A4FE
11304 bitmap for character A540
... ...
395568 bitmap for character C67E

Chinese character code

相對於台灣用大五碼,大陸用國家標準代碼,簡稱國標碼(GuoBiao)來做為漢字編碼集。

GB2312-80 是大陸官方在1981年5月1日實施。幾乎大陸所有中文系統及國際化軟體都支援GB2312。

微軟的 CP936 與 GB2312 幾乎是一樣的編碼。
微軟後來對 CP936 做擴展,後來稱為 GBK。K是由擴展的漢語拼音 Kuo而來。

GB18030-2000 是大陸官方在2000年推出的標準。後來在 2005年推出其修訂版,稱GB18030-2005。

GB18030 完全相容 GB2312;基本相容 GBK。

cclib.16 是一個 GB2312 的點陣字型檔,其字型大小為 16x16 點。

GB2312 0xA1A1-0xA7FE 對應到 cclib.16 是從檔案的 0 開始。
GB2312 0xB0A1-0xF7FE 對應到 cclib.16 是從檔案的 0x5240 開始。

GB2312 的編碼表可以參考下面的網址
http://www.geocities.com/SiliconValley/Bit/3862/simplify/sim1/gbcode.html

例如,"啊" 的 GB碼是 0xB0A1,你可以從 cclib.16 的 0x5240 開始,連續讀 32 bytes。
每兩個位元組表示一列,共16列。將之展開為二進制後,你就可以看到"啊"這個字了。

星期二, 12月 09, 2008

backup a DVD in Debian

aptitude install dvdbackup
dvdbackup -i /media/cdrom -o ~/movie -M

其他dvd 相關工具
vobcopy
lsdvd

Could not open/initialize audio device -> no sound

while play a DVD with Mplayer,
video can play, but no audio.
And Mplayer shows "Could not open/initialize audio device -> no sound"

check this with
$ lspci | grep -i audio
$ lsmod | grep snd

Any exact error messages from ...
# alsaconf

星期六, 12月 06, 2008

ati2dvag problem

遇到 Windows XP 藍白畫面上面只看得懂 ati2dvag ,目前一般解決方法有兩個:

  • 重新安裝 ATI driver。啟動 Windows 於安全模式 (在 Windows 顯示前按下 F8),到 Windows 新增移除程式中移除 ATI 相關的所有東西。移除 DAO/MDAC 元件。你可以到 ATI 的網站下載 ATI 的移除工具來做這件事。完整的移除程序在 ATI 的網站的這裡
  • 到控制台 > 系統 > 硬體 > 裝置管理員 > 系統裝置 > PCI standard PCI-to-PCI bridge,按右鍵,選,更新驅動程式 > 從清單或特殊位置安裝 > 不要搜尋,我將選擇要安裝的驅動程式 > PCI standard PCI-to-PCI bridge。

參考來源:
http://www.modernstreet.com/general/ati2dvag-problem/

Ati2dvag problem

If you ever experienced your computer freezing/crashing without warning all of a sudden, with a blue screen on your monitor saying your computer was “caught in an infinite loop”, plus there is a mention of the word - “ati2dvag”, it means your computer has caught the ati2dvag bug. This bug seems to affect ATI video cards.

I was having this problem on and off since last year, but it got really bad a few days ago. If you have not yet experienced this problem, then keep your fingers crossed and consider yourself fortunate, because this is a REALLY annoying problem that does not have a sure solution or cure, and can give you enough fits to trash your old faithful PC.

The usual symptoms of the ati2dvag problem are:

  • PC crashes without warning, sometimes the display shows weird patterns before the crash.
  • Resolution may revert to the lowest resolution settings upon restarting your PC.
  • The CPU temperature may shoot up prior to crashing.
  • PC may not be able to reboot back after the crash, unless you turn off the power supply unit of your PC and switch it back on again.
  • Your PC tells you (sometimes only) that the ati2dvag driver has failed to function.

This is a universal problem afflicting thousands of PCs worldwide and can occur in totally new or old computers; it doesn’t discriminate. Imagine the frustration of buying a new PC only to have it crash on you after a few weeks and thereafter.

There have been many hypothesis’ postulated. Some say it is a very stealthy virus, some say it is an incompatibility with Windows XP SP2 and ATI, some say it is a problem with the hardware acceleration settings in the ATI graphic card, others say it is a problem within Windows XP itself…etc.

The 2 most common “solutions” are:

  • Reinstall the ATI driver. You are advised to launch Windows in Safe Mode (press F8 before Windows boots), go to Windows Add/Remove programs and uninstall everything ATI. Remove the DAO/MDAC component as well. You can use the ATI removal tool utility which can be downloaded from the ATI website. The complete set of instructions on removing ATI can be found here on the ATI website.
  • Go to System Devices in My Computer > Properties > Hardware, and locate the option, PCI standard PCI-to-PCI bridge. This could under other names on your PC, so contact your PC vendor if you’re unsure. Right click, and select the “update driver” option. Manually search and install the PCI standard PCI-to-PCI bridge.

ATI and Microsoft have never issued public statements regarding this ati2dvag issue up till this day. There is no definitive prevention or cure of this problem also. What works for some may not work for others….I’ve reinstalled the drivers and now it only crashes while I’m playing some graphics intensive game.

If you think this is a trivial problem, look at a forum thread on this problem which has been running for 3 years with no “real” fix to date. It’s about time ATI and Microsoft consider this problem serious enough to warrant a concerted investigation into why this problem happens, and come out with the best possible fix.