緣起:區區想用symbian系統API,把系統字體的字模實時獲取出來。
所謂字模又叫glyph,有向量表達(paths)和位圖表達(bitmap),這個之前弄freetype和ndsl編程時已經很熟悉。
關鍵是在處處不熟悉的S60平臺,很多東西文檔講不全。如果算自然時間,我一個朋前就想實現這個功能,直到昨天才算有眉目,
BS Nokia公司的文檔!!!
文檔具體地點:S60 Developer Tools 3rd Edtion SDK / 1.1 MR/ SDK help, 索引關鍵字爲:TPositionParam
這是CFont的嵌套類,文檔內容爲:
class TPositionParam;
Description
Complicated parameter block used for contextual glyph selection, ligature creation and diacritic placement when drawing text in complex scripts
This class declares a constructor, another scoped class, and several other enums. However this class is unlikely to be useful to third party developers.
注意最後這句However...... unlikely。。。
Nokia你要麼整點有用的,要麼別發佈這個接口啊,從v1取v5都是這句廢話,害區區找不到,搞不清。
花了一下午試驗,還是沒搞清其iOutput下的iBitmap是個什麼結構,也許太心煩了。
回家後重新一想,bitmap這種結構應該有些通用習慣吧?於是問問wiki,,找到這個http://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format
裏面有個'A'字模的例子:
STARTFONT 2.1
FONT -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1
SIZE 16 75 75
FONTBOUNDINGBOX 16 16 0 -2
STARTPROPERTIES 2
FONT_ASCENT 14
FONT_DESCENT 2
ENDPROPERTIES
CHARS 1
STARTCHAR U+0041
ENCODING 65
SWIDTH 500 0
DWIDTH 8 0
BBX 8 16 0 -2
BITMAP
00
00
00
00
18
24
24
42
42
7E
42
42
42
42
00
00
ENDCHAR
ENDFONT
我不清楚s60的會不會也是這個,明天我再試試吧!
調試腳本先準備好:
(defun binary-rep-text ()
(interactive)
(backward-word 1)
(let* ((word (buffer-substring (point) (progn (forward-word) (point))))
(num (string-to-int word 16)))
(backward-kill-word 1)
(dotimes (time 8)
(insert (format "%d " (logand (lsh num (- time)) 1)) )
(backward-word)
)))
睡覺睡覺,開始做symbian之後,休息顯得不足^_