CorelDRAW:CorelScriptTools.GetFont

From OberonPlace Development Portal

Jump to: navigation, search

Contents

CorelScriptTools.GetFont Method

This method displays a standard Windows font selection dialog.

Image:GetFont.png

Syntax

Function GetFont(ByRef FaceName As String, ByRef PointSize As Long, ByRef Weight As Long,  _
    ByRef Italic As Boolean, ByRef Underline As Boolean, ByRef StrikeOut As Boolean,  _
    ByRef Red As Long, ByRef Green As Long, ByRef Blue As Long) As Boolean

Parameters

Name Type Description
FaceName String Font name (in, out)
PointSize Long Font size in points (in, out)
Weight Long Font weight. See remarks section below for details (in, out)
Italic Boolean Specifies whether the font is italic (in, out)
Underline Boolean Specifies whether an underline should be used (in, out)
StrikeOut Boolean Specifies whether a strike-out should be used (in, out)
Red Long Red component of the RGB color (in, out)
Green Long Green component of the RGB color (in, out)
Blue Long Blue component of the RGB color (in, out)

Return Value

Returns a Boolean indicating whether the user clicked Ok or Cancel buttons. If Ok was pressed, then True is returned, False otherwise.

Remarks

The Weight parameter specifies one of the following values:

Value Font weight
100 Thin
200 Extra Light, Ultra Light
300 Light
400 Normal, Regular
500 Medium
600 Semi Bold, Demi Bold
700 Bold
800 Extra Bold, Ultra Bold
900 Black, Heavy

Examples

The following example shows the dialog and when the user specifies the font parameters, creates an artistic text object in CorelDRAW/Designer document with the selected properties:

Sub CreateTextSample()
    Dim FaceName As String, PointSize As Long, Weight As Long
    Dim Italic As Boolean, Underline As Boolean, StrikeOut As Boolean
    Dim Red As Long, Green As Long, Blue As Long
 
    ' Initial values
    FaceName = "Arial"
    PointSize = 24
    Weight = 400
    Italic = False
    Underline = False
    StrikeOut = False
    Red = 0
    Green = 0
    Blue = 0
    If Not CorelScriptTools.GetFont(FaceName, PointSize, Weight, Italic, _
                Underline, StrikeOut, Red, Green, Blue) Then Exit Sub
 
    Dim fontStyle As cdrFontStyle
    Select Case Weight
        Case 100 ' Thin
            If Italic Then
                fontStyle = cdrThinItalicFontStyle
            Else
                fontStyle = cdrThinFontStyle
            End If
 
        Case 200 ' Extra Light, Ultra Light
            If Italic Then
                fontStyle = cdrExtraLightItalicFontStyle
            Else
                fontStyle = cdrExtraLightFontStyle
            End If
 
        Case 300 ' Light
            If Italic Then
                fontStyle = cdrThinItalicFontStyle
            Else
                fontStyle = cdrThinFontStyle
            End If
 
        Case 400 ' Normal, Regular
            If Italic Then
                fontStyle = cdrItalicFontStyle
            Else
                fontStyle = cdrNormalFontStyle
            End If
 
        Case 500 ' Medium
            If Italic Then
                fontStyle = cdrItalicFontStyle
            Else
                fontStyle = cdrNormalFontStyle
            End If
 
        Case 600 ' Semi Bold, Demi Bold
            If Italic Then
                fontStyle = cdrSemiBoldItalicFontStyle
            Else
                fontStyle = cdrSemiBoldFontStyle
            End If
 
        Case 700 ' Bold
            If Italic Then
                fontStyle = cdrBoldItalicFontStyle
            Else
                fontStyle = cdrBoldFontStyle
            End If
 
        Case 800 ' Extra Bold, Ultra Bold
            If Italic Then
                fontStyle = cdrExtraBoldItalicFontStyle
            Else
                fontStyle = cdrExtraBoldFontStyle
            End If
 
        Case 900 ' Black, Heavy
            If Italic Then
                fontStyle = cdrHeavyItalicFontStyle
            Else
                fontStyle = cdrHeavyFontStyle
            End If
    End Select
 
    Dim underlineStyle As cdrFontLine
    If Underline Then
        underlineStyle = cdrSingleThickFontLine
    Else
        underlineStyle = cdrNoFontLine
    End If
 
    Dim strikeoutStyle As cdrFontLine
    If StrikeOut Then
        strikeoutStyle = cdrSingleThickFontLine
    Else
        strikeoutStyle = cdrNoFontLine
    End If
 
    Dim s As Shape
    Set s = ActiveLayer.CreateArtisticText(0, 0, "Sample", , , FaceName, PointSize, , , underlineStyle)
    s.Text.Story.Style = fontStyle
    s.Text.Story.Strikethru = strikeoutStyle
    s.Fill.UniformColor.RGBAssign Red, Green, Blue
End Sub

Version Information

  • CorelDRAW: Available since version 9
  • Corel DESIGNER: Available since version 10

References

Personal tools