ReactOS 0.4.15-dev-7934-g1dc8d80
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}
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
& rect
Definition: startmenu.cpp:1413
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
char * LPSTR
Definition: xmlstorage.h:182

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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#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
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
POINT cp
Definition: magnifier.c:59
unsigned int UINT
Definition: ndis.h:50
Definition: time.h:68
int32_t INT
Definition: typedefs.h:58
int ret
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

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:1071

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 1071 of file text.c.

1077{
1078 SIZE size;
1079 const WCHAR *strPtr;
1080 WCHAR *retstr, *p_retstr;
1081 size_t size_retstr;
1083 int len, lh, count=i_count;
1085 int lmargin = 0, rmargin = 0;
1086 int x = rect->left, y = rect->top;
1087 int width = rect->right - rect->left;
1088 int max_width = 0;
1089 int last_line;
1090 int tabwidth /* to keep gcc happy */ = 0;
1091 int prefix_offset;
1092 ellipsis_data ellip;
1093 BOOL invert_y=FALSE;
1094
1095 HRGN hrgn = 0;
1096
1097#ifdef _WIN32K_
1098 TRACE("%S, %d, %08x\n", str, count, flags);
1099#else
1100 TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count,
1102#endif
1103 if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
1104 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
1105
1106 if (!str) return 0;
1107
1108 strPtr = str;
1109
1110 if (flags & DT_SINGLELINE)
1111 flags &= ~DT_WORDBREAK;
1112#ifdef _WIN32K_
1114#else
1116#endif
1118 lh = tm.tmHeight + tm.tmExternalLeading;
1119 else
1120 lh = tm.tmHeight;
1121
1122 if (str[0] && count == 0)
1123 return lh;
1124
1125 if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
1126 return 0;
1127#ifdef _WIN32K_
1129 {
1130 SIZE window_ext, viewport_ext;
1131 GreGetWindowExtEx(hdc, &window_ext);
1132 GreGetViewportExtEx(hdc, &viewport_ext);
1133 if ((window_ext.cy > 0) != (viewport_ext.cy > 0))
1134 invert_y = TRUE;
1135 }
1136#else
1138 {
1139 SIZE window_ext, viewport_ext;
1140 GetWindowExtEx(hdc, &window_ext);
1141 GetViewportExtEx(hdc, &viewport_ext);
1142 if ((window_ext.cy > 0) != (viewport_ext.cy > 0))
1143 invert_y = TRUE;
1144 }
1145#endif
1146 if (count == -1)
1147 {
1148#ifdef _WIN32K_
1149 count = wcslen(str);
1150#else
1151 count = strlenW(str);
1152#endif
1153 if (count == 0)
1154 {
1155 if( flags & DT_CALCRECT)
1156 {
1157 rect->right = rect->left;
1158 if( flags & DT_SINGLELINE)
1159 rect->bottom = rect->top + (invert_y ? -lh : lh);
1160 else
1161 rect->bottom = rect->top;
1162 }
1163 return lh;
1164 }
1165 }
1166
1167 if (dtp)
1168 {
1169 lmargin = dtp->iLeftMargin;
1170 rmargin = dtp->iRightMargin;
1171 if (!(flags & (DT_CENTER | DT_RIGHT)))
1172 x += lmargin;
1173 dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
1174 }
1175
1176 if (flags & DT_EXPANDTABS)
1177 {
1178 int tabstop = ((flags & DT_TABSTOP) && dtp && dtp->iTabLength) ? dtp->iTabLength : 8;
1179 tabwidth = tm.tmAveCharWidth * tabstop;
1180 }
1181
1182 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
1183#ifndef _WIN32K_
1184 if (!(flags & DT_NOCLIP) )
1185 {
1186 int hasClip;
1187 hrgn = CreateRectRgn(0,0,0,0);
1188 if (hrgn)
1189 {
1190 hasClip = GetClipRgn(hdc, hrgn);
1191 // If the region to be retrieved is NULL, the return value is 0.
1192 if (hasClip != 1)
1193 {
1195 hrgn = NULL;
1196 }
1197 IntersectClipRect(hdc, rect->left, rect->top, rect->right, rect->bottom);
1198 }
1199 }
1200#else
1201 if (!(flags & DT_NOCLIP) )
1202 {
1203 int hasClip;
1204 hrgn = NtGdiCreateRectRgn(0,0,0,0);
1205 if (hrgn)
1206 {
1207 hasClip = NtGdiGetRandomRgn(hdc, hrgn, CLIPRGN);
1208 if (hasClip != 1)
1209 {
1211 hrgn = NULL;
1212 }
1213 NtGdiIntersectClipRect(hdc, rect->left, rect->top, rect->right, rect->bottom);
1214 }
1215 }
1216#endif
1217 if (flags & DT_MODIFYSTRING)
1218 {
1219 size_retstr = (count + 4) * sizeof (WCHAR);
1220#ifdef _WIN32K_
1221 retstr = ExAllocatePoolWithTag(PagedPool, size_retstr, USERTAG_RTL);
1222#else
1223 retstr = HeapAlloc(GetProcessHeap(), 0, size_retstr);
1224#endif
1225 if (!retstr) return 0;
1226 memcpy (retstr, str, size_retstr);
1227 }
1228 else
1229 {
1230 size_retstr = 0;
1231 retstr = NULL;
1232 }
1233 p_retstr = retstr;
1234
1235 do
1236 {
1237 len = sizeof(line)/sizeof(line[0]);
1238 if (invert_y)
1239 last_line = !(flags & DT_NOCLIP) && y - ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) < rect->bottom;
1240 else
1241 last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
1242 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags, &size, last_line, &p_retstr, tabwidth, &prefix_offset, &ellip);
1243
1244#ifdef __REACTOS__
1245 if (flags & DT_CENTER)
1246 {
1247 if (((rect->right - rect->left) < size.cx) && (flags & DT_CALCRECT))
1248 {
1249 x = rect->left + size.cx;
1250 }
1251 else
1252 {
1253 x = (rect->left + rect->right - size.cx) / 2;
1254 }
1255 }
1256#else
1257 if (flags & DT_CENTER) x = (rect->left + rect->right -
1258 size.cx) / 2;
1259#endif
1260 else if (flags & DT_RIGHT) x = rect->right - size.cx;
1261
1262 if (flags & DT_SINGLELINE)
1263 {
1264#ifdef __REACTOS__
1265 if (flags & DT_VCENTER) y = rect->top +
1266 (rect->bottom - rect->top + (invert_y ? size.cy : -size.cy)) / 2;
1267 else if (flags & DT_BOTTOM)
1268 y = rect->bottom + (invert_y ? size.cy : -size.cy);
1269#else
1270 if (flags & DT_VCENTER) y = rect->top +
1271 (rect->bottom - rect->top) / 2 - size.cy / 2;
1272 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
1273#endif
1274 }
1275
1276 if (!(flags & DT_CALCRECT))
1277 {
1278 const WCHAR *str = line;
1279 int xseg = x;
1280 while (len)
1281 {
1282 int len_seg;
1283 SIZE size;
1284 if ((flags & DT_EXPANDTABS))
1285 {
1286 const WCHAR *p;
1287 p = str; while (p < str+len && *p != TAB) p++;
1288 len_seg = p - str;
1289 if (len_seg != len &&
1290#ifdef _WIN32K_
1291 !GreGetTextExtentW(hdc, str, len_seg, &size, 0))
1292#else
1293 !GetTextExtentPointW(hdc, str, len_seg, &size))
1294#endif
1295 {
1296#ifdef _WIN32K_
1298#else
1299 HeapFree (GetProcessHeap(), 0, retstr);
1300#endif
1301 return 0;
1302 }
1303 }
1304 else
1305 len_seg = len;
1306#ifdef _WIN32K_
1307 if (!UserExtTextOutW( hdc, xseg, y,
1308 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
1309 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
1310 rect, str, len_seg))
1311#else
1312 if (!ExtTextOutW( hdc, xseg, y,
1313 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
1314 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
1315 rect, str, len_seg, NULL ))
1316#endif
1317 {
1318#ifdef _WIN32K_
1320#else
1321 HeapFree (GetProcessHeap(), 0, retstr);
1322#endif
1323 return 0;
1324 }
1325 if (prefix_offset != -1 && prefix_offset < len_seg)
1326 {
1327 TEXT_DrawUnderscore (hdc, xseg, y + tm.tmAscent + 1, str, prefix_offset, (flags & DT_NOCLIP) ? NULL : rect);
1328 }
1329 len -= len_seg;
1330 str += len_seg;
1331 if (len)
1332 {
1333 assert ((flags & DT_EXPANDTABS) && *str == TAB);
1334 len--; str++;
1335 xseg += ((size.cx/tabwidth)+1)*tabwidth;
1336 if (prefix_offset != -1)
1337 {
1338 if (prefix_offset < len_seg)
1339 {
1340 /* We have just drawn an underscore; we ought to
1341 * figure out where the next one is. I am going
1342 * to leave it for now until I have a better model
1343 * for the line, which will make reprefixing easier.
1344 * This is where ellip would be used.
1345 */
1346 prefix_offset = -1;
1347 }
1348 else
1349 prefix_offset -= len_seg;
1350 }
1351 }
1352 }
1353 }
1354 else if (size.cx > max_width)
1355 max_width = size.cx;
1356
1357 y += invert_y ? -lh : lh;
1358 if (dtp)
1359 dtp->uiLengthDrawn += len;
1360 }
1361 while (strPtr && !last_line);
1362
1363#ifndef _WIN32K_
1364 if (!(flags & DT_NOCLIP) )
1365 {
1366 SelectClipRgn(hdc, hrgn); // This should be NtGdiExtSelectClipRgn, but due to ReactOS build rules this option is next:
1367 GdiFlush(); // Flush the batch and level up! See CORE-16498.
1368 if (hrgn)
1369 {
1371 }
1372 }
1373#else
1374 if (!(flags & DT_NOCLIP) )
1375 {
1377 if (hrgn)
1378 {
1380 }
1381 }
1382#endif
1383
1384 if (flags & DT_CALCRECT)
1385 {
1386 rect->right = rect->left + max_width;
1387 rect->bottom = y;
1388 if (dtp)
1389 rect->right += lmargin + rmargin;
1390 }
1391 if (retstr)
1392 {
1393 memcpy (str, retstr, size_retstr);
1394#ifdef _WIN32K_
1396#else
1397 HeapFree (GetProcessHeap(), 0, retstr);
1398#endif
1399 }
1400 return y - rect->top;
1401}
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
#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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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:486
__kernel_entry W32KAPI INT APIENTRY NtGdiGetRandomRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iRgn)
#define strlenW(s)
Definition: unicode.h:28
#define TRACE(s)
Definition: solgame.cpp:4
int iRightMargin
Definition: winuser.h:3100
UINT uiLengthDrawn
Definition: winuser.h:3101
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:1158
BOOL FASTCALL GreGetTextExtentW(HDC hDC, LPCWSTR lpwsz, INT cwc, LPSIZE psize, UINT flOpts)
Definition: text.c:78
BOOL WINAPI GreGetTextMetricsW(_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
Definition: text.c:193
#define USERTAG_RTL
Definition: tags.h:270
#define MAX_BUFFER
Definition: text.c:1065
static void TEXT_DrawUnderscore(HDC hdc, int x, int y, const WCHAR *str, int offset, const RECT *rect)
Definition: text.c:894
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:666
#define TAB
Definition: text.c:109
#define assert(e)
Definition: text.c:47
#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}
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ 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:2029
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 */
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
static LPCSTR lpstr
Definition: font.c:51
#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 iswspace(_c)
Definition: ctype.h:669
#define L(x)
Definition: ntvdm.h:50
#define PREFIX
Definition: font.c:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:861
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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().