【VB】字符表,可用于游戏绘制字符
用VB写的,通过调用TextOut来绘制每一个字符。这个字符表可用于游戏的字符纹理(当然它可能有点大了,但是比较全)。每256个字符一行,共256行,每个字符都是12x12的(半角字符是6x12的,自己判断全角半角。)另外,各种阿拉伯文的尺寸未知。主要是照顾中日韩用户。
也许还不如用freetype开源库呢。
创建一个窗口然后添加一个PictureBox,要求:
AutoRedraw = True
BorderStyle = 0
ScaleMode = 3
BackColor = &H80000005&
Option Explicit
Private Declare Function TextOut Lib "gdi32" Alias "TextOutW" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, lpString As Any, ByVal nCount As Long) As Long
Private Sub Form_Load()
Show
picTable.Move 0, 0, 256 * 12, 256 * 12
Dim I&, X&, Y&
For Y = 0 To 255
For X = 0 To 255
TextOut picTable.hDC, X * 12, Y * 12, I, 2
I = I + 1
Next
Next
picTable.Refresh
SavePicture picTable.Image, "Font.bmp"
End Sub
Private Sub picTable_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static DrX!, DrY!
If Button And 1 Then
picTable.Move picTable.Left + X - DrX, picTable.Top + Y - DrY
Else
DrX = X
DrY = Y
End If
End Sub生成的字符表如下:
BIN:
SRC:
页:
[1]