Home

TextOut

TextOut is a function in the Windows Graphics Device Interface (GDI) used to render a sequence of characters at a specified location within a device context (DC). It draws text using the font currently selected into the DC and respects the current text color, background mode, and mapping mode. In the commonly used MM_TEXT mode, the x and y coordinates designate the reference point for the text, typically the left edge of the baseline of the first character.

In the Win32 API, there are two character-set variants: TextOutA for ANSI strings and TextOutW for Unicode

Parameters include the device context handle (HDC hdc), the x and y coordinates of the reference point,

TextOut is suitable for simple text rendering but not for complex layouts. For advanced text layout, applications

strings.
The
generic
name
TextOut
resolves
to
TextOutW
in
Unicode
builds.
The
function
signatures
are
typically
presented
as
BOOL
TextOut(HDC
hdc,
int
x,
int
y,
LPCSTR
lpString,
int
cchString)
for
ANSI
or
BOOL
TextOut(HDC
hdc,
int
x,
int
y,
LPCWSTR
lpString,
int
cchString)
for
Unicode,
with
the
return
value
indicating
success
(nonzero)
or
failure
(zero).
a
pointer
to
the
character
string
(lpString),
and
the
length
of
the
string
in
characters
(cchString).
The
function
does
not
return
the
number
of
characters
drawn;
it
returns
a
success
indicator.
If
cchString
is
zero
or
the
string
is
empty,
nothing
is
drawn.
may
use
DrawText
or
ExtTextOut,
and
to
measure
text
extents,
GetTextExtentPoint32
or
related
functions
can
be
employed.