CreateFont
The CreateFont function creates a font that has specific characteristics.
CreateFont
sFamily, nCharset, nHeight, nAngle, bBold, bItalic, bUnderline, bStrikeOut
Parameters
-
sFamily
-
String that specifies the typeface name of the font.
-
nCharset
-
Specifies the character set. The following values are taken as examples:
- 0 - ANSI charset
- 161 - Greek charset
- 204 - Cyrillic charset
-
nHeight
-
Specifies the height, in pixels, of the font's character cell or character. Zero
value means default height value.
-
nAngle
-
Specifies the angle, in tenths of degrees, between text's base line
and the x-axis.
-
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
-
bItalic
-
Specifies an italic font if set to True.
-
bUnderline
-
Specifies an underlined font if set to True.
-
bStrikeOut
-
Specifies an strikeout font if set to True.
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.
See too
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)
%>