Murali Pattathe
[wine/multimedia.git] / objects / text.c
blob3c4714b2b7029a39586f6f14625fd7d0b6fe7079
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"
19 #include "debugstr.h"
21 DEFAULT_DEBUG_CHANNEL(text)
23 #define TAB 9
24 #define LF 10
25 #define CR 13
26 #define SPACE 32
27 #define PREFIX 38
29 #define SWAP_INT(a,b) { int t = a; a = b; b = t; }
31 static int tabstop = 8;
32 static int tabwidth;
33 static int spacewidth;
34 static int prefix_offset;
36 static const char *TEXT_NextLine( HDC16 hdc, const char *str, int *count,
37 char *dest, int *len, int width, WORD format)
39 /* Return next line of text from a string.
41 * hdc - handle to DC.
42 * str - string to parse into lines.
43 * count - length of str.
44 * dest - destination in which to return line.
45 * len - length of resultant line in dest in chars.
46 * width - maximum width of line in pixels.
47 * format - format type passed to DrawText.
49 * Returns pointer to next char in str after end of the line
50 * or NULL if end of str reached.
53 int i = 0, j = 0, k;
54 int plen = 0;
55 int numspaces;
56 SIZE16 size;
57 int lasttab = 0;
58 int wb_i = 0, wb_j = 0, wb_count = 0;
60 while (*count)
62 switch (str[i])
64 case CR:
65 case LF:
66 if (!(format & DT_SINGLELINE))
68 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
70 (*count)--;
71 i++;
73 i++;
74 *len = j;
75 (*count)--;
76 return (&str[i]);
78 dest[j++] = str[i++];
79 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
80 (format & DT_WORDBREAK))
82 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
83 return NULL;
84 plen += size.cx;
86 break;
88 case PREFIX:
89 if (!(format & DT_NOPREFIX) && *count > 1)
91 if (str[++i] == PREFIX)
92 (*count)--;
93 else {
94 prefix_offset = j;
95 break;
98 dest[j++] = str[i++];
99 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
100 (format & DT_WORDBREAK))
102 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
103 return NULL;
104 plen += size.cx;
106 break;
108 case TAB:
109 if (format & DT_EXPANDTABS)
111 wb_i = ++i;
112 wb_j = j;
113 wb_count = *count;
115 if (!GetTextExtentPoint16(hdc, &dest[lasttab], j - lasttab,
116 &size))
117 return NULL;
119 numspaces = (tabwidth - size.cx) / spacewidth;
120 for (k = 0; k < numspaces; k++)
121 dest[j++] = SPACE;
122 plen += tabwidth - size.cx;
123 lasttab = wb_j + numspaces;
125 else
127 dest[j++] = str[i++];
128 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
129 (format & DT_WORDBREAK))
131 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
132 return NULL;
133 plen += size.cx;
136 break;
138 case SPACE:
139 dest[j++] = str[i++];
140 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
141 (format & DT_WORDBREAK))
143 wb_i = i;
144 wb_j = j - 1;
145 wb_count = *count;
146 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
147 return NULL;
148 plen += size.cx;
150 break;
152 default:
153 dest[j++] = str[i++];
154 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
155 (format & DT_WORDBREAK))
157 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
158 return NULL;
159 plen += size.cx;
163 (*count)--;
164 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
166 if (plen > width)
168 if (format & DT_WORDBREAK)
170 if (wb_j)
172 *len = wb_j;
173 *count = wb_count - 1;
174 return (&str[wb_i]);
177 else
179 *len = j;
180 return (&str[i]);
186 *len = j;
187 return NULL;
191 /***********************************************************************
192 * DrawText16 (USER.85)
194 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
195 LPRECT16 rect, UINT16 flags )
197 SIZE16 size;
198 const char *strPtr;
199 static char line[1024];
200 int len, lh, count=i_count;
201 int prefix_x = 0;
202 int prefix_end = 0;
203 TEXTMETRIC16 tm;
204 int x = rect->left, y = rect->top;
205 int width = rect->right - rect->left;
206 int max_width = 0;
208 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n",
209 debugstr_an (str, count), count,
210 rect->left, rect->top, rect->right, rect->bottom);
212 if (!str) return 0;
213 if (count == -1) count = strlen(str);
214 strPtr = str;
216 GetTextMetrics16(hdc, &tm);
217 if (flags & DT_EXTERNALLEADING)
218 lh = tm.tmHeight + tm.tmExternalLeading;
219 else
220 lh = tm.tmHeight;
222 if (flags & DT_TABSTOP)
223 tabstop = flags >> 8;
225 if (flags & DT_EXPANDTABS)
227 GetTextExtentPoint16(hdc, " ", 1, &size);
228 spacewidth = size.cx;
229 GetTextExtentPoint16(hdc, "o", 1, &size);
230 tabwidth = size.cx * tabstop;
233 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
237 prefix_offset = -1;
238 strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
240 if (prefix_offset != -1)
242 GetTextExtentPoint16(hdc, line, prefix_offset, &size);
243 prefix_x = size.cx;
244 GetTextExtentPoint16(hdc, line, prefix_offset + 1, &size);
245 prefix_end = size.cx - 1;
248 if (!GetTextExtentPoint16(hdc, line, len, &size)) return 0;
249 if (flags & DT_CENTER) x = (rect->left + rect->right -
250 size.cx) / 2;
251 else if (flags & DT_RIGHT) x = rect->right - size.cx;
253 if (flags & DT_SINGLELINE)
255 if (flags & DT_VCENTER) y = rect->top +
256 (rect->bottom - rect->top) / 2 - size.cy / 2;
257 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
259 if (!(flags & DT_CALCRECT))
261 if (!ExtTextOut16(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
262 rect, line, len, NULL )) return 0;
263 if (prefix_offset != -1)
265 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
266 HPEN oldPen = SelectObject( hdc, hpen );
267 MoveTo16(hdc, x + prefix_x, y + tm.tmAscent + 1 );
268 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
269 SelectObject( hdc, oldPen );
270 DeleteObject( hpen );
273 else if (size.cx > max_width)
274 max_width = size.cx;
276 y += lh;
277 if (strPtr)
279 if (!(flags & DT_NOCLIP))
281 if (y > rect->bottom - lh)
282 break;
286 while (strPtr);
287 if (flags & DT_CALCRECT)
289 rect->right = rect->left + max_width;
290 rect->bottom = y;
292 return y - rect->top;
296 /***********************************************************************
297 * DrawText32A (USER32.164)
299 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count,
300 LPRECT rect, UINT flags )
302 RECT16 rect16;
303 INT16 ret;
305 if (!rect)
306 return DrawText16( (HDC16)hdc, str, (INT16)count, NULL, (UINT16)flags);
307 CONV_RECT32TO16( rect, &rect16 );
308 ret = DrawText16( (HDC16)hdc, str, (INT16)count, &rect16, (UINT16)flags );
309 CONV_RECT16TO32( &rect16, rect );
310 return ret;
314 /***********************************************************************
315 * DrawText32W (USER32.167)
317 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
318 LPRECT rect, UINT flags )
320 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
321 INT ret = DrawTextA( hdc, p, count, rect, flags );
322 HeapFree( GetProcessHeap(), 0, p );
323 return ret;
326 /***********************************************************************
327 * DrawTextEx32A (USER32.165)
329 INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
330 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
332 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
333 if(dtp) {
334 FIXME("Ignores params:%d,%d,%d,%d,%d\n",dtp->cbSize,
335 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin,
336 dtp->uiLengthDrawn);
338 return DrawTextA(hdc,str,count,rect,flags);
341 /***********************************************************************
342 * DrawTextEx32W (USER32.166)
344 INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT count,
345 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
347 TRACE("(%d,%p,%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
348 FIXME("ignores extended functionality\n");
349 return DrawTextW(hdc,str,count,rect,flags);
352 /***********************************************************************
353 * ExtTextOut16 (GDI.351)
355 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
356 const RECT16 *lprect, LPCSTR str, UINT16 count,
357 const INT16 *lpDx )
359 BOOL ret;
360 int i;
361 RECT rect32;
362 LPINT lpdx32 = NULL;
364 if (lpDx) lpdx32 = (LPINT)HEAP_xalloc( GetProcessHeap(), 0,
365 sizeof(INT)*count );
366 if (lprect) CONV_RECT16TO32(lprect,&rect32);
367 if (lpdx32) for (i=count;i--;) lpdx32[i]=lpDx[i];
368 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
369 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
370 return ret;
376 /***********************************************************************
377 * ExtTextOut32A (GDI32.98)
379 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
380 const RECT *lprect, LPCSTR str, UINT count,
381 const INT *lpDx )
383 DC * dc = DC_GetDCPtr( hdc );
384 return dc && dc->funcs->pExtTextOut &&
385 dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
389 /***********************************************************************
390 * ExtTextOut32W (GDI32.99)
392 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
393 const RECT *lprect, LPCWSTR str, UINT count,
394 const INT *lpDx )
396 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
397 INT ret = ExtTextOutA( hdc, x, y, flags, lprect, p, count, lpDx );
398 HeapFree( GetProcessHeap(), 0, p );
399 return ret;
403 /***********************************************************************
404 * TextOut16 (GDI.33)
406 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
408 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
412 /***********************************************************************
413 * TextOut32A (GDI32.355)
415 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
417 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
421 /***********************************************************************
422 * TextOut32W (GDI32.356)
424 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
426 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
430 /***********************************************************************
431 * TEXT_GrayString
433 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
434 * heap and we can guarantee that the handles fit in an INT16. We have to
435 * rethink the strategy once the migration to NT handles is complete.
436 * We are going to get a lot of code-duplication once this migration is
437 * completed...
440 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
441 GRAYSTRINGPROC fn, LPARAM lp, INT len,
442 INT x, INT y, INT cx, INT cy,
443 BOOL unicode, BOOL _32bit)
445 HBITMAP hbm, hbmsave;
446 HBRUSH hbsave;
447 HFONT hfsave;
448 HDC memdc = CreateCompatibleDC(hdc);
449 int slen = len;
450 BOOL retval = TRUE;
451 RECT r;
452 COLORREF fg, bg;
454 if(!hdc) return FALSE;
456 if(len == 0)
458 if(unicode)
459 slen = lstrlenW((LPCWSTR)lp);
460 else if(_32bit)
461 slen = lstrlenA((LPCSTR)lp);
462 else
463 slen = lstrlenA((LPCSTR)PTR_SEG_TO_LIN(lp));
466 if((cx == 0 || cy == 0) && slen != -1)
468 SIZE s;
469 if(unicode)
470 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
471 else if(_32bit)
472 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
473 else
474 GetTextExtentPoint32A(hdc, (LPCSTR)PTR_SEG_TO_LIN(lp), slen, &s);
475 if(cx == 0) cx = s.cx;
476 if(cy == 0) cy = s.cy;
479 r.left = r.top = 0;
480 r.right = cx;
481 r.bottom = cy;
483 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
484 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
485 FillRect(memdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
486 SetTextColor(memdc, RGB(255, 255, 255));
487 SetBkColor(memdc, RGB(0, 0, 0));
488 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
490 if(fn)
491 if(_32bit)
492 retval = fn(memdc, lp, slen);
493 else
494 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
495 else
496 if(unicode)
497 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
498 else if(_32bit)
499 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
500 else
501 TextOutA(memdc, 0, 0, (LPCSTR)PTR_SEG_TO_LIN(lp), slen);
503 SelectObject(memdc, hfsave);
506 * Windows doc says that the bitmap isn't grayed when len == -1 and
507 * the callback function returns FALSE. However, testing this on
508 * win95 showed otherwise...
510 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
511 if(retval || len != -1)
512 #endif
514 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
515 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
516 SelectObject(memdc, hbsave);
519 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
520 fg = SetTextColor(hdc, RGB(0, 0, 0));
521 bg = SetBkColor(hdc, RGB(255, 255, 255));
522 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
523 SetTextColor(hdc, fg);
524 SetBkColor(hdc, bg);
525 if(hb) SelectObject(hdc, hbsave);
527 SelectObject(memdc, hbmsave);
528 DeleteObject(hbm);
529 DeleteDC(memdc);
530 return retval;
534 /***********************************************************************
535 * GrayString16 (USER.185)
537 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
538 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
539 INT16 cx, INT16 cy )
541 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch, x, y, cx, cy, FALSE, FALSE);
545 /***********************************************************************
546 * GrayString32A (USER32.315)
548 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
549 LPARAM lParam, INT cch, INT x, INT y,
550 INT cx, INT cy )
552 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, FALSE, TRUE);
556 /***********************************************************************
557 * GrayString32W (USER32.316)
559 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
560 LPARAM lParam, INT cch, INT x, INT y,
561 INT cx, INT cy )
563 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, TRUE, TRUE);
567 /***********************************************************************
568 * TEXT_TabbedTextOut
570 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
571 * Note: this doesn't work too well for text-alignment modes other
572 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
574 LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
575 INT count, INT cTabStops, const INT16 *lpTabPos16,
576 const INT *lpTabPos32, INT nTabOrg,
577 BOOL fDisplayText )
579 INT defWidth;
580 DWORD extent = 0;
581 int i, tabPos = x;
582 int start = x;
584 if (cTabStops == 1)
586 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
587 cTabStops = 0;
589 else
591 TEXTMETRIC16 tm;
592 GetTextMetrics16( hdc, &tm );
593 defWidth = 8 * tm.tmAveCharWidth;
596 while (count > 0)
598 for (i = 0; i < count; i++)
599 if (lpstr[i] == '\t') break;
600 extent = GetTextExtent16( hdc, lpstr, i );
601 if (lpTabPos32)
603 while ((cTabStops > 0) &&
604 (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
606 lpTabPos32++;
607 cTabStops--;
610 else
612 while ((cTabStops > 0) &&
613 (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
615 lpTabPos16++;
616 cTabStops--;
619 if (i == count)
620 tabPos = x + LOWORD(extent);
621 else if (cTabStops > 0)
622 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
623 else
624 tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
625 if (fDisplayText)
627 RECT r;
628 SetRect( &r, x, y, tabPos, y+HIWORD(extent) );
629 ExtTextOutA( hdc, x, y,
630 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
631 &r, lpstr, i, NULL );
633 x = tabPos;
634 count -= i+1;
635 lpstr += i+1;
637 return MAKELONG(tabPos - start, HIWORD(extent));
641 /***********************************************************************
642 * TabbedTextOut16 (USER.196)
644 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
645 INT16 count, INT16 cTabStops,
646 const INT16 *lpTabPos, INT16 nTabOrg )
648 TRACE("%04x %d,%d '%.*s' %d\n",
649 hdc, x, y, count, lpstr, count );
650 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
651 lpTabPos, NULL, nTabOrg, TRUE );
655 /***********************************************************************
656 * TabbedTextOut32A (USER32.542)
658 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr,
659 INT count, INT cTabStops,
660 const INT *lpTabPos, INT nTabOrg )
662 TRACE("%04x %d,%d '%.*s' %d\n",
663 hdc, x, y, count, lpstr, count );
664 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
665 NULL, lpTabPos, nTabOrg, TRUE );
669 /***********************************************************************
670 * TabbedTextOut32W (USER32.543)
672 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str,
673 INT count, INT cTabStops,
674 const INT *lpTabPos, INT nTabOrg )
676 LONG ret;
677 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
678 lstrcpynWtoA( p, str, count + 1 );
679 ret = TabbedTextOutA( hdc, x, y, p, count, cTabStops,
680 lpTabPos, nTabOrg );
681 HeapFree( GetProcessHeap(), 0, p );
682 return ret;
686 /***********************************************************************
687 * GetTabbedTextExtent16 (USER.197)
689 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
690 INT16 cTabStops, const INT16 *lpTabPos )
692 TRACE("%04x '%.*s' %d\n",
693 hdc, count, lpstr, count );
694 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
695 lpTabPos, NULL, 0, FALSE );
699 /***********************************************************************
700 * GetTabbedTextExtent32A (USER32.293)
702 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
703 INT cTabStops, const INT *lpTabPos )
705 TRACE("%04x '%.*s' %d\n",
706 hdc, count, lpstr, count );
707 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
708 NULL, lpTabPos, 0, FALSE );
712 /***********************************************************************
713 * GetTabbedTextExtent32W (USER32.294)
715 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
716 INT cTabStops, const INT *lpTabPos )
718 LONG ret;
719 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
720 lstrcpynWtoA( p, lpstr, count + 1 );
721 ret = GetTabbedTextExtentA( hdc, p, count, cTabStops, lpTabPos );
722 HeapFree( GetProcessHeap(), 0, p );
723 return ret;
726 /***********************************************************************
727 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
729 * NOTES
730 * Should it return a UINT32 instead of an INT32?
731 * => YES, as GetTextCharsetInfo returns UINT32
733 * RETURNS
734 * Success: Character set identifier
735 * Failure: DEFAULT_CHARSET
737 UINT WINAPI GetTextCharset(
738 HDC hdc) /* [in] Handle to device context */
740 /* MSDN docs say this is equivalent */
741 return GetTextCharsetInfo(hdc, NULL, 0);
744 /***********************************************************************
745 * GetTextCharset16 [GDI.612]
747 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
749 return (UINT16)GetTextCharset(hdc);
752 /***********************************************************************
753 * GetTextCharsetInfo [GDI32.381] Gets character set for font
755 * NOTES
756 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
757 * Should it return a UINT32 instead of an INT32?
758 * => YES and YES, from win32.hlp from Borland
760 * RETURNS
761 * Success: Character set identifier
762 * Failure: DEFAULT_CHARSET
764 UINT WINAPI GetTextCharsetInfo(
765 HDC hdc, /* [in] Handle to device context */
766 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
767 DWORD flags) /* [in] Reserved - must be 0 */
769 HGDIOBJ hFont;
770 UINT charSet = DEFAULT_CHARSET;
771 LOGFONTW lf;
772 CHARSETINFO csinfo;
774 hFont = GetCurrentObject(hdc, OBJ_FONT);
775 if (hFont == 0)
776 return(DEFAULT_CHARSET);
777 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
778 charSet = lf.lfCharSet;
780 if (fs != NULL) {
781 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
782 return (DEFAULT_CHARSET);
783 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
785 return charSet;
788 /***********************************************************************
789 * PolyTextOutA [GDI.402] Draw several Strings
791 BOOL WINAPI PolyTextOutA (
792 HDC hdc, /* Handle to device context */
793 PPOLYTEXTA pptxt, /* array of strings */
794 INT cStrings /* Number of strings in array */
797 FIXME("stub!\n");
798 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
799 return 0;
804 /***********************************************************************
805 * PolyTextOutW [GDI.403] Draw several Strings
807 BOOL WINAPI PolyTextOutW (
808 HDC hdc, /* Handle to device context */
809 PPOLYTEXTW pptxt, /* array of strings */
810 INT cStrings /* Number of strings in array */
813 FIXME("stub!\n");
814 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
815 return 0;