TextSetStyle

Syntax

TextSetStyle(Text, Style)

Description

Sets the font style (normal, italic, or oblique) for the specified text object.

Parameters

Text
The handle of the text object to modify.

Style
The font style constant.

#PG_Text_Style_Normal  : Standard upright style. (Default)
#PG_Text_Style_Oblique : Slanted style, often algorithmically generated if no specific oblique font face exists.
#PG_Text_Style_Italic  : Cursive/slanted style, typically uses a specific italic font face if available.

Return Value

This function does not return a value.

Remarks

The availability of true italic or oblique styles depends on the chosen font family (CreateText()). If the specific style is not available, the rendering engine might simulate it (e.g., algorithmically skewing the normal style for oblique) or fall back to the normal style.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Global TextNormal, TextItalic

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
    DrawClear(RGB(240, 240, 240), 1)
    DrawTxt(TextNormal, 10, 10, 0)
    DrawTxt(TextItalic, 10, 40, 0)
EndProcedure

MyWindow = CreateWindow(0, 0, 200, 100, "Text Style")

If MyWindow
    TextNormal = CreateText("Normal Text", "Arial", 14)
    TextItalic = CreateText("Italic Text", "Arial", 14)
    TextSetStyle(TextItalic, #PG_Text_Style_Italic) ; Set style to Italic

    AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
    WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
    Repeat: Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
    FreeText(TextNormal)
    FreeText(TextItalic)
EndIf

StopProGUI()

See Also

CreateText, TextGetStyle, TextSetWeight

Supported OS

Windows, Linux