ReactOS 0.4.17-dev-470-gf9e3448
font.c File Reference
#include <user32.h>
Include dependency graph for font.c:

Go to the source code of this file.

Macros

#define MAX_BUFFER   1024
 
#define PREFIX   38
 
#define ALPHA_PREFIX   30 /* Win16: Alphabet prefix */
 
#define KANA_PREFIX   31 /* Win16: Katakana prefix */
 

Functions

DWORD WINAPI GdiGetCodePage (HDC hdc)
 
INT WINAPI DrawTextExWorker (HDC hdc, LPWSTR str, INT i_count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
 
LONG TEXT_TabbedTextOut (HDC hdc, INT x, INT y, LPCWSTR lpstr, INT count, INT cTabStops, const INT *lpTabPos, INT nTabOrg, BOOL fDisplayText)
 
LONG WINAPI TabbedTextOutA (HDC hDC, int X, int Y, LPCSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions, int nTabOrigin)
 
LONG WINAPI TabbedTextOutW (HDC hDC, int X, int Y, LPCWSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions, int nTabOrigin)
 
DWORD WINAPI GetTabbedTextExtentA (HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions)
 
DWORD WINAPI GetTabbedTextExtentW (HDC hDC, LPCWSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions)
 
INT WINAPI DrawTextExW (HDC hdc, LPWSTR str, INT i_count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
 
INT WINAPI DrawTextExA (HDC hdc, LPSTR str, INT count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
 
INT WINAPI DrawTextW (HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
 
INT WINAPI DrawTextA (HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
 
INT WINAPI UserLpkPSMTextOut (HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags)
 

Macro Definition Documentation

◆ ALPHA_PREFIX

#define ALPHA_PREFIX   30 /* Win16: Alphabet prefix */

Definition at line 410 of file font.c.

◆ KANA_PREFIX

#define KANA_PREFIX   31 /* Win16: Katakana prefix */

Definition at line 411 of file font.c.

◆ MAX_BUFFER

#define MAX_BUFFER   1024

Definition at line 253 of file font.c.

◆ PREFIX

#define PREFIX   38

Definition at line 409 of file font.c.

Function Documentation

◆ DrawTextA()

INT WINAPI DrawTextA ( HDC  hdc,
LPCSTR  str,
INT  count,
LPRECT  rect,
UINT  flags 
)

Definition at line 373 of file font.c.

374{
375 DRAWTEXTPARAMS dtp;
376
377 memset (&dtp, 0, sizeof(dtp));
378 dtp.cbSize = sizeof(dtp);
379 if (flags & DT_TABSTOP)
380 {
381 dtp.iTabLength = (flags >> 8) & 0xff;
382 flags &= 0xffff00ff;
383 }
384 return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, &dtp );
385}
RECT rect
Definition: combotst.c:67
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
char * LPSTR
Definition: typedefs.h:51
INT WINAPI DrawTextExA(HDC hdc, LPSTR str, INT count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
Definition: font.c:276
#define DT_TABSTOP
Definition: winuser.h:541

Referenced by create_bitmap(), DECLARE_INTERFACE_(), DoEntry(), menu_ownerdraw_wnd_proc(), PAINTING_DrawStateJam(), test_bcm_get_ideal_size(), and test_DrawTextCalcRect().

◆ DrawTextExA()

INT WINAPI DrawTextExA ( HDC  hdc,
LPSTR  str,
INT  count,
LPRECT  rect,
UINT  flags,
LPDRAWTEXTPARAMS  dtp 
)

Definition at line 276 of file font.c.

278{
279 WCHAR *wstr;
280 WCHAR *p;
281 INT ret = 0;
282 int i;
283 DWORD wcount;
284 DWORD wmax;
285 DWORD amax;
286 UINT cp;
287
288 if (!count) return 0;
289 if (!str && count > 0) return 0;
290 if( !str || ((count == -1) && !(count = strlen(str))))
291 {
292 int lh;
294
295 if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
296 return 0;
297
300 lh = tm.tmHeight + tm.tmExternalLeading;
301 else
302 lh = tm.tmHeight;
303
304 if( flags & DT_CALCRECT)
305 {
306 rect->right = rect->left;
307 if( flags & DT_SINGLELINE)
308 rect->bottom = rect->top + lh;
309 else
310 rect->bottom = rect->top;
311 }
312 return lh;
313 }
314 cp = GdiGetCodePage( hdc );
315 wcount = MultiByteToWideChar( cp, 0, str, count, NULL, 0 );
316 wmax = wcount;
317 amax = count;
319 {
320 wmax += 4;
321 amax += 4;
322 }
323 wstr = HeapAlloc(GetProcessHeap(), 0, wmax * sizeof(WCHAR));
324 if (wstr)
325 {
326 MultiByteToWideChar( cp, 0, str, count, wstr, wcount );
328 for (i=4, p=wstr+wcount; i--; p++) *p=0xFFFE;
329 /* Initialise the extra characters so that we can see which ones
330 * change. U+FFFE is guaranteed to be not a unicode character and
331 * so will not be generated by DrawTextEx itself.
332 */
333 ret = DrawTextExW( hdc, wstr, wcount, rect, flags, dtp );
335 {
336 /* Unfortunately the returned string may contain multiple \0s
337 * and so we need to measure it ourselves.
338 */
339 for (i=4, p=wstr+wcount; i-- && *p != 0xFFFE; p++) wcount++;
340 WideCharToMultiByte( cp, 0, wstr, wcount, str, amax, NULL, NULL );
341 }
342 HeapFree(GetProcessHeap(), 0, wstr);
343 }
344 return ret;
345}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
return ret
Definition: mutex.c:146
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
POINT cp
Definition: magnifier.c:59
short WCHAR
Definition: pedump.c:58
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int32_t INT
Definition: typedefs.h:58
INT WINAPI DrawTextExW(HDC hdc, LPWSTR str, INT i_count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
Definition: font.c:259
DWORD WINAPI GdiGetCodePage(HDC)
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define DT_EXTERNALLEADING
Definition: winuser.h:533
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_MODIFYSTRING
Definition: winuser.h:535
#define DT_CALCRECT
Definition: winuser.h:526

Referenced by DrawTextA().

◆ DrawTextExW()

INT WINAPI DrawTextExW ( HDC  hdc,
LPWSTR  str,
INT  i_count,
LPRECT  rect,
UINT  flags,
LPDRAWTEXTPARAMS  dtp 
)

Definition at line 259 of file font.c.

261{
262 return DrawTextExWorker( hdc, str, i_count, rect, flags, dtp );
263}
INT WINAPI DrawTextExWorker(HDC hdc, LPWSTR str, INT i_count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp)
Definition: text.c:1075

Referenced by DrawTextExA(), and DrawTextW().

◆ DrawTextExWorker()

INT WINAPI DrawTextExWorker ( HDC  hdc,
LPWSTR  str,
INT  i_count,
LPRECT  rect,
UINT  flags,
LPDRAWTEXTPARAMS  dtp 
)

Definition at line 1075 of file text.c.

1081{
1082 SIZE size;
1083 const WCHAR *strPtr;
1084 WCHAR *retstr, *p_retstr;
1085 size_t size_retstr;
1087 int len, lh, count=i_count;
1089 int lmargin = 0, rmargin = 0;
1090 int x = rect->left, y = rect->top;
1091 int width = rect->right - rect->left;
1092 int max_width = 0;
1093 int last_line;
1094 int tabwidth /* to keep gcc happy */ = 0;
1095 int prefix_offset;
1096 ellipsis_data ellip;
1097 BOOL invert_y=FALSE;
1098
1099 HRGN hrgn = 0;
1100
1101#ifdef _WIN32K_
1102 TRACE("%S, %d, %08x\n", str, count, flags);
1103#else
1104 TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count,
1106#endif
1107 if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
1108 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
1109
1110 if (!str) return 0;
1111
1112 strPtr = str;
1113
1114 if (flags & DT_SINGLELINE)
1115 flags &= ~DT_WORDBREAK;
1116#ifdef _WIN32K_
1118#else
1120#endif
1122 lh = tm.tmHeight + tm.tmExternalLeading;
1123 else
1124 lh = tm.tmHeight;
1125
1126 if (str[0] && count == 0)
1127 return lh;
1128
1129 if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
1130 return 0;
1131#ifdef _WIN32K_
1133 {
1134 SIZE window_ext, viewport_ext;
1135 GreGetWindowExtEx(hdc, &window_ext);
1136 GreGetViewportExtEx(hdc, &viewport_ext);
1137 if ((window_ext.cy > 0) != (viewport_ext.cy > 0))
1138 invert_y = TRUE;
1139 }
1140#else
1142 {
1143 SIZE window_ext, viewport_ext;
1144 GetWindowExtEx(hdc, &window_ext);
1145 GetViewportExtEx(hdc, &viewport_ext);
1146 if ((window_ext.cy > 0) != (viewport_ext.cy > 0))
1147 invert_y = TRUE;
1148 }
1149#endif
1150 if (count == -1)
1151 {
1152#ifdef _WIN32K_
1153 count = wcslen(str);
1154#else
1155 count = strlenW(str);
1156#endif
1157 if (count == 0)
1158 {
1159 if( flags & DT_CALCRECT)
1160 {
1161 rect->right = rect->left;
1162 if( flags & DT_SINGLELINE)
1163 rect->bottom = rect->top + (invert_y ? -lh : lh);
1164 else
1165 rect->bottom = rect->top;
1166 }
1167 return lh;
1168 }
1169 }
1170
1171 if (dtp)
1172 {
1173 lmargin = dtp->iLeftMargin;
1174 rmargin = dtp->iRightMargin;
1175 if (!(flags & (DT_CENTER | DT_RIGHT)))
1176 x += lmargin;
1177 dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
1178 }
1179
1180 if (flags & DT_EXPANDTABS)
1181 {
1182 int tabstop = ((flags & DT_TABSTOP) && dtp && dtp->iTabLength) ? dtp->iTabLength : 8;
1183 tabwidth = tm.tmAveCharWidth * tabstop;
1184 }
1185
1186 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
1187#ifndef _WIN32K_
1188 if (!(flags & DT_NOCLIP) )
1189 {
1190 int hasClip;
1191 hrgn = CreateRectRgn(0,0,0,0);
1192 if (hrgn)
1193 {
1194 hasClip = GetClipRgn(hdc, hrgn);
1195 // If the region to be retrieved is NULL, the return value is 0.
1196 if (hasClip != 1)
1197 {
1199 hrgn = NULL;
1200 }
1202 }
1203 }
1204#else
1205 if (!(flags & DT_NOCLIP) )
1206 {
1207 int hasClip;
1208 hrgn = NtGdiCreateRectRgn(0,0,0,0);
1209 if (hrgn)
1210 {
1211 hasClip = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN);
1212 if (hasClip != 1)
1213 {
1215 hrgn = NULL;
1216 }
1218 }
1219 }
1220#endif
1221 if (flags & DT_MODIFYSTRING)
1222 {
1223 size_retstr = (count + 4) * sizeof (WCHAR);
1224#ifdef _WIN32K_
1225 retstr = ExAllocatePoolWithTag(PagedPool, size_retstr, USERTAG_RTL);
1226#else
1227 retstr = HeapAlloc(GetProcessHeap(), 0, size_retstr);
1228#endif
1229 if (!retstr) return 0;
1230 memcpy (retstr, str, size_retstr);
1231 }
1232 else
1233 {
1234 size_retstr = 0;
1235 retstr = NULL;
1236 }
1237 p_retstr = retstr;
1238
1239 do
1240 {
1241 len = sizeof(line)/sizeof(line[0]);
1242 if (invert_y)
1243 last_line = !(flags & DT_NOCLIP) && y - ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) < rect->bottom;
1244 else
1245 last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
1246 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags, &size, last_line, &p_retstr, tabwidth, &prefix_offset, &ellip);
1247
1248#ifdef __REACTOS__
1249 if (flags & DT_CENTER)
1250 {
1251 if (((rect->right - rect->left) < size.cx) && (flags & DT_CALCRECT))
1252 {
1253 x = rect->left + size.cx;
1254 }
1255 else
1256 {
1257 x = (rect->left + rect->right - size.cx) / 2;
1258 }
1259 }
1260#else
1261 if (flags & DT_CENTER) x = (rect->left + rect->right -
1262 size.cx) / 2;
1263#endif
1264 else if (flags & DT_RIGHT) x = rect->right - size.cx;
1265
1266 if (flags & DT_SINGLELINE)
1267 {
1268#ifdef __REACTOS__
1269 if (flags & DT_VCENTER) y = rect->top +
1270 (rect->bottom - rect->top + (invert_y ? size.cy : -size.cy)) / 2;
1271 else if (flags & DT_BOTTOM)
1272 y = rect->bottom + (invert_y ? size.cy : -size.cy);
1273#else
1274 if (flags & DT_VCENTER) y = rect->top +
1275 (rect->bottom - rect->top) / 2 - size.cy / 2;
1276 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
1277#endif
1278 }
1279
1280 if (!(flags & DT_CALCRECT))
1281 {
1282 const WCHAR *str = line;
1283 int xseg = x;
1284 while (len)
1285 {
1286 int len_seg;
1287 SIZE size;
1288 if ((flags & DT_EXPANDTABS))
1289 {
1290 const WCHAR *p;
1291 p = str; while (p < str+len && *p != TAB) p++;
1292 len_seg = p - str;
1293 if (len_seg != len &&
1294#ifdef _WIN32K_
1295 !GreGetTextExtentW(hdc, str, len_seg, &size, 0))
1296#else
1297 !GetTextExtentPointW(hdc, str, len_seg, &size))
1298#endif
1299 {
1300#ifdef _WIN32K_
1302#else
1303 HeapFree (GetProcessHeap(), 0, retstr);
1304#endif
1305 return 0;
1306 }
1307 }
1308 else
1309 len_seg = len;
1310#ifdef _WIN32K_
1311 if (!UserExtTextOutW( hdc, xseg, y,
1312 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
1313 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
1314 rect, str, len_seg))
1315#else
1316 if (!ExtTextOutW( hdc, xseg, y,
1317 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
1318 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
1319 rect, str, len_seg, NULL ))
1320#endif
1321 {
1322#ifdef _WIN32K_
1324#else
1325 HeapFree (GetProcessHeap(), 0, retstr);
1326#endif
1327 return 0;
1328 }
1329 if (prefix_offset != -1 && prefix_offset < len_seg)
1330 {
1331 TEXT_DrawUnderscore (hdc, xseg, y + tm.tmAscent + 1, str, prefix_offset, (flags & DT_NOCLIP) ? NULL : rect);
1332 }
1333 len -= len_seg;
1334 str += len_seg;
1335 if (len)
1336 {
1337 assert ((flags & DT_EXPANDTABS) && *str == TAB);
1338 len--; str++;
1339 xseg += ((size.cx/tabwidth)+1)*tabwidth;
1340 if (prefix_offset != -1)
1341 {
1342 if (prefix_offset < len_seg)
1343 {
1344 /* We have just drawn an underscore; we ought to
1345 * figure out where the next one is. I am going
1346 * to leave it for now until I have a better model
1347 * for the line, which will make reprefixing easier.
1348 * This is where ellip would be used.
1349 */
1350 prefix_offset = -1;
1351 }
1352 else
1353 prefix_offset -= len_seg;
1354 }
1355 }
1356 }
1357 }
1358 else if (size.cx > max_width)
1359 max_width = size.cx;
1360
1361 y += invert_y ? -lh : lh;
1362 if (dtp)
1363 dtp->uiLengthDrawn += len;
1364 }
1365 while (strPtr && !last_line);
1366
1367#ifndef _WIN32K_
1368 if (!(flags & DT_NOCLIP) )
1369 {
1370 SelectClipRgn(hdc, hrgn); // This should be NtGdiExtSelectClipRgn, but due to ReactOS build rules this option is next:
1371 GdiFlush(); // Flush the batch and level up! See CORE-16498.
1372 if (hrgn)
1373 {
1375 }
1376 }
1377#else
1378 if (!(flags & DT_NOCLIP) )
1379 {
1381 if (hrgn)
1382 {
1384 }
1385 }
1386#endif
1387
1388 if (flags & DT_CALCRECT)
1389 {
1390 rect->right = rect->left + max_width;
1391 rect->bottom = y;
1392 if (dtp)
1393 rect->right += lmargin + rmargin;
1394 }
1395 if (retstr)
1396 {
1397 memcpy (str, retstr, size_retstr);
1398#ifdef _WIN32K_
1400#else
1401 HeapFree (GetProcessHeap(), 0, retstr);
1402#endif
1403 }
1404 return y - rect->top;
1405}
static HRGN hrgn
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
int FASTCALL GreGetGraphicsMode(HDC)
Definition: dcutil.c:306
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_wn
Definition: kernel32.h:33
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define CLIPRGN
Definition: precomp.h:18
BOOL WINAPI GreGetViewportExtEx(_In_ HDC hdc, _Out_ LPSIZE lpSize)
Definition: coord.c:1416
BOOL WINAPI GreGetWindowExtEx(_In_ HDC hdc, _Out_ LPSIZE lpSize)
Definition: coord.c:1407
__kernel_entry W32KAPI HRGN APIENTRY NtGdiCreateRectRgn(_In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
__kernel_entry W32KAPI INT APIENTRY NtGdiExtSelectClipRgn(_In_ HDC hdc, _In_opt_ HRGN hrgn, _In_ INT iMode)
__kernel_entry W32KAPI INT APIENTRY NtGdiIntersectClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: cliprgn.c:488
__kernel_entry W32KAPI INT APIENTRY NtGdiGetRandomRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iRgn)
#define TRACE(s)
Definition: solgame.cpp:4
int iRightMargin
Definition: winuser.h:3208
UINT uiLengthDrawn
Definition: winuser.h:3209
LONG cy
Definition: kdterminal.h:28
Definition: parser.c:49
BOOL UserExtTextOutW(HDC hdc, INT x, INT y, UINT flags, PRECTL lprc, LPCWSTR lpString, UINT count)
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1165
BOOL WINAPI GreGetTextMetricsW(_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
Definition: text.c:191
BOOL FASTCALL GreGetTextExtentW(_In_ HDC hDC, _In_reads_(cwc) PCWCH lpwsz, _In_ INT cwc, _Out_ PSIZE psize, _In_ UINT flOpts)
Definition: text.c:77
#define USERTAG_RTL
Definition: tags.h:270
#define MAX_BUFFER
Definition: text.c:1069
static void TEXT_DrawUnderscore(HDC hdc, int x, int y, const WCHAR *str, int offset, const RECT *rect)
Definition: text.c:898
static const WCHAR * TEXT_NextLineW(HDC hdc, const WCHAR *str, int *count, WCHAR *dest, int *len, int width, DWORD format, SIZE *retsize, int last_line, WCHAR **p_retstr, int tabwidth, int *pprefix_offset, ellipsis_data *pellip)
Definition: text.c:670
#define TAB
Definition: text.c:109
#define assert(e)
Definition: text.c:47
#define strlenW(s)
Definition: unicode.h:28
#define GM_COMPATIBLE
Definition: wingdi.h:864
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetGraphicsMode(_In_ HDC)
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
BOOL WINAPI GdiFlush(void)
Definition: misc.c:44
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define RGN_COPY
Definition: wingdi.h:357
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define DT_CENTER
Definition: winuser.h:527
#define DT_NOCLIP
Definition: winuser.h:536
#define DT_RTLREADING
Definition: winuser.h:539
#define DT_VCENTER
Definition: winuser.h:543
#define DT_BOTTOM
Definition: winuser.h:525
#define DT_RIGHT
Definition: winuser.h:538
#define DT_EXPANDTABS
Definition: winuser.h:532
#define DT_EDITCONTROL
Definition: winuser.h:528

Referenced by DrawTextExW().

◆ DrawTextW()

INT WINAPI DrawTextW ( HDC  hdc,
LPCWSTR  str,
INT  count,
LPRECT  rect,
UINT  flags 
)

Definition at line 353 of file font.c.

354{
355 DRAWTEXTPARAMS dtp;
356
357 memset (&dtp, 0, sizeof(dtp));
358 dtp.cbSize = sizeof(dtp);
359 if (flags & DT_TABSTOP)
360 {
361 dtp.iTabLength = (flags >> 8) & 0xff;
362 flags &= 0xffff00ff;
363 }
364 return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, &dtp);
365}
uint16_t * LPWSTR
Definition: typedefs.h:56

◆ GdiGetCodePage()

DWORD WINAPI GdiGetCodePage ( HDC  hdc)

◆ GetTabbedTextExtentA()

DWORD WINAPI GetTabbedTextExtentA ( HDC  hDC,
LPCSTR  lpString,
int  nCount,
int  nTabPositions,
CONST INT lpnTabStopPositions 
)

Definition at line 205 of file font.c.

211{
212 LONG ret;
213 UINT cp = GdiGetCodePage( hDC ); // CP_ACP
214 DWORD len;
215 LPWSTR strW;
216
217 len = MultiByteToWideChar(cp, 0, lpString, nCount, NULL, 0);
218 if (!len) return 0;
219 strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
220 if (!strW) return 0;
221 MultiByteToWideChar(cp, 0, lpString, nCount, strW, len);
222 ret = GetTabbedTextExtentW(hDC, strW, len, nTabPositions, lpnTabStopPositions);
224 return ret;
225}
static HDC hDC
Definition: 3dtext.c:33
WCHAR strW[12]
Definition: clipboard.c:2216
long LONG
Definition: pedump.c:60
DWORD WINAPI GetTabbedTextExtentW(HDC hDC, LPCWSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions)
Definition: font.c:232

◆ GetTabbedTextExtentW()

DWORD WINAPI GetTabbedTextExtentW ( HDC  hDC,
LPCWSTR  lpString,
int  nCount,
int  nTabPositions,
CONST INT lpnTabStopPositions 
)

Definition at line 232 of file font.c.

238{
239 return TEXT_TabbedTextOut(hDC, 0, 0, lpString, nCount, nTabPositions, lpnTabStopPositions, 0, FALSE);
240}
LONG TEXT_TabbedTextOut(HDC hdc, INT x, INT y, LPCWSTR lpstr, INT count, INT cTabStops, const INT *lpTabPos, INT nTabOrg, BOOL fDisplayText)
Definition: font.c:49

Referenced by GetTabbedTextExtentA().

◆ TabbedTextOutA()

LONG WINAPI TabbedTextOutA ( HDC  hDC,
int  X,
int  Y,
LPCSTR  lpString,
int  nCount,
int  nTabPositions,
CONST INT lpnTabStopPositions,
int  nTabOrigin 
)

Definition at line 156 of file font.c.

165{
166 LONG ret;
167 DWORD len;
168 LPWSTR strW;
169 UINT cp = GdiGetCodePage( hDC ); // CP_ACP
170
171 len = MultiByteToWideChar(cp, 0, lpString, nCount, NULL, 0);
172 if (!len) return 0;
173 strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
174 if (!strW) return 0;
175 MultiByteToWideChar(cp, 0, lpString, nCount, strW, len);
176 ret = TabbedTextOutW(hDC, X, Y, strW, len, nTabPositions, lpnTabStopPositions, nTabOrigin);
178 return ret;
179}
#define Y(I)
LONG WINAPI TabbedTextOutW(HDC hDC, int X, int Y, LPCWSTR lpString, int nCount, int nTabPositions, CONST INT *lpnTabStopPositions, int nTabOrigin)
Definition: font.c:186

◆ TabbedTextOutW()

LONG WINAPI TabbedTextOutW ( HDC  hDC,
int  X,
int  Y,
LPCWSTR  lpString,
int  nCount,
int  nTabPositions,
CONST INT lpnTabStopPositions,
int  nTabOrigin 
)

Definition at line 186 of file font.c.

195{
196 return TEXT_TabbedTextOut(hDC, X, Y, lpString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin, TRUE);
197}

Referenced by TabbedTextOutA().

◆ TEXT_TabbedTextOut()

LONG TEXT_TabbedTextOut ( HDC  hdc,
INT  x,
INT  y,
LPCWSTR  lpstr,
INT  count,
INT  cTabStops,
const INT lpTabPos,
INT  nTabOrg,
BOOL  fDisplayText 
)

Definition at line 49 of file font.c.

58{
59 INT defWidth;
61 int i, j;
62 int start = x;
64
65 if (!lpTabPos)
66 cTabStops=0;
67
69
70 if (cTabStops == 1)
71 {
72 defWidth = *lpTabPos;
73 cTabStops = 0;
74 }
75 else
76 {
77 defWidth = 8 * tm.tmAveCharWidth;
78 }
79
80 while (count > 0)
81 {
82 RECT r;
83 INT x0;
84 x0 = x;
85 r.left = x0;
86 /* chop the string into substrings of 0 or more <tabs>
87 * possibly followed by 1 or more normal characters */
88 for (i = 0; i < count; i++)
89 if (lpstr[i] != '\t') break;
90 for (j = i; j < count; j++)
91 if (lpstr[j] == '\t') break;
92 /* get the extent of the normal character part */
93 GetTextExtentPointW( hdc, lpstr + i, j - i , &extent );
94 /* and if there is a <tab>, calculate its position */
95 if( i) {
96 /* get x coordinate for the drawing of this string */
97 for (; cTabStops > i; lpTabPos++, cTabStops--)
98 {
99 if( nTabOrg + abs( *lpTabPos) > x) {
100 if( lpTabPos[ i - 1] >= 0) {
101 /* a left aligned tab */
102 x = nTabOrg + lpTabPos[ i-1] + extent.cx;
103 break;
104 }
105 else
106 {
107 /* if tab pos is negative then text is right-aligned
108 * to tab stop meaning that the string extends to the
109 * left, so we must subtract the width of the string */
110 if (nTabOrg - lpTabPos[ i - 1] - extent.cx > x)
111 {
112 x = nTabOrg - lpTabPos[ i - 1];
113 x0 = x - extent.cx;
114 break;
115 }
116 }
117 }
118 }
119 /* if we have run out of tab stops and we have a valid default tab
120 * stop width then round x up to that width */
121 if ((cTabStops <= i) && (defWidth > 0)) {
122 x0 = nTabOrg + ((x - nTabOrg) / defWidth + i) * defWidth;
123 x = x0 + extent.cx;
124 } else if ((cTabStops <= i) && (defWidth < 0)) {
125 x = nTabOrg + ((x - nTabOrg + extent.cx) / -defWidth + i)
126 * -defWidth;
127 x0 = x - extent.cx;
128 }
129 } else
130 x += extent.cx;
131
132 if (fDisplayText)
133 {
134 r.top = y;
135 r.right = x;
136 r.bottom = y + extent.cy;
137
139 &r, lpstr + i, j - i, NULL );
140 }
141 count -= j;
142 lpstr += j;
143 }
144
145 if(!extent.cy)
146 extent.cy = tm.tmHeight;
147
148 return MAKELONG(x - start, extent.cy);
149}
#define abs(i)
Definition: fconv.c:206
GLuint start
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLint x0
Definition: linetemp.h:95
#define MAKELONG(a, b)
Definition: typedefs.h:249
int WINAPI GetBkMode(_In_ HDC)
#define ETO_OPAQUE
Definition: wingdi.h:647
#define OPAQUE
Definition: wingdi.h:949

Referenced by GetTabbedTextExtentW(), and TabbedTextOutW().

◆ UserLpkPSMTextOut()

INT WINAPI UserLpkPSMTextOut ( HDC  hdc,
int  x,
int  y,
LPCWSTR  lpString,
int  cString,
DWORD  dwFlags 
)

Definition at line 413 of file font.c.

414{
415 SIZE size;
417 int len, i = 0, j = 0;
418 int prefix_count = 0, prefix_offset = -1;
419 LPWSTR display_str = NULL;
420 int prefix_x, prefix_end;
421 HPEN hpen;
422 HPEN oldPen;
423
424 if (!lpString || cString <= 0)
425 return 0;
426
427 if (dwFlags & DT_NOPREFIX) /* Windows ignores this */
428 {
429 TextOutW(hdc, x, y, lpString, cString);
430 GetTextExtentPointW(hdc, lpString, cString, &size);
431 return size.cx;
432 }
433
434 display_str = HeapAlloc(GetProcessHeap(), 0, (cString + 1) * sizeof(WCHAR));
435
436 if (!display_str)
437 return 0;
438
439 while (i < cString)
440 {
441 if (lpString[i] == PREFIX || (iswspace(lpString[i]) && lpString[i] != L' '))
442 {
443 if (i < cString - 1 && lpString[i + 1] == PREFIX)
444 display_str[j++] = lpString[i++];
445 else
446 i++;
447 }
448 else
449 {
450 display_str[j++] = lpString[i++];
451 }
452 }
453
454 display_str[j] = L'\0';
455 len = wcslen(display_str);
456
457 if (!(dwFlags & DT_PREFIXONLY))
458 TextOutW(hdc, x, y, display_str, len);
459
460 if (!(dwFlags & DT_HIDEPREFIX))
461 {
462
463 for (i = 0; i < cString - 1; i++)
464 {
465 if (lpString[i] == PREFIX && lpString[i + 1] != PREFIX)
466 {
467 prefix_offset = i - prefix_count;
468 prefix_count++;
469 }
470 else if (lpString[i] == PREFIX && lpString[i + 1] == PREFIX)
471 {
472 i++;
473 }
474 }
475
477
478 if (prefix_offset != -1)
479 {
480 GetTextExtentPointW(hdc, display_str, prefix_offset, &size);
481 prefix_x = x + size.cx;
482 GetTextExtentPointW(hdc, display_str, prefix_offset + 1, &size);
483 prefix_end = x + size.cx - 1;
485 oldPen = SelectObject(hdc, hpen);
486 MoveToEx(hdc, prefix_x, y + tm.tmAscent + 1, NULL);
487 LineTo(hdc, prefix_end, y + tm.tmAscent + 1);
488 SelectObject(hdc, oldPen);
490 }
491 }
492
493 GetTextExtentPointW(hdc, display_str, len + 1, &size);
494 HeapFree(GetProcessHeap(), 0, display_str);
495
496 return size.cx;
497}
static HPEN hpen
#define L(x)
Definition: resources.c:13
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define iswspace(_c)
Definition: ctype.h:669
#define PREFIX
Definition: font.c:409
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:860
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586
#define DT_NOPREFIX
Definition: winuser.h:537
#define DT_PREFIXONLY
Definition: winuser.h:548
#define DT_HIDEPREFIX
Definition: winuser.h:547

Referenced by DrawTest().