ReactOS  0.4.14-dev-845-g8381e29
text.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wine/wingdi16.h"
#include "mfdrv/metafiledrv.h"
#include "wine/debug.h"
Include dependency graph for text.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (metafile)
 
static BOOL MFDRV_MetaExtTextOut (PHYSDEV dev, short x, short y, UINT16 flags, const RECT16 *rect, LPCSTR str, short count, const INT16 *lpDx)
 
BOOL MFDRV_ExtTextOut (PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx)
 

Function Documentation

◆ MFDRV_ExtTextOut()

BOOL MFDRV_ExtTextOut ( PHYSDEV  dev,
INT  x,
INT  y,
UINT  flags,
const RECT lprect,
LPCWSTR  str,
UINT  count,
const INT lpDx 
)

Definition at line 75 of file text.c.

77 {
78  RECT16 rect16;
79  LPINT16 lpdx16 = NULL;
80  BOOL ret;
81  unsigned int i, j;
82  LPSTR ascii;
83  DWORD len;
84  CHARSETINFO csi;
85  int charset = GetTextCharset( dev->hdc );
86  UINT cp = CP_ACP;
87 
89  cp = csi.ciACP;
90  else {
91  switch(charset) {
92  case OEM_CHARSET:
93  cp = GetOEMCP();
94  break;
95  case DEFAULT_CHARSET:
96  cp = GetACP();
97  break;
98 
99  case VISCII_CHARSET:
100  case TCVN_CHARSET:
101  case KOI8_CHARSET:
102  case ISO3_CHARSET:
103  case ISO4_CHARSET:
104  case ISO10_CHARSET:
105  case CELTIC_CHARSET:
106  /* FIXME: These have no place here, but because x11drv
107  enumerates fonts with these (made up) charsets some apps
108  might use them and then the FIXME below would become
109  annoying. Now we could pick the intended codepage for
110  each of these, but since it's broken anyway we'll just
111  use CP_ACP and hope it'll go away...
112  */
113  cp = CP_ACP;
114  break;
115 
116 
117  default:
118  FIXME("Can't find codepage for charset %d\n", charset);
119  break;
120  }
121  }
122 
123 
124  TRACE("cp == %d\n", cp);
126  ascii = HeapAlloc(GetProcessHeap(), 0, len);
127  WideCharToMultiByte(cp, 0, str, count, ascii, len, NULL, NULL);
128  TRACE("mapped %s -> %s\n", debugstr_wn(str, count), debugstr_an(ascii, len));
129 
130 
131  if (lprect)
132  {
133  rect16.left = lprect->left;
134  rect16.top = lprect->top;
135  rect16.right = lprect->right;
136  rect16.bottom = lprect->bottom;
137  }
138 
139  if(lpDx) {
140  lpdx16 = HeapAlloc( GetProcessHeap(), 0, sizeof(INT16)*len );
141  for(i = j = 0; i < len; )
142  if(IsDBCSLeadByteEx(cp, ascii[i])) {
143  lpdx16[i++] = lpDx[j++];
144  lpdx16[i++] = 0;
145  } else
146  lpdx16[i++] = lpDx[j++];
147  }
148 
149  ret = MFDRV_MetaExtTextOut(dev,x,y,flags,lprect?&rect16:NULL,ascii,len,lpdx16);
150  HeapFree( GetProcessHeap(), 0, ascii );
151  HeapFree( GetProcessHeap(), 0, lpdx16 );
152  return ret;
153 }
#define ISO10_CHARSET
Definition: wingdi.h:411
#define ULongToPtr(ul)
Definition: basetsd.h:92
CFF_Charset charset
Definition: cffcmap.c:138
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
INT16 * LPINT16
Definition: windef16.h:43
LONG top
Definition: windef.h:307
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
INT16 left
Definition: windef16.h:143
LONG left
Definition: windef.h:306
char * LPSTR
Definition: xmlstorage.h:182
#define DEFAULT_CHARSET
Definition: wingdi.h:383
LONG right
Definition: windef.h:308
#define ISO4_CHARSET
Definition: wingdi.h:410
INT16 right
Definition: windef16.h:145
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2210
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
INT16 bottom
Definition: windef16.h:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetACP(VOID)
Definition: nls.c:2180
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
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define VISCII_CHARSET
Definition: wingdi.h:406
static BOOL MFDRV_MetaExtTextOut(PHYSDEV dev, short x, short y, UINT16 flags, const RECT16 *rect, LPCSTR str, short count, const INT16 *lpDx)
Definition: text.c:36
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define ISO3_CHARSET
Definition: wingdi.h:409
int ret
#define OEM_CHARSET
Definition: wingdi.h:399
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
GLenum GLsizei len
Definition: glext.h:6722
#define CELTIC_CHARSET
Definition: wingdi.h:412
#define debugstr_wn
Definition: kernel32.h:33
unsigned int UINT
Definition: ndis.h:50
INT16 top
Definition: windef16.h:144
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
INT WINAPI GetTextCharset(_In_ HDC hdc)
Definition: text.c:187
POINT cp
Definition: magnifier.c:59
#define KOI8_CHARSET
Definition: wingdi.h:408
LONG bottom
Definition: windef.h:309
#define HeapFree(x, y, z)
Definition: compat.h:402
#define TCI_SRCCHARSET
Definition: wingdi.h:960
#define TCVN_CHARSET
Definition: wingdi.h:407
UINT WINAPI GetOEMCP(VOID)
Definition: nls.c:2195
signed short INT16

◆ MFDRV_MetaExtTextOut()

static BOOL MFDRV_MetaExtTextOut ( PHYSDEV  dev,
short  x,
short  y,
UINT16  flags,
const RECT16 rect,
LPCSTR  str,
short  count,
const INT16 lpDx 
)
static

Definition at line 36 of file text.c.

39 {
40  BOOL ret;
41  DWORD len;
42  METARECORD *mr;
43  BOOL isrect = flags & (ETO_CLIPPED | ETO_OPAQUE);
44 
45  len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
46  + sizeof(UINT16);
47  if (isrect)
48  len += sizeof(RECT16);
49  if (lpDx)
50  len+=count*sizeof(INT16);
51  if (!(mr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len)))
52  return FALSE;
53 
54  mr->rdSize = len / 2;
56  *(mr->rdParm) = y;
57  *(mr->rdParm + 1) = x;
58  *(mr->rdParm + 2) = count;
59  *(mr->rdParm + 3) = flags;
60  if (isrect) memcpy(mr->rdParm + 4, rect, sizeof(RECT16));
61  memcpy(mr->rdParm + (isrect ? 8 : 4), str, count);
62  if (lpDx)
63  memcpy(mr->rdParm + (isrect ? 8 : 4) + ((count + 1) >> 1),lpDx,
64  count*sizeof(INT16));
65  ret = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
66  HeapFree( GetProcessHeap(), 0, mr);
67  return ret;
68 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
WORD rdFunction
Definition: wingdi.h:2345
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct tagMETARECORD METARECORD
DWORD rdSize
Definition: wingdi.h:2344
& rect
Definition: startmenu.cpp:1413
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define ETO_OPAQUE
Definition: wingdi.h:646
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
#define ETO_CLIPPED
Definition: wingdi.h:647
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define META_EXTTEXTOUT
Definition: wingdi.h:258
GLbitfield flags
Definition: glext.h:7161
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
WORD rdParm[1]
Definition: wingdi.h:2346
unsigned short UINT16
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL MFDRV_WriteRecord(PHYSDEV dev, METARECORD *mr, DWORD rlen)
Definition: init.c:475
#define HeapFree(x, y, z)
Definition: compat.h:402
signed short INT16

Referenced by MFDRV_ExtTextOut().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( metafile  )