TextSetWeight

Syntax

TextSetWeight(Text, Weight)

Description

Sets the font weight (boldness) for the specified text object.

Parameters

Text
The handle of the text object to modify.

Weight
The font weight constant.

#PG_Text_Weight_Thin       (100)
#PG_Text_Weight_ExtraLight (200)
#PG_Text_Weight_Light      (300)
#PG_Text_Weight_SemiLight  (350)
#PG_Text_Weight_Normal     (400) - Default
#PG_Text_Weight_Medium     (500)
#PG_Text_Weight_SemiBold   (600)
#PG_Text_Weight_Bold       (700)
#PG_Text_Weight_ExtraBold  (800)
#PG_Text_Weight_Black      (900)
#PG_Text_Weight_ExtraBlack (950)

Return Value

This function does not return a value.

Remarks

The availability of specific weights depends on the chosen font family (CreateText()). If the exact weight is not available, the rendering engine typically selects the closest available weight or might synthesize a weight (e.g., simulating bold).

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Global TextNormal, TextBold

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

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

If MyWindow
    TextNormal = CreateText("Normal Weight", "Arial", 14)
    TextBold = CreateText("Bold Weight", "Arial", 14)
    TextSetWeight(TextBold, #PG_Text_Weight_Bold) ; Set weight to Bold

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

StopProGUI()

See Also

CreateText, TextGetWeight, TextSetStyle

Supported OS

Windows, Linux