GDI v0.1.0
FW_NORMAL
pub const FW_NORMAL: int32 = 400;
FW_NORMAL: the regular weight of a font.
FW_SEMIBOLD
pub const FW_SEMIBOLD: int32 = 600;
FW_SEMIBOLD: the weight between regular and bold, which Windows uses for headings.
FW_BOLD
pub const FW_BOLD: int32 = 700;
FW_BOLD: the bold weight of a font.
DEFAULT_CHARSET
pub const DEFAULT_CHARSET: uint32 = 1;
DEFAULT_CHARSET: let the font mapper choose the character set from the face name.
OUT_DEFAULT_PRECIS
pub const OUT_DEFAULT_PRECIS: uint32 = 0;
OUT_DEFAULT_PRECIS: let the font mapper decide how closely the font must match.
CLIP_DEFAULT_PRECIS
pub const CLIP_DEFAULT_PRECIS: uint32 = 0;
CLIP_DEFAULT_PRECIS: clip characters the default way.
CLEARTYPE_QUALITY
pub const CLEARTYPE_QUALITY: uint32 = 5;
CLEARTYPE_QUALITY: draw the font with ClearType smoothing.
DEFAULT_PITCH
pub const DEFAULT_PITCH: uint32 = 0;
DEFAULT_PITCH: let the font mapper choose fixed or variable pitch.
TRANSPARENT
pub const TRANSPARENT: int32 = 1;
TRANSPARENT: text is drawn without filling the cell behind it.
OPAQUE
pub const OPAQUE: int32 = 2;
OPAQUE: text is drawn on a cell filled with the background color.
CreateFontW
pub extern func CreateFontW(
height: int32,
width: int32,
escapement: int32,
orientation: int32,
weight: int32,
italic: uint32,
underline: uint32,
strikeOut: uint32,
charSet: uint32,
outPrecision: uint32,
clipPrecision: uint32,
quality: uint32,
pitchAndFamily: uint32,
faceName: *char16
) -> *var opaque
Creates a logical font, which the mapper matches to the closest installed font when it is selected.
A negative height asks for that many pixels of character height without the internal leading, which is how a
point size is given: -(points * dpi / 72).
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-createfontw
Parameters
| Name | Type | Description |
|---|---|---|
height | int32 | the character height in pixels, negative for the character height without the leading |
width | int32 | the average character width, or zero to derive it from the height |
escapement | int32 | the angle of the text line, in tenths of a degree |
orientation | int32 | the angle of each character, in tenths of a degree |
weight | int32 | the weight, such as FW_NORMAL |
italic | uint32 | non-zero for italic |
underline | uint32 | non-zero for underlined |
strikeOut | uint32 | non-zero for struck out |
charSet | uint32 | the character set, usually DEFAULT_CHARSET |
outPrecision | uint32 | how closely the font must match, usually OUT_DEFAULT_PRECIS |
clipPrecision | uint32 | how characters are clipped, usually CLIP_DEFAULT_PRECIS |
quality | uint32 | how it is smoothed, such as CLEARTYPE_QUALITY |
pitchAndFamily | uint32 | the pitch and family, usually DEFAULT_PITCH |
faceName | *char16 | the NUL-terminated UTF-16 face name, such as Segoe UI |
Returns: the font, which the caller deletes with DeleteObject, or null on failure
DeleteObject
pub extern func DeleteObject(object: *var opaque) -> bool32
Deletes a GDI object such as a font, giving back what the system holds for it. An object still selected into a device context is not deleted, and the call fails.
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-deleteobject
Parameters
| Name | Type | Description |
|---|---|---|
object | *var opaque | the object to delete |
Returns: non-zero on success, and zero when the handle is not valid or the object is still selected
SelectObject
pub extern func SelectObject(
deviceContext: *var opaque,
object: *var opaque
) -> *var opaque
Selects a font or another GDI object into a device context, replacing the one of the same kind. The object replaced is returned so it can be selected back before the context is given up.
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-selectobject
Parameters
| Name | Type | Description |
|---|---|---|
deviceContext | *var opaque | the device context |
object | *var opaque | the object to select |
Returns: the object it replaced, or null on failure
SetBkMode
pub extern func SetBkMode(
deviceContext: *var opaque,
mode: int32
) -> int32
Sets whether text is drawn on a filled cell or straight onto what is already there.
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-setbkmode
Parameters
| Name | Type | Description |
|---|---|---|
deviceContext | *var opaque | the device context |
mode | int32 | TRANSPARENT or OPAQUE |
Returns: the mode before the call, or zero on failure
SetTextColor
pub extern func SetTextColor(
deviceContext: *var opaque,
color: uint32
) -> uint32
Sets the color text is drawn in.
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-settextcolor
Parameters
| Name | Type | Description |
|---|---|---|
deviceContext | *var opaque | the device context |
color | uint32 | the color as 0x00BBGGRR, such as one from GetSysColor |
Returns: the color before the call, or CLR_INVALID (0xFFFFFFFF) on failure
TextOutW
pub extern func TextOutW(
deviceContext: *var opaque,
x: int32,
y: int32,
text: *char16,
count: int32
) -> bool32
Draws a run of UTF-16 text with its top-left corner at a point, in the selected font and text color. The run is counted rather than NUL-terminated, and is not wrapped or clipped to the window.
See also: https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-textoutw
Parameters
| Name | Type | Description |
|---|---|---|
deviceContext | *var opaque | the device context |
x | int32 | the left edge, in pixels |
y | int32 | the top edge, in pixels |
text | *char16 | the UTF-16 units to draw |
count | int32 | how many units to draw |
Returns: non-zero on success, and zero on failure