- Minor fixes.
[wine/hacks.git] / objects / text.c
blob76c82d6d0ed13e31aa308a3b962d6bdd3f81464c
1 /*
2 * text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 */
8 #include <string.h>
10 #include "wine/winuser16.h"
11 #include "winbase.h"
12 #include "winuser.h"
13 #include "winerror.h"
14 #include "dc.h"
15 #include "gdi.h"
16 #include "heap.h"
17 #include "debugtools.h"
18 #include "cache.h"
20 DEFAULT_DEBUG_CHANNEL(text);
22 #define TAB 9
23 #define LF 10
24 #define CR 13
25 #define SPACE 32
26 #define PREFIX 38
28 #define SWAP_INT(a,b) { int t = a; a = b; b = t; }
30 static int tabstop = 8;
31 static int tabwidth;
32 static int spacewidth;
33 static int prefix_offset;
35 static const char *TEXT_NextLine( HDC16 hdc, const char *str, int *count,
36 char *dest, int *len, int width, WORD format)
38 /* Return next line of text from a string.
40 * hdc - handle to DC.
41 * str - string to parse into lines.
42 * count - length of str.
43 * dest - destination in which to return line.
44 * len - length of resultant line in dest in chars.
45 * width - maximum width of line in pixels.
46 * format - format type passed to DrawText.
48 * Returns pointer to next char in str after end of the line
49 * or NULL if end of str reached.
52 int i = 0, j = 0, k;
53 int plen = 0;
54 int numspaces;
55 SIZE16 size;
56 int lasttab = 0;
57 int wb_i = 0, wb_j = 0, wb_count = 0;
59 while (*count)
61 switch (str[i])
63 case CR:
64 case LF:
65 if (!(format & DT_SINGLELINE))
67 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
69 (*count)--;
70 i++;
72 i++;
73 *len = j;
74 (*count)--;
75 return (&str[i]);
77 dest[j++] = str[i++];
78 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
79 (format & DT_WORDBREAK))
81 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
82 return NULL;
83 plen += size.cx;
85 break;
87 case PREFIX:
88 if (!(format & DT_NOPREFIX) && *count > 1)
90 if (str[++i] == PREFIX)
91 (*count)--;
92 else {
93 prefix_offset = j;
94 break;
97 dest[j++] = str[i++];
98 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
99 (format & DT_WORDBREAK))
101 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
102 return NULL;
103 plen += size.cx;
105 break;
107 case TAB:
108 if (format & DT_EXPANDTABS)
110 wb_i = ++i;
111 wb_j = j;
112 wb_count = *count;
114 if (!GetTextExtentPoint16(hdc, &dest[lasttab], j - lasttab,
115 &size))
116 return NULL;
118 numspaces = (tabwidth - size.cx) / spacewidth;
119 for (k = 0; k < numspaces; k++)
120 dest[j++] = SPACE;
121 plen += tabwidth - size.cx;
122 lasttab = wb_j + numspaces;
124 else
126 dest[j++] = str[i++];
127 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
128 (format & DT_WORDBREAK))
130 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
131 return NULL;
132 plen += size.cx;
135 break;
137 case SPACE:
138 dest[j++] = str[i++];
139 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
140 (format & DT_WORDBREAK))
142 wb_i = i;
143 wb_j = j - 1;
144 wb_count = *count;
145 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
146 return NULL;
147 plen += size.cx;
149 break;
151 default:
152 dest[j++] = str[i++];
153 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
154 (format & DT_WORDBREAK))
156 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
157 return NULL;
158 plen += size.cx;
162 (*count)--;
163 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
165 if (plen > width)
167 if (format & DT_WORDBREAK)
169 if (wb_j)
171 *len = wb_j;
172 *count = wb_count - 1;
173 return (&str[wb_i]);
176 else
178 *len = j;
179 return (&str[i]);
185 *len = j;
186 return NULL;
190 /***********************************************************************
191 * DrawText16 (USER.85)
193 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
194 LPRECT16 rect, UINT16 flags )
196 SIZE16 size;
197 const char *strPtr;
198 static char line[1024];
199 int len, lh, count=i_count;
200 int prefix_x = 0;
201 int prefix_end = 0;
202 TEXTMETRIC16 tm;
203 int x = rect->left, y = rect->top;
204 int width = rect->right - rect->left;
205 int max_width = 0;
207 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n",
208 debugstr_an (str, count), count,
209 rect->left, rect->top, rect->right, rect->bottom);
211 if (!str) return 0;
212 if (count == -1) count = strlen(str);
213 strPtr = str;
215 GetTextMetrics16(hdc, &tm);
216 if (flags & DT_EXTERNALLEADING)
217 lh = tm.tmHeight + tm.tmExternalLeading;
218 else
219 lh = tm.tmHeight;
221 if (flags & DT_TABSTOP)
222 tabstop = flags >> 8;
224 if (flags & DT_EXPANDTABS)
226 GetTextExtentPoint16(hdc, " ", 1, &size);
227 spacewidth = size.cx;
228 GetTextExtentPoint16(hdc, "o", 1, &size);
229 tabwidth = size.cx * tabstop;
232 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
236 prefix_offset = -1;
237 strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
239 if (prefix_offset != -1)
241 GetTextExtentPoint16(hdc, line, prefix_offset, &size);
242 prefix_x = size.cx;
243 GetTextExtentPoint16(hdc, line, prefix_offset + 1, &size);
244 prefix_end = size.cx - 1;
247 if (!GetTextExtentPoint16(hdc, line, len, &size)) return 0;
248 if (flags & DT_CENTER) x = (rect->left + rect->right -
249 size.cx) / 2;
250 else if (flags & DT_RIGHT) x = rect->right - size.cx;
252 if (flags & DT_SINGLELINE)
254 if (flags & DT_VCENTER) y = rect->top +
255 (rect->bottom - rect->top) / 2 - size.cy / 2;
256 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
258 if (!(flags & DT_CALCRECT))
260 if (!ExtTextOut16(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
261 rect, line, len, NULL )) return 0;
262 if (prefix_offset != -1)
264 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
265 HPEN oldPen = SelectObject( hdc, hpen );
266 MoveTo16(hdc, x + prefix_x, y + tm.tmAscent + 1 );
267 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
268 SelectObject( hdc, oldPen );
269 DeleteObject( hpen );
272 else if (size.cx > max_width)
273 max_width = size.cx;
275 y += lh;
276 if (strPtr)
278 if (!(flags & DT_NOCLIP))
280 if (y > rect->bottom - lh)
281 break;
285 while (strPtr);
286 if (flags & DT_CALCRECT)
288 rect->right = rect->left + max_width;
289 rect->bottom = y;
291 return y - rect->top;
295 /***********************************************************************
296 * DrawText32A (USER32.164)
298 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count,
299 LPRECT rect, UINT flags )
301 RECT16 rect16;
302 INT16 ret;
304 if (!rect)
305 return DrawText16( (HDC16)hdc, str, (INT16)count, NULL, (UINT16)flags);
306 CONV_RECT32TO16( rect, &rect16 );
307 ret = DrawText16( (HDC16)hdc, str, (INT16)count, &rect16, (UINT16)flags );
308 CONV_RECT16TO32( &rect16, rect );
309 return ret;
313 /***********************************************************************
314 * DrawText32W (USER32.167)
316 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
317 LPRECT rect, UINT flags )
319 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
320 INT ret = DrawTextA( hdc, p, count, rect, flags );
321 HeapFree( GetProcessHeap(), 0, p );
322 return ret;
325 /***********************************************************************
326 * DrawTextEx32A (USER32.165)
328 INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
329 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
331 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
332 if(dtp) {
333 FIXME("Ignores params:%d,%d,%d,%d,%d\n",dtp->cbSize,
334 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin,
335 dtp->uiLengthDrawn);
337 return DrawTextA(hdc,str,count,rect,flags);
340 /***********************************************************************
341 * DrawTextEx32W (USER32.166)
343 INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT count,
344 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
346 TRACE("(%d,%p,%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
347 FIXME("ignores extended functionality\n");
348 return DrawTextW(hdc,str,count,rect,flags);
351 /***********************************************************************
352 * ExtTextOut16 (GDI.351)
354 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
355 const RECT16 *lprect, LPCSTR str, UINT16 count,
356 const INT16 *lpDx )
358 BOOL ret;
359 int i;
360 RECT rect32;
361 LPINT lpdx32 = NULL;
363 if (lpDx) lpdx32 = (LPINT)HEAP_xalloc( GetProcessHeap(), 0,
364 sizeof(INT)*count );
365 if (lprect) CONV_RECT16TO32(lprect,&rect32);
366 if (lpdx32) for (i=count;i--;) lpdx32[i]=lpDx[i];
367 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
368 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
369 return ret;
375 /***********************************************************************
376 * ExtTextOutA (GDI32.98)
378 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
379 const RECT *lprect, LPCSTR str, UINT count,
380 const INT *lpDx )
382 /* str need not be \0 terminated but lstrcpynAtoW adds \0 so we allocate one
383 more byte */
384 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, (count+1) * sizeof(WCHAR) );
385 INT ret;
386 lstrcpynAtoW( p, str, count+1 );
387 ret = ExtTextOutW( hdc, x, y, flags, lprect, p, count, lpDx );
388 HeapFree( GetProcessHeap(), 0, p );
389 return ret;
393 /***********************************************************************
394 * ExtTextOutW (GDI32.99)
396 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
397 const RECT *lprect, LPCWSTR str, UINT count,
398 const INT *lpDx )
400 DC * dc = DC_GetDCPtr( hdc );
401 return dc && dc->funcs->pExtTextOut &&
402 dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
406 /***********************************************************************
407 * TextOut16 (GDI.33)
409 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
411 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
415 /***********************************************************************
416 * TextOut32A (GDI32.355)
418 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
420 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
424 /***********************************************************************
425 * TextOut32W (GDI32.356)
427 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
429 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
433 /***********************************************************************
434 * TEXT_GrayString
436 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
437 * heap and we can guarantee that the handles fit in an INT16. We have to
438 * rethink the strategy once the migration to NT handles is complete.
439 * We are going to get a lot of code-duplication once this migration is
440 * completed...
443 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
444 GRAYSTRINGPROC fn, LPARAM lp, INT len,
445 INT x, INT y, INT cx, INT cy,
446 BOOL unicode, BOOL _32bit)
448 HBITMAP hbm, hbmsave;
449 HBRUSH hbsave;
450 HFONT hfsave;
451 HDC memdc = CreateCompatibleDC(hdc);
452 int slen = len;
453 BOOL retval = TRUE;
454 RECT r;
455 COLORREF fg, bg;
457 if(!hdc) return FALSE;
459 if(len == 0)
461 if(unicode)
462 slen = lstrlenW((LPCWSTR)lp);
463 else if(_32bit)
464 slen = lstrlenA((LPCSTR)lp);
465 else
466 slen = lstrlenA((LPCSTR)PTR_SEG_TO_LIN(lp));
469 if((cx == 0 || cy == 0) && slen != -1)
471 SIZE s;
472 if(unicode)
473 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
474 else if(_32bit)
475 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
476 else
477 GetTextExtentPoint32A(hdc, (LPCSTR)PTR_SEG_TO_LIN(lp), slen, &s);
478 if(cx == 0) cx = s.cx;
479 if(cy == 0) cy = s.cy;
482 r.left = r.top = 0;
483 r.right = cx;
484 r.bottom = cy;
486 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
487 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
488 FillRect(memdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
489 SetTextColor(memdc, RGB(255, 255, 255));
490 SetBkColor(memdc, RGB(0, 0, 0));
491 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
493 if(fn)
494 if(_32bit)
495 retval = fn(memdc, lp, slen);
496 else
497 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
498 else
499 if(unicode)
500 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
501 else if(_32bit)
502 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
503 else
504 TextOutA(memdc, 0, 0, (LPCSTR)PTR_SEG_TO_LIN(lp), slen);
506 SelectObject(memdc, hfsave);
509 * Windows doc says that the bitmap isn't grayed when len == -1 and
510 * the callback function returns FALSE. However, testing this on
511 * win95 showed otherwise...
513 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
514 if(retval || len != -1)
515 #endif
517 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
518 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
519 SelectObject(memdc, hbsave);
522 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
523 fg = SetTextColor(hdc, RGB(0, 0, 0));
524 bg = SetBkColor(hdc, RGB(255, 255, 255));
525 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
526 SetTextColor(hdc, fg);
527 SetBkColor(hdc, bg);
528 if(hb) SelectObject(hdc, hbsave);
530 SelectObject(memdc, hbmsave);
531 DeleteObject(hbm);
532 DeleteDC(memdc);
533 return retval;
537 /***********************************************************************
538 * GrayString16 (USER.185)
540 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
541 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
542 INT16 cx, INT16 cy )
544 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch, x, y, cx, cy, FALSE, FALSE);
548 /***********************************************************************
549 * GrayString32A (USER32.315)
551 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
552 LPARAM lParam, INT cch, INT x, INT y,
553 INT cx, INT cy )
555 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, FALSE, TRUE);
559 /***********************************************************************
560 * GrayString32W (USER32.316)
562 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
563 LPARAM lParam, INT cch, INT x, INT y,
564 INT cx, INT cy )
566 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, TRUE, TRUE);
570 /***********************************************************************
571 * TEXT_TabbedTextOut
573 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
574 * Note: this doesn't work too well for text-alignment modes other
575 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
577 LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
578 INT count, INT cTabStops, const INT16 *lpTabPos16,
579 const INT *lpTabPos32, INT nTabOrg,
580 BOOL fDisplayText )
582 INT defWidth;
583 DWORD extent = 0;
584 int i, tabPos = x;
585 int start = x;
587 if (cTabStops == 1)
589 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
590 cTabStops = 0;
592 else
594 TEXTMETRIC16 tm;
595 GetTextMetrics16( hdc, &tm );
596 defWidth = 8 * tm.tmAveCharWidth;
599 while (count > 0)
601 for (i = 0; i < count; i++)
602 if (lpstr[i] == '\t') break;
603 extent = GetTextExtent16( hdc, lpstr, i );
604 if (lpTabPos32)
606 while ((cTabStops > 0) &&
607 (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
609 lpTabPos32++;
610 cTabStops--;
613 else
615 while ((cTabStops > 0) &&
616 (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
618 lpTabPos16++;
619 cTabStops--;
622 if (i == count)
623 tabPos = x + LOWORD(extent);
624 else if (cTabStops > 0)
625 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
626 else
627 tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
628 if (fDisplayText)
630 RECT r;
631 SetRect( &r, x, y, tabPos, y+HIWORD(extent) );
632 ExtTextOutA( hdc, x, y,
633 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
634 &r, lpstr, i, NULL );
636 x = tabPos;
637 count -= i+1;
638 lpstr += i+1;
640 return MAKELONG(tabPos - start, HIWORD(extent));
644 /***********************************************************************
645 * TabbedTextOut16 (USER.196)
647 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
648 INT16 count, INT16 cTabStops,
649 const INT16 *lpTabPos, INT16 nTabOrg )
651 TRACE("%04x %d,%d '%.*s' %d\n",
652 hdc, x, y, count, lpstr, count );
653 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
654 lpTabPos, NULL, nTabOrg, TRUE );
658 /***********************************************************************
659 * TabbedTextOut32A (USER32.542)
661 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr,
662 INT count, INT cTabStops,
663 const INT *lpTabPos, INT nTabOrg )
665 TRACE("%04x %d,%d '%.*s' %d\n",
666 hdc, x, y, count, lpstr, count );
667 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
668 NULL, lpTabPos, nTabOrg, TRUE );
672 /***********************************************************************
673 * TabbedTextOut32W (USER32.543)
675 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str,
676 INT count, INT cTabStops,
677 const INT *lpTabPos, INT nTabOrg )
679 LONG ret;
680 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
681 lstrcpynWtoA( p, str, count + 1 );
682 ret = TabbedTextOutA( hdc, x, y, p, count, cTabStops,
683 lpTabPos, nTabOrg );
684 HeapFree( GetProcessHeap(), 0, p );
685 return ret;
689 /***********************************************************************
690 * GetTabbedTextExtent16 (USER.197)
692 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
693 INT16 cTabStops, const INT16 *lpTabPos )
695 TRACE("%04x '%.*s' %d\n",
696 hdc, count, lpstr, count );
697 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
698 lpTabPos, NULL, 0, FALSE );
702 /***********************************************************************
703 * GetTabbedTextExtent32A (USER32.293)
705 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
706 INT cTabStops, const INT *lpTabPos )
708 TRACE("%04x '%.*s' %d\n",
709 hdc, count, lpstr, count );
710 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
711 NULL, lpTabPos, 0, FALSE );
715 /***********************************************************************
716 * GetTabbedTextExtent32W (USER32.294)
718 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
719 INT cTabStops, const INT *lpTabPos )
721 LONG ret;
722 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
723 lstrcpynWtoA( p, lpstr, count + 1 );
724 ret = GetTabbedTextExtentA( hdc, p, count, cTabStops, lpTabPos );
725 HeapFree( GetProcessHeap(), 0, p );
726 return ret;
729 /***********************************************************************
730 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
732 * NOTES
733 * Should it return a UINT32 instead of an INT32?
734 * => YES, as GetTextCharsetInfo returns UINT32
736 * RETURNS
737 * Success: Character set identifier
738 * Failure: DEFAULT_CHARSET
740 UINT WINAPI GetTextCharset(
741 HDC hdc) /* [in] Handle to device context */
743 /* MSDN docs say this is equivalent */
744 return GetTextCharsetInfo(hdc, NULL, 0);
747 /***********************************************************************
748 * GetTextCharset16 [GDI.612]
750 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
752 return (UINT16)GetTextCharset(hdc);
755 /***********************************************************************
756 * GetTextCharsetInfo [GDI32.381] Gets character set for font
758 * NOTES
759 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
760 * Should it return a UINT32 instead of an INT32?
761 * => YES and YES, from win32.hlp from Borland
763 * RETURNS
764 * Success: Character set identifier
765 * Failure: DEFAULT_CHARSET
767 UINT WINAPI GetTextCharsetInfo(
768 HDC hdc, /* [in] Handle to device context */
769 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
770 DWORD flags) /* [in] Reserved - must be 0 */
772 HGDIOBJ hFont;
773 UINT charSet = DEFAULT_CHARSET;
774 LOGFONTW lf;
775 CHARSETINFO csinfo;
777 hFont = GetCurrentObject(hdc, OBJ_FONT);
778 if (hFont == 0)
779 return(DEFAULT_CHARSET);
780 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
781 charSet = lf.lfCharSet;
783 if (fs != NULL) {
784 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
785 return (DEFAULT_CHARSET);
786 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
788 return charSet;
791 /***********************************************************************
792 * PolyTextOutA [GDI.402] Draw several Strings
794 BOOL WINAPI PolyTextOutA (
795 HDC hdc, /* Handle to device context */
796 PPOLYTEXTA pptxt, /* array of strings */
797 INT cStrings /* Number of strings in array */
800 FIXME("stub!\n");
801 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
802 return 0;
807 /***********************************************************************
808 * PolyTextOutW [GDI.403] Draw several Strings
810 BOOL WINAPI PolyTextOutW (
811 HDC hdc, /* Handle to device context */
812 PPOLYTEXTW pptxt, /* array of strings */
813 INT cStrings /* Number of strings in array */
816 FIXME("stub!\n");
817 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
818 return 0;