您现在的位置:首页 > 网络学院
资料检索 SEARCH

热点推荐

 

 
绘制各种图形的组件ShotGraph2.5 ------创建字体函数
    2002-10-7 15:48:07    


CreateFont
创建字体函数

The CreateFont function creates a font that has specific characteristics.
用CreateFont函数可以创建具有特殊特性的字体。
CreateFont sFamily, nCharset, nHeight, nAngle, bBold, bItalic, bUnderline, bStrikeOut [,bUnicode]


Parameters
参数
sFamily
String that specifies the typeface name of the font.
sFamily 参数规定了字体的字样名。

nCharset
Specifies the character set number. Some values see in the "Remarks" section.
nCharset参数规定字符集代码。其中某些代码可以参考“备注”部分。

nHeight
Specifies the height, in pixels, of the font's character cell or character. Zero value means default height value.
nHeight参数规定字体字符元或字符像素的高度。缺省高度值为零。

nAngle
Specifies the angle, in tenths of degrees, between text's base line and the x-axis.
nAngle参数规定正文基线和X-线的角度,单位为1/10度。

bBold
Specifies the font weight. Can be either boolean value or string. Set bBold to True to specify an bold font, normal font is False.
Also, you can set the string specifying the font weight directly. If bBold is string, it can be one of the following strings:
FW_DONTCARE (System default)
FW_THIN
FW_EXTRALIGHT
FW_LIGHT
FW_NORMAL
FW_MEDIUM
FW_SEMIBOLD
FW_BOLD
FW_EXTRABOLD
FW_BLACK
bBold 参数规定字体灰度。灰度值可以是布尔值或字符串。bBold 为True 时,为粗体,普通字体为 False。
你还可以直接设定规定字体灰度的串。如果bBold为串,它可以为下面的任意一种串:
FW_DONTCARE (系统缺省)
FW_THIN
FW_EXTRALIGHT
FW_LIGHT
FW_NORMAL
FW_MEDIUM
FW_SEMIBOLD
FW_BOLD
FW_EXTRABOLD
FW_BLACK

bItalic
Specifies an italic font if set to True.
bItalic参数设定为True时为斜体。

bUnderline
Specifies an underlined font if set to True.
bUnderline参数设定为True时为下划线字体。

bStrikeOut
Specifies an strikeout font if set to True.
bStrikeOut 参数设定为True时为加删除线字体。

bUnicode
Optional. If True the function will use the Unicode representation of the font name string. If False the function will use the ASCII representaion. The default value is False.
bUnicode参数为可选项。该函数设定为True时,将使用字体名字串的Unicode表示法。该函数设定为False时,使用的是ASCII表示法。缺省值为False。

Remarks
The CreateFont function let you create fonts for later text drawing. This function uses fonts installed on NT server, not on the client!
When you draw text by font with height different from default, you can use BuildPalette function to add anti-alias effect to your picture. Some fonts do not require palette building.
备注:该函数可以用来设定后面正文制图的字体。它使用的是NT服务器上安装的字体,而不是客户端安装的字体。如果在画正文时,你使用的字体的高度与缺省值不同,可以用BuildPalette函数在你的图片上防别名效果。

Some charset numbers:
0 - ANSI charset
1 - default charset
2 - symbol charset
136 - Chinese Big5
161 - Greek charset
163 - Vietnamese charset
204 - Cyrillic charset
222 - Thai charset
238 - East Europe charset
一些字符集的代码:
0 - 美国国家标准化组织字符集
1 - 缺省字符集
2 - 符号字符集
136 - 中国大五码
161 - 希腊字符集
163 - 越南字符集
204 - 古代斯拉夫语字符集
222 - 泰国语字符集
238 - 东欧字符集

See too
TextOut
还请参考TextOut

Example例子
View result观察结果

<%@ Language=VBScript %>
<%
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")

size=401
obj.CreateImage size,size,4
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,0,0,204
obj.SetColor 3,103,0,51
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1

obj.CreatePen "PS_SOLID",5,1
obj.Line 0,size/2,size-1,size/2
obj.SetBkMode "TRANSPARENT"
obj.CreateFont "Arial",204,48,0,True,False,False,False
obj.SetTextColor 1
obj.TextOut 4,4,"蒡?镱-痼耨觇!"
obj.CreateFont "Times New Roman",204,96,0,False,True,False,False
obj.SetTextColor 2
obj.TextOut 200,300,"Times"
obj.CreateFont "Verdana",204,96,450,False,False,True,False
obj.SetTextColor 3
obj.TextOut 20,300,"Angle=45"
obj.BuildPalette 4

img=obj.GifImage(-1,1,"")
Response.BinaryWrite(img)
%>