[問題] 看不懂十六進制的charset內容

作者: hn12404988 (Willy)   2016-07-01 17:24:54
後來看懂了,說明放在最下面。
_____________________________________________________
想寫一個小program,可以檢測某個ttf或otf檔(字型)
有沒有完整支援一段utf8編碼的字串
但我現在在看「fc-query xxx.ttf」出來的內容
在charset的部份,看起來是十六進位,但我沒辦法跟unicode編碼的十六進位
連結起來,以下是fc-query出來的部份片段
﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍
charset:
0000: ffffffff ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: 0c0f000f 00000f00 000cf198 00003f00 00040000 00018003 1fffe000 03000000
0002: 00000000 00000000 00020000 00000002 00000000 00000000 02000e80 00000000
0003: 00000000 00000000 00000000 00000000 fffe0000 fffe03fb 000003fb 00000000
0004: ffff0002 ffffffff 0002ffff 00000000 00000000 00000000 00000000 00000000
然後我找到一篇文章,底下的解答有如何看是否有對應charset
﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍
It shows the supported character ranges, although it doesn't which block it
belongs to (you have to know which range belongs to which block).
For example, the fourth column of 0000, which corresponds to U+0060 - U+007F,
has a hex value of 7fffffff. This has a bit value of
0111 1111 1111 1111 1111 1111 1111 1111
, where the right most bit is U+0060, and the left most is U+007F.
This means that U+007F is not supported in this font.
﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍
但我還是不懂,他如何看出0000那行的第四欄是介於unicode編碼的U+0060 ~U+007F
那其他行跟其他欄是要如何跟unicode編碼對應?
﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍﹍
說明:
utf8最廣泛的是1到3 byte,所以以3 byte來說,範例中的每一row(0000,0001,0002....)
的開頭(冒號左邊)代表3 byte中的前2 byte開頭,冒號右邊的八組column
代表剩下1 byte的16*16個尾數(ex. 0000 row 是從000000到0000ff)
所以每個column負責32個尾數,而如果把每個column decode 到二進位
就有32個二進位值,例如row 0000的第四欄7fffffff的二進位就是
0111-1111-1111-1111-1111-1111-1111-1111,這是從000060 ~ 00007f
代表000060到00007e都有這個字型,但最左邊的0(from 0111)代表00007f沒支援
沒錯,是從右邊數來,到左邊最大值,最右邊是000060,最左是00007f
作者: wgst88w (清楚明「熙」)   2016-07-02 09:23:00
那the right most bit's column of 1111~0110 之間是否也屬於 U+0060 呢?
作者: EdwardGJLee (LGJ)   2016-07-02 10:46:00
安裝 fonttools/TTX dump 出 cmap table 然後去分析或自行寫個 python 小程式去判斷(用 fonttools)。或有安裝 fontforge 的話,寫個 fontforge script。
作者: wgst88w (清楚明「熙」)   2016-07-02 14:43:00
疑=.=?等等,冒號左邊 : 冒號右邊...你冒號是不是沒標!痾~~看懂了ex. FFFF(前2byte):32個ff 是這樣吧,唉~~~~
作者: EdwardGJLee (LGJ)   2016-07-02 15:37:00
fc-query 對 charset 的判斷並不可靠。
作者: hn12404988 (Willy)   2016-07-02 18:05:00
對,後來我實際使用了幾個中文字檢查了幾個檔案發現charset提供的資訊有一定機率的失誤後來就使用freetype library來解決這問題了
作者: EdwardGJLee (LGJ)   2016-07-02 19:34:00
要用 c 寫的話,一些地方要自己刻。FT2 對字型操作相當陽春。

Links booklink

Contact Us: admin [ a t ] ucptt.com