ReactOS  0.4.15-dev-2354-g9e947e2
font.c File Reference
#include "d3dx9_private.h"
#include "usp10.h"
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  d3dx_glyph
 
struct  d3dx_font
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static int glyph_rb_compare (const void *key, const struct wine_rb_entry *entry)
 
static void glyph_rb_free (struct wine_rb_entry *entry, void *context)
 
static struct d3dx_fontimpl_from_ID3DXFont (ID3DXFont *iface)
 
static HRESULT WINAPI ID3DXFontImpl_QueryInterface (ID3DXFont *iface, REFIID riid, void **out)
 
static ULONG WINAPI ID3DXFontImpl_AddRef (ID3DXFont *iface)
 
static ULONG WINAPI ID3DXFontImpl_Release (ID3DXFont *iface)
 
static HRESULT WINAPI ID3DXFontImpl_GetDevice (ID3DXFont *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI ID3DXFontImpl_GetDescA (ID3DXFont *iface, D3DXFONT_DESCA *desc)
 
static HRESULT WINAPI ID3DXFontImpl_GetDescW (ID3DXFont *iface, D3DXFONT_DESCW *desc)
 
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA (ID3DXFont *iface, TEXTMETRICA *metrics)
 
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW (ID3DXFont *iface, TEXTMETRICW *metrics)
 
static HDC WINAPI ID3DXFontImpl_GetDC (ID3DXFont *iface)
 
static HRESULT WINAPI ID3DXFontImpl_GetGlyphData (ID3DXFont *iface, UINT glyph, IDirect3DTexture9 **texture, RECT *black_box, POINT *cell_inc)
 
static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters (ID3DXFont *iface, UINT first, UINT last)
 
static uint32_t morton_decode (uint32_t x)
 
static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs (ID3DXFont *iface, UINT first, UINT last)
 
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA (ID3DXFont *iface, const char *string, INT count)
 
static HRESULT WINAPI ID3DXFontImpl_PreloadTextW (ID3DXFont *iface, const WCHAR *string, INT count)
 
static INT WINAPI ID3DXFontImpl_DrawTextA (ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
 
static void word_break (HDC hdc, const WCHAR *str, unsigned int *str_len, unsigned int chars_fit, unsigned int *chars_used, SIZE *size)
 
static const WCHARread_line (HDC hdc, const WCHAR *str, unsigned int *count, WCHAR *dest, unsigned int *dest_len, int width, DWORD format, SIZE *size)
 
static int compute_rect (struct d3dx_font *font, const WCHAR *string, unsigned int count, WCHAR *line, RECT *rect, DWORD format)
 
static INT WINAPI ID3DXFontImpl_DrawTextW (ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT in_count, RECT *rect, DWORD format, D3DCOLOR color)
 
static HRESULT WINAPI ID3DXFontImpl_OnLostDevice (ID3DXFont *iface)
 
static HRESULT WINAPI ID3DXFontImpl_OnResetDevice (ID3DXFont *iface)
 
HRESULT WINAPI D3DXCreateFontA (struct IDirect3DDevice9 *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitchandfamily, const char *facename, struct ID3DXFont **font)
 
HRESULT WINAPI D3DXCreateFontW (IDirect3DDevice9 *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitchandfamily, const WCHAR *facename, ID3DXFont **font)
 
HRESULT WINAPI D3DXCreateFontIndirectA (IDirect3DDevice9 *device, const D3DXFONT_DESCA *desc, ID3DXFont **font)
 
HRESULT WINAPI D3DXCreateFontIndirectW (IDirect3DDevice9 *device, const D3DXFONT_DESCW *desc, ID3DXFont **font)
 

Variables

static const ID3DXFontVtbl D3DXFont_Vtbl
 

Function Documentation

◆ compute_rect()

static int compute_rect ( struct d3dx_font font,
const WCHAR string,
unsigned int  count,
WCHAR line,
RECT rect,
DWORD  format 
)
static

Definition at line 598 of file font.c.

600 {
601  int y, lh, width, top = rect->top;
602  int max_width = 0;
603  SIZE size;
604 
605  y = rect->top;
606  lh = font->metrics.tmHeight;
607  width = rect->right - rect->left;
608 
609  while (string)
610  {
611  unsigned int line_len;
612 
613  string = read_line(font->hdc, string, &count, line, &line_len, width, format, &size);
614 
615  if (size.cx > max_width)
616  max_width = size.cx;
617 
618  y += lh;
619  if (!(format & DT_NOCLIP) && (y > rect->bottom))
620  break;
621  }
622 
623  if (format & DT_CENTER)
624  {
625  rect->left += (rect->right - rect->left - max_width) / 2;
626  rect->right = rect->left + max_width;
627  }
628  else if (format & DT_RIGHT)
629  {
630  rect->left = rect->right - max_width;
631  }
632  else
633  {
634  rect->right = rect->left + max_width;
635  }
636 
637  if (format & DT_VCENTER)
638  {
639  rect->top += (rect->bottom - y) / 2;
640  rect->bottom = rect->top + y - top;
641  }
642  else if (format & DT_BOTTOM)
643  {
644  rect->top += rect->bottom - y;
645  }
646  else
647  {
648  rect->bottom = y;
649  }
650 
651  return rect->bottom - top;
652 }
GLint GLint GLsizei width
Definition: gl.h:1546
Definition: mk_font.cpp:20
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DT_RIGHT
Definition: winuser.h:538
& rect
Definition: startmenu.cpp:1413
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: parser.c:48
#define DT_VCENTER
Definition: winuser.h:543
GLsizeiptr size
Definition: glext.h:5919
#define DT_NOCLIP
Definition: winuser.h:536
static const WORD INT INT LPINT LPINT LPSIZE size
Definition: font.c:53
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static const WCHAR * read_line(HDC hdc, const WCHAR *str, unsigned int *count, WCHAR *dest, unsigned int *dest_len, int width, DWORD format, SIZE *size)
Definition: font.c:559
#define DT_CENTER
Definition: winuser.h:527
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
#define DT_BOTTOM
Definition: winuser.h:525

Referenced by ID3DXFontImpl_DrawTextW().

◆ D3DXCreateFontA()

HRESULT WINAPI D3DXCreateFontA ( struct IDirect3DDevice9 *  device,
INT  height,
UINT  width,
UINT  weight,
UINT  miplevels,
BOOL  italic,
DWORD  charset,
DWORD  precision,
DWORD  quality,
DWORD  pitchandfamily,
const char facename,
struct ID3DXFont **  font 
)

Definition at line 844 of file font.c.

847 {
849 
850  if( !device || !font ) return D3DERR_INVALIDCALL;
851 
852  desc.Height=height;
853  desc.Width=width;
854  desc.Weight=weight;
855  desc.MipLevels=miplevels;
856  desc.Italic=italic;
857  desc.CharSet=charset;
858  desc.OutputPrecision=precision;
859  desc.Quality=quality;
860  desc.PitchAndFamily=pitchandfamily;
861  if(facename != NULL) lstrcpyA(desc.FaceName, facename);
862  else desc.FaceName[0] = '\0';
863 
865 }
GLint GLint GLsizei width
Definition: gl.h:1546
CFF_Charset charset
Definition: cffcmap.c:138
Definition: mk_font.cpp:20
#define D3DERR_INVALIDCALL
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT WINAPI D3DXCreateFontIndirectA(IDirect3DDevice9 *device, const D3DXFONT_DESCA *desc, ID3DXFont **font)
Definition: font.c:892
static LPTEXTMETRICW LONG * height
Definition: font.c:42
GLenum GLint GLint * precision
Definition: glext.h:7539
int quality
Definition: jpeglib.h:992
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
weight
Definition: sortkey.c:156
#define NULL
Definition: types.h:112

Referenced by test_ID3DXFont().

◆ D3DXCreateFontIndirectA()

HRESULT WINAPI D3DXCreateFontIndirectA ( IDirect3DDevice9 *  device,
const D3DXFONT_DESCA desc,
ID3DXFont **  font 
)

Definition at line 892 of file font.c.

893 {
894  D3DXFONT_DESCW widedesc;
895 
896  if( !device || !desc || !font ) return D3DERR_INVALIDCALL;
897 
898  /* Copy everything but the last structure member. This requires the
899  two D3DXFONT_DESC structures to be equal until the FaceName member */
900  memcpy(&widedesc, desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName));
901  MultiByteToWideChar(CP_ACP, 0, desc->FaceName, -1, widedesc.FaceName, ARRAY_SIZE(widedesc.FaceName));
902  return D3DXCreateFontIndirectW(device, &widedesc, font);
903 }
Definition: mk_font.cpp:20
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_DESCW *desc, ID3DXFont **font)
Definition: font.c:908
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WCHAR FaceName[LF_FACESIZE]
Definition: d3dx9core.h:122
#define ARRAY_SIZE(a)
Definition: main.h:24
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by D3DXCreateFontA(), and test_ID3DXFont().

◆ D3DXCreateFontIndirectW()

HRESULT WINAPI D3DXCreateFontIndirectW ( IDirect3DDevice9 *  device,
const D3DXFONT_DESCW desc,
ID3DXFont **  font 
)

Definition at line 908 of file font.c.

909 {
911  struct d3dx_font *object;
913  IDirect3D9 *d3d;
914  HRESULT hr;
915 
916  TRACE("(%p, %p, %p)\n", device, desc, font);
917 
918  if( !device || !desc || !font ) return D3DERR_INVALIDCALL;
919 
920  /* the device MUST support D3DFMT_A8R8G8B8 */
925  if (FAILED(hr))
926  {
927  IDirect3D9_Release(d3d);
928  return D3DXERR_INVALIDDATA;
929  }
930  IDirect3D9_Release(d3d);
931 
932  object = heap_alloc_zero(sizeof(*object));
933  if (!object)
934  {
935  *font = NULL;
936  return E_OUTOFMEMORY;
937  }
938  object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl;
939  object->ref = 1;
940  object->device = device;
941  object->desc = *desc;
942 
943  object->hdc = CreateCompatibleDC(NULL);
944  if (!object->hdc)
945  {
946  heap_free(object);
947  return D3DXERR_INVALIDDATA;
948  }
949 
950  object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet,
951  desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName);
952  if (!object->hfont)
953  {
954  DeleteDC(object->hdc);
955  heap_free(object);
956  return D3DXERR_INVALIDDATA;
957  }
958  SelectObject(object->hdc, object->hfont);
959 
960  wine_rb_init(&object->glyph_tree, glyph_rb_compare);
961 
962  if (!GetTextMetricsW(object->hdc, &object->metrics))
963  {
964  DeleteObject(object->hfont);
965  DeleteDC(object->hdc);
966  heap_free(object);
967  return D3DXERR_INVALIDDATA;
968  }
969 
970  object->glyph_size = make_pow2(object->metrics.tmHeight);
971 
972  object->texture_size = object->glyph_size;
973  if (object->glyph_size < 256)
974  object->texture_size = min(256, object->texture_size * 16);
975 
976  object->glyphs_per_texture = object->texture_size * object->texture_size
977  / (object->glyph_size * object->glyph_size);
978  object->texture_pos = object->glyphs_per_texture;
979 
981  *font = &object->ID3DXFont_iface;
982 
983  return D3D_OK;
984 }
#define IDirect3D9_CheckDeviceFormat(p, a, b, c, d, e, f)
Definition: d3d9.h:229
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
coclass MSXML2::XSLTemplate40 object
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DDevice9_GetCreationParameters(p, a)
Definition: d3d9.h:1516
Definition: mk_font.cpp:20
#define D3DERR_INVALIDCALL
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
Definition: font.c:41
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static int glyph_rb_compare(const void *key, const struct wine_rb_entry *entry)
Definition: font.c:61
FxDevice * device
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
#define IDirect3DDevice9_GetDisplayMode(p, a, b)
Definition: d3d9.h:1515
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
#define IDirect3DDevice9_GetDirect3D(p, a)
Definition: d3d9.h:1513
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
static const ID3DXFontVtbl D3DXFont_Vtbl
Definition: font.c:820
static uint32_t make_pow2(uint32_t num)
GLenum mode
Definition: glext.h:6217
#define D3D_OK
Definition: d3d.h:106
BOOL WINAPI DeleteDC(_In_ HDC)
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
HFONT WINAPI CreateFontW(int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, DWORD fnItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet, DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality, DWORD fdwPitchAndFamily, LPCWSTR lpszFace)
Definition: font.c:1894

Referenced by D3DXCreateFontIndirectA(), and D3DXCreateFontW().

◆ D3DXCreateFontW()

HRESULT WINAPI D3DXCreateFontW ( IDirect3DDevice9 *  device,
INT  height,
UINT  width,
UINT  weight,
UINT  miplevels,
BOOL  italic,
DWORD  charset,
DWORD  precision,
DWORD  quality,
DWORD  pitchandfamily,
const WCHAR facename,
ID3DXFont **  font 
)

Definition at line 867 of file font.c.

869 {
871 
872  if( !device || !font ) return D3DERR_INVALIDCALL;
873 
874  desc.Height=height;
875  desc.Width=width;
876  desc.Weight=weight;
877  desc.MipLevels=miplevels;
878  desc.Italic=italic;
879  desc.CharSet=charset;
880  desc.OutputPrecision=precision;
881  desc.Quality=quality;
882  desc.PitchAndFamily=pitchandfamily;
883  if(facename != NULL) lstrcpyW(desc.FaceName, facename);
884  else desc.FaceName[0] = '\0';
885 
887 }
GLint GLint GLsizei width
Definition: gl.h:1546
CFF_Charset charset
Definition: cffcmap.c:138
Definition: mk_font.cpp:20
#define D3DERR_INVALIDCALL
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_DESCW *desc, ID3DXFont **font)
Definition: font.c:908
static LPTEXTMETRICW LONG * height
Definition: font.c:42
GLenum GLint GLint * precision
Definition: glext.h:7539
int quality
Definition: jpeglib.h:992
weight
Definition: sortkey.c:156
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112

◆ glyph_rb_compare()

static int glyph_rb_compare ( const void key,
const struct wine_rb_entry entry 
)
static

Definition at line 61 of file font.c.

62 {
63  struct d3dx_glyph *glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry);
64  unsigned int id = (UINT_PTR)key;
65 
66  return id - glyph->id;
67 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
unsigned int id
Definition: font.c:33
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
Definition: path.c:41

Referenced by D3DXCreateFontIndirectW().

◆ glyph_rb_free()

static void glyph_rb_free ( struct wine_rb_entry entry,
void context 
)
static

Definition at line 69 of file font.c.

70 {
71  struct d3dx_glyph *glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry);
72 
73  heap_free(glyph);
74 }
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by ID3DXFontImpl_Release().

◆ ID3DXFontImpl_AddRef()

static ULONG WINAPI ID3DXFontImpl_AddRef ( ID3DXFont iface)
static

Definition at line 99 of file font.c.

100 {
101  struct d3dx_font *font = impl_from_ID3DXFont(iface);
103 
104  TRACE("%p increasing refcount to %u\n", iface, ref);
105  return ref;
106 }
Definition: mk_font.cpp:20
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ ID3DXFontImpl_DrawTextA()

static INT WINAPI ID3DXFontImpl_DrawTextA ( ID3DXFont iface,
ID3DXSprite *  sprite,
const char string,
INT  count,
RECT rect,
DWORD  format,
D3DCOLOR  color 
)
static

Definition at line 487 of file font.c.

489 {
490  int ret, countW;
491  WCHAR *wstr;
492 
493  TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n",
495 
496  if (!string || !count)
497  return 0;
498 
499  countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
500 
501  if (!countW)
502  return 0;
503 
504  wstr = heap_alloc_zero(countW * sizeof(*wstr));
505  if (!wstr)
506  return 0;
507 
508  MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
509 
510  ret = ID3DXFont_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW,
511  rect, format, color);
512 
513  heap_free(wstr);
514 
515  return ret;
516 }
#define CP_ACP
Definition: compat.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
& rect
Definition: startmenu.cpp:1413
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLuint color
Definition: glext.h:6243
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char * wine_dbgstr_rect(const RECT *rect)
int ret
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define ID3DXFont_DrawTextW(p, a, b, c, d, e, f)
Definition: d3dx9core.h:180
Definition: sprite.c:39
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ID3DXFontImpl_DrawTextW()

static INT WINAPI ID3DXFontImpl_DrawTextW ( ID3DXFont iface,
ID3DXSprite *  sprite,
const WCHAR string,
INT  in_count,
RECT rect,
DWORD  format,
D3DCOLOR  color 
)
static

Definition at line 654 of file font.c.

656 {
657  struct d3dx_font *font = impl_from_ID3DXFont(iface);
658  int lh, x, y, width, top, ret = 0;
659  ID3DXSprite *target = sprite;
660  unsigned int count;
661  RECT r = {0};
662  WCHAR *line;
663  SIZE size;
664 
665  TRACE("iface %p, sprite %p, string %s, in_count %d, rect %s, format %#x, color 0x%08x.\n",
666  iface, sprite, debugstr_wn(string, in_count), in_count, wine_dbgstr_rect(rect), format, color);
667 
668  if (!string)
669  return 0;
670 
671  count = in_count < 0 ? lstrlenW(string) : in_count;
672 
673  if (!count)
674  return 0;
675 
676  if (format & DT_CALCRECT)
677  format |= DT_NOCLIP;
678 
679  if (format & DT_SINGLELINE)
680  format &= ~DT_WORDBREAK;
681 
682  line = heap_alloc(count * sizeof(*line));
683  if (!line)
684  return 0;
685 
686  if (!rect || format & (DT_CALCRECT | DT_VCENTER | DT_BOTTOM))
687  {
688  if (!rect)
689  {
690  rect = &r;
691  format |= DT_NOCLIP;
692  }
693  else if (!(format & DT_CALCRECT))
694  {
695  r = *rect;
696  rect = &r;
697  }
698 
699  top = rect->top;
700 
701  ret = compute_rect(font, string, count, line, rect, format);
702 
703  if (format & DT_CALCRECT)
704  goto cleanup;
705  }
706  else
707  {
708  top = rect->top;
709  }
710 
711  y = rect->top;
712  lh = font->metrics.tmHeight;
713  width = rect->right - rect->left;
714 
715  if (!sprite)
716  {
717  D3DXCreateSprite(font->device, &target);
719  }
720 
721  while (string)
722  {
723  unsigned int line_len, i;
725 
726  string = read_line(font->hdc, string, &count, line, &line_len, width, format, &size);
727 
728  if (format & DT_CENTER)
729  x = (rect->left + rect->right - size.cx) / 2;
730  else if (format & DT_RIGHT)
731  x = rect->right - size.cx;
732  else
733  x = rect->left;
734 
735  memset(&results, 0, sizeof(results));
736  results.nGlyphs = line_len;
737 
738  results.lpCaretPos = heap_alloc(line_len * sizeof(*results.lpCaretPos));
739  if (!results.lpCaretPos)
740  goto cleanup;
741 
742  results.lpGlyphs = heap_alloc(line_len * sizeof(*results.lpGlyphs));
743  if (!results.lpGlyphs)
744  {
745  heap_free(results.lpCaretPos);
746  goto cleanup;
747  }
748 
749  GetCharacterPlacementW(font->hdc, line, line_len, 0, &results, 0);
750 
751  for (i = 0; i < results.nGlyphs; ++i)
752  {
753  IDirect3DTexture9 *texture;
755  POINT cell_inc;
756  RECT black_box;
757 
758  ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc);
759 
760  if (!texture)
761  continue;
762 
763  pos.x = cell_inc.x + x + results.lpCaretPos[i];
764  pos.y = cell_inc.y + y;
765  pos.z = 0;
766 
767  if (!(format & DT_NOCLIP))
768  {
769  if (pos.x > rect->right)
770  {
772  continue;
773  }
774 
775  if (pos.x + black_box.right - black_box.left > rect->right)
776  black_box.right = black_box.left + rect->right - pos.x;
777 
778  if (pos.y + black_box.bottom - black_box.top > rect->bottom)
779  black_box.bottom = black_box.top + rect->bottom - pos.y;
780  }
781 
782  ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color);
784  }
785 
786  heap_free(results.lpCaretPos);
787  heap_free(results.lpGlyphs);
788 
789  y += lh;
790  if (!(DT_NOCLIP & format) && (y > rect->bottom))
791  break;
792  }
793 
794  ret = y - top;
795 
796 cleanup:
797  if (target != sprite)
798  {
801  }
802 
803  heap_free(line);
804 
805  return ret;
806 }
GLint GLint GLsizei width
Definition: gl.h:1546
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
Definition: mk_font.cpp:20
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DT_WORDBREAK
Definition: winuser.h:544
#define ID3DXSprite_Draw(p, a, b, c, d, e)
Definition: d3dx9core.h:450
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
LONG top
Definition: windef.h:307
Definition: font.c:41
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define DT_RIGHT
Definition: winuser.h:538
LONG left
Definition: windef.h:306
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
LONG right
Definition: windef.h:308
#define lstrlenW
Definition: compat.h:609
& rect
Definition: startmenu.cpp:1413
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define DT_CALCRECT
Definition: winuser.h:526
GLuint color
Definition: glext.h:6243
Definition: parser.c:48
#define DT_VCENTER
Definition: winuser.h:543
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static int compute_rect(struct d3dx_font *font, const WCHAR *string, unsigned int count, WCHAR *line, RECT *rect, DWORD format)
Definition: font.c:598
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint texture
Definition: glext.h:6295
static UINT UINT count
Definition: font.c:44
const char * wine_dbgstr_rect(const RECT *rect)
#define ID3DXSprite_End(p)
Definition: d3dx9core.h:452
struct _test_info results[8]
Definition: SetCursorPos.c:29
int ret
char line[200]
Definition: main.c:97
#define ID3DXSprite_Release(p)
Definition: d3dx9core.h:442
#define ID3DXSprite_Begin(p, a)
Definition: d3dx9core.h:449
#define debugstr_wn
Definition: kernel32.h:33
Definition: sprite.c:39
#define DT_NOCLIP
Definition: winuser.h:536
#define DT_SINGLELINE
Definition: winuser.h:540
static const WORD INT INT LPINT LPINT LPSIZE size
Definition: font.c:53
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
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static const WCHAR * read_line(HDC hdc, const WCHAR *str, unsigned int *count, WCHAR *dest, unsigned int *dest_len, int width, DWORD format, SIZE *size)
Definition: font.c:559
HRESULT WINAPI D3DXCreateSprite(struct IDirect3DDevice9 *device, struct ID3DXSprite **sprite)
Definition: sprite.c:569
GLenum target
Definition: glext.h:7315
LONG bottom
Definition: windef.h:309
#define DT_CENTER
Definition: winuser.h:527
char * cleanup(char *str)
Definition: wpickclick.c:99
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
#define ID3DXFont_GetGlyphData(p, a, b, c, d)
Definition: d3dx9core.h:174
#define memset(x, y, z)
Definition: compat.h:39
#define DT_BOTTOM
Definition: winuser.h:525
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
DWORD WINAPI GetCharacterPlacementW(HDC hdc, LPCWSTR lpString, INT uCount, INT nMaxExtent, GCP_RESULTSW *lpResults, DWORD dwFlags)
Definition: font.c:568

◆ ID3DXFontImpl_GetDC()

static HDC WINAPI ID3DXFontImpl_GetDC ( ID3DXFont iface)
static

Definition at line 185 of file font.c.

186 {
187  struct d3dx_font *font = impl_from_ID3DXFont(iface);
188  TRACE("iface %p\n", iface);
189  return font->hdc;
190 }
Definition: mk_font.cpp:20
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
#define TRACE(s)
Definition: solgame.cpp:4

◆ ID3DXFontImpl_GetDescA()

static HRESULT WINAPI ID3DXFontImpl_GetDescA ( ID3DXFont iface,
D3DXFONT_DESCA desc 
)
static

Definition at line 146 of file font.c.

147 {
148  struct d3dx_font *font = impl_from_ID3DXFont(iface);
149 
150  TRACE("iface %p, desc %p\n", iface, desc);
151 
152  if( !desc ) return D3DERR_INVALIDCALL;
153  memcpy(desc, &font->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName));
154  WideCharToMultiByte(CP_ACP, 0, font->desc.FaceName, -1, desc->FaceName, ARRAY_SIZE(desc->FaceName), NULL, NULL);
155 
156  return D3D_OK;
157 }
#define WideCharToMultiByte
Definition: compat.h:111
Definition: mk_font.cpp:20
#define CP_ACP
Definition: compat.h:109
#define D3DERR_INVALIDCALL
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
static const WCHAR desc[]
Definition: protectdata.c:36
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define D3D_OK
Definition: d3d.h:106
#define ARRAY_SIZE(a)
Definition: main.h:24
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112

◆ ID3DXFontImpl_GetDescW()

static HRESULT WINAPI ID3DXFontImpl_GetDescW ( ID3DXFont iface,
D3DXFONT_DESCW desc 
)
static

Definition at line 159 of file font.c.

160 {
161  struct d3dx_font *font = impl_from_ID3DXFont(iface);
162 
163  TRACE("iface %p, desc %p\n", iface, desc);
164 
165  if( !desc ) return D3DERR_INVALIDCALL;
166  *desc = font->desc;
167 
168  return D3D_OK;
169 }
Definition: mk_font.cpp:20
#define D3DERR_INVALIDCALL
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
static const WCHAR desc[]
Definition: protectdata.c:36
#define TRACE(s)
Definition: solgame.cpp:4
#define D3D_OK
Definition: d3d.h:106

◆ ID3DXFontImpl_GetDevice()

static HRESULT WINAPI ID3DXFontImpl_GetDevice ( ID3DXFont iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 133 of file font.c.

134 {
135  struct d3dx_font *font = impl_from_ID3DXFont(iface);
136 
137  TRACE("iface %p, device %p\n", iface, device);
138 
139  if( !device ) return D3DERR_INVALIDCALL;
140  *device = font->device;
141  IDirect3DDevice9_AddRef(font->device);
142 
143  return D3D_OK;
144 }
Definition: mk_font.cpp:20
#define D3DERR_INVALIDCALL
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
#define D3D_OK
Definition: d3d.h:106

◆ ID3DXFontImpl_GetGlyphData()

static HRESULT WINAPI ID3DXFontImpl_GetGlyphData ( ID3DXFont iface,
UINT  glyph,
IDirect3DTexture9 **  texture,
RECT black_box,
POINT cell_inc 
)
static

Definition at line 192 of file font.c.

194 {
195  struct d3dx_font *font = impl_from_ID3DXFont(iface);
196  struct wine_rb_entry *entry;
197  HRESULT hr;
198 
199  TRACE("iface %p, glyph %#x, texture %p, black_box %p, cell_inc %p.\n",
200  iface, glyph, texture, black_box, cell_inc);
201 
202  hr = ID3DXFont_PreloadGlyphs(iface, glyph, glyph);
203  if (FAILED(hr))
204  return hr;
205 
206  entry = wine_rb_get(&font->glyph_tree, ULongToPtr(glyph));
207  if (entry)
208  {
209  struct d3dx_glyph *current_glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry);
210 
211  if (cell_inc)
212  *cell_inc = current_glyph->cell_inc;
213  if (black_box)
214  *black_box = current_glyph->black_box;
215  if (texture)
216  {
217  *texture = current_glyph->texture;
218  if (*texture)
219  IDirect3DTexture9_AddRef(current_glyph->texture);
220  }
221  return D3D_OK;
222  }
223 
224  return D3DXERR_INVALIDDATA;
225 }
IDirect3DTexture9 * texture
Definition: font.c:36
#define ULongToPtr(ul)
Definition: basetsd.h:92
HRESULT hr
Definition: shlfolder.c:183
Definition: mk_font.cpp:20
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
#define IDirect3DTexture9_AddRef(p)
Definition: d3d9.h:1013
RECT black_box
Definition: font.c:34
POINT cell_inc
Definition: font.c:35
#define TRACE(s)
Definition: solgame.cpp:4
#define ID3DXFont_PreloadGlyphs(p, a, b)
Definition: d3dx9core.h:176
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:79
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
#define D3D_OK
Definition: d3d.h:106
Definition: rbtree.h:35
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203

◆ ID3DXFontImpl_GetTextMetricsA()

static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA ( ID3DXFont iface,
TEXTMETRICA metrics 
)
static

Definition at line 171 of file font.c.

172 {
173  struct d3dx_font *font = impl_from_ID3DXFont(iface);
174  TRACE("iface %p, metrics %p\n", iface, metrics);
175  return GetTextMetricsA(font->hdc, metrics);
176 }
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
Definition: mk_font.cpp:20
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define TRACE(s)
Definition: solgame.cpp:4

◆ ID3DXFontImpl_GetTextMetricsW()

static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW ( ID3DXFont iface,
TEXTMETRICW metrics 
)
static

Definition at line 178 of file font.c.

179 {
180  struct d3dx_font *font = impl_from_ID3DXFont(iface);
181  TRACE("iface %p, metrics %p\n", iface, metrics);
182  return GetTextMetricsW(font->hdc, metrics);
183 }
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
Definition: mk_font.cpp:20
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
#define TRACE(s)
Definition: solgame.cpp:4

◆ ID3DXFontImpl_OnLostDevice()

static HRESULT WINAPI ID3DXFontImpl_OnLostDevice ( ID3DXFont iface)
static

Definition at line 808 of file font.c.

809 {
810  FIXME("iface %p stub!\n", iface);
811  return D3D_OK;
812 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define D3D_OK
Definition: d3d.h:106

◆ ID3DXFontImpl_OnResetDevice()

static HRESULT WINAPI ID3DXFontImpl_OnResetDevice ( ID3DXFont iface)
static

Definition at line 814 of file font.c.

815 {
816  FIXME("iface %p stub\n", iface);
817  return D3D_OK;
818 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define D3D_OK
Definition: d3d.h:106

◆ ID3DXFontImpl_PreloadCharacters()

static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters ( ID3DXFont iface,
UINT  first,
UINT  last 
)
static

Definition at line 227 of file font.c.

228 {
229  struct d3dx_font *font = impl_from_ID3DXFont(iface);
230  unsigned int i, count, start, end;
231  WORD *indices;
232  WCHAR *chars;
233 
234  TRACE("iface %p, first %u, last %u.\n", iface, first, last);
235 
236  if (last < first)
237  return D3D_OK;
238 
239  count = last - first + 1;
240  indices = heap_alloc(count * sizeof(*indices));
241  if (!indices)
242  return E_OUTOFMEMORY;
243 
244  chars = heap_alloc(count * sizeof(*chars));
245  if (!chars)
246  {
248  return E_OUTOFMEMORY;
249  }
250 
251  for (i = 0; i < count; ++i)
252  chars[i] = first + i;
253 
254  GetGlyphIndicesW(font->hdc, chars, count, indices, 0);
255 
256  start = end = indices[0];
257  for (i = 1; i < count; ++i)
258  {
259  if (indices[i] == end + 1)
260  {
261  end = indices[i];
262  continue;
263  }
265  start = end = indices[i];
266  }
268 
269  heap_free(chars);
271 
272  return D3D_OK;
273 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
static const WORD * indices
Definition: font.c:53
Definition: mk_font.cpp:20
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794
Definition: font.c:41
static UINT UINT last
Definition: font.c:45
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define ID3DXFont_PreloadGlyphs(p, a, b)
Definition: d3dx9core.h:176
__wchar_t WCHAR
Definition: xmlstorage.h:180
static UINT UINT count
Definition: font.c:44
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint end
Definition: gl.h:1545
#define D3D_OK
Definition: d3d.h:106
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
GLuint start
Definition: gl.h:1545
DWORD WINAPI GetGlyphIndicesW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpstr, _In_ int c, _Out_writes_(c) LPWORD pgi, _In_ DWORD fl)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ID3DXFontImpl_PreloadGlyphs()

static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs ( ID3DXFont iface,
UINT  first,
UINT  last 
)
static

Definition at line 302 of file font.c.

303 {
304  static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
305  struct d3dx_font *font = impl_from_ID3DXFont(iface);
306  IDirect3DTexture9 *current_texture = NULL;
307  unsigned int size, stride, glyph, x, y;
308  struct d3dx_glyph *current_glyph;
309  D3DLOCKED_RECT lockrect;
311  BOOL mapped = FALSE;
312  DWORD *pixel_data;
313  BYTE *buffer;
314  HRESULT hr;
315 
316  TRACE("iface %p, first %u, last %u.\n", iface, first, last);
317 
318  if (last < first)
319  return D3D_OK;
320 
321  if (font->texture_count)
322  current_texture = font->textures[font->texture_count - 1];
323 
324  for (glyph = first; glyph <= last; ++glyph)
325  {
326  if (wine_rb_get(&font->glyph_tree, ULongToPtr(glyph)))
327  continue;
328 
329  current_glyph = heap_alloc(sizeof(*current_glyph));
330  if (!current_glyph)
331  {
332  if (mapped)
333  IDirect3DTexture9_UnlockRect(current_texture, 0);
334  return E_OUTOFMEMORY;
335  }
336 
337  current_glyph->id = glyph;
338  current_glyph->texture = NULL;
339  wine_rb_put(&font->glyph_tree, ULongToPtr(current_glyph->id), &current_glyph->entry);
340 
342  if (size == GDI_ERROR)
343  {
344  WARN("GetGlyphOutlineW failed.\n");
345  continue;
346  }
347  if (!size)
348  continue;
349 
351  if (!buffer)
352  {
353  if (mapped)
354  IDirect3DTexture9_UnlockRect(current_texture, 0);
355  return E_OUTOFMEMORY;
356  }
357 
359 
360  if (font->texture_pos == font->glyphs_per_texture)
361  {
362  unsigned int new_texture_count = font->texture_count + 1;
363  IDirect3DTexture9 **new_textures;
364 
365  if (mapped)
366  IDirect3DTexture9_UnlockRect(current_texture, 0);
367  mapped = FALSE;
368  new_textures = heap_realloc(font->textures, new_texture_count * sizeof(*new_textures));
369  if (!new_textures)
370  {
371  heap_free(buffer);
372  return E_OUTOFMEMORY;
373  }
374  font->textures = new_textures;
375 
376  if (FAILED(hr = IDirect3DDevice9_CreateTexture(font->device, font->texture_size,
377  font->texture_size, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
378  &font->textures[font->texture_count], NULL)))
379  {
380  heap_free(buffer);
381  return hr;
382  }
383 
384  current_texture = font->textures[font->texture_count++];
385  font->texture_pos = 0;
386  }
387 
388  if (!mapped)
389  {
390  if (FAILED(hr = IDirect3DTexture9_LockRect(current_texture, 0, &lockrect, NULL, 0)))
391  {
392  heap_free(buffer);
393  return hr;
394  }
395  mapped = TRUE;
396  }
397 
398  x = morton_decode(font->texture_pos) * font->glyph_size;
399  y = morton_decode(font->texture_pos >> 1) * font->glyph_size;
400 
401  current_glyph->black_box.left = x - metrics.gmptGlyphOrigin.x + font->glyph_size / 2
402  - metrics.gmBlackBoxX / 2;
403  current_glyph->black_box.top = y - metrics.gmptGlyphOrigin.y + font->metrics.tmAscent + 1;
404  current_glyph->black_box.right = current_glyph->black_box.left + metrics.gmBlackBoxX;
405  current_glyph->black_box.bottom = current_glyph->black_box.top + metrics.gmBlackBoxY;
406  current_glyph->cell_inc.x = metrics.gmptGlyphOrigin.x - 1;
407  current_glyph->cell_inc.y = font->metrics.tmAscent - metrics.gmptGlyphOrigin.y - 1;
408  current_glyph->texture = current_texture;
409 
410  pixel_data = lockrect.pBits;
411  stride = (metrics.gmBlackBoxX + 3) & ~3;
412  for (y = 0; y < metrics.gmBlackBoxY; ++y)
413  for (x = 0; x < metrics.gmBlackBoxX; ++x)
414  pixel_data[(current_glyph->black_box.top + y) * lockrect.Pitch / 4
415  + current_glyph->black_box.left + x] =
416  (buffer[y * stride + x] * 255 / 64 << 24) | 0x00ffffffu;
417 
418  heap_free(buffer);
419  ++font->texture_pos;
420  }
421  if (mapped)
422  IDirect3DTexture9_UnlockRect(current_texture, 0);
423 
424  return D3D_OK;
425 }
static uint32_t morton_decode(uint32_t x)
Definition: font.c:275
#define IDirect3DTexture9_UnlockRect(p, a)
Definition: d3d9.h:1035
IDirect3DTexture9 * texture
Definition: font.c:36
#define ULongToPtr(ul)
Definition: basetsd.h:92
long y
Definition: polytest.cpp:48
HRESULT hr
Definition: shlfolder.c:183
long x
Definition: polytest.cpp:48
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
Definition: mk_font.cpp:20
#define TRUE
Definition: types.h:120
const GLint * first
Definition: glext.h:5794
#define WARN(fmt,...)
Definition: debug.h:112
LONG top
Definition: windef.h:307
Definition: font.c:41
GLuint buffer
Definition: glext.h:5915
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static const MAT2 mat
Definition: font.c:66
Definition: wingdi.h:2471
static UINT UINT last
Definition: font.c:45
LONG left
Definition: windef.h:306
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
LONG right
Definition: windef.h:308
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define GGO_GRAY8_BITMAP
Definition: wingdi.h:853
unsigned int id
Definition: font.c:33
RECT black_box
Definition: font.c:34
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetGlyphOutlineW(HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpvBuffer, CONST MAT2 *lpmat2)
Definition: font.c:1161
static UINT UINT LPINT buffer
Definition: font.c:48
POINT cell_inc
Definition: font.c:35
#define TRACE(s)
Definition: solgame.cpp:4
GLsizei stride
Definition: glext.h:5848
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:79
struct wine_rb_entry entry
Definition: font.c:38
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GGO_GLYPH_INDEX
Definition: wingdi.h:854
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
static const WORD INT INT LPINT LPINT LPSIZE size
Definition: font.c:53
#define IDirect3DDevice9_CreateTexture(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1530
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
#define IDirect3DTexture9_LockRect(p, a, b, c, d)
Definition: d3d9.h:1034
LONG bottom
Definition: windef.h:309
#define GDI_ERROR
Definition: wingdi.h:1308
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ID3DXFontImpl_PreloadTextA()

static HRESULT WINAPI ID3DXFontImpl_PreloadTextA ( ID3DXFont iface,
const char string,
INT  count 
)
static

Definition at line 427 of file font.c.

428 {
429  WCHAR *wstr;
430  HRESULT hr;
431  int countW;
432 
433  TRACE("iface %p, string %s, count %d.\n", iface, debugstr_an(string, count), count);
434 
435  if (!string && !count)
436  return D3D_OK;
437 
438  if (!string)
439  return D3DERR_INVALIDCALL;
440 
441  countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
442 
443  wstr = heap_alloc(countW * sizeof(*wstr));
444  if (!wstr)
445  return E_OUTOFMEMORY;
446 
447  MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
448 
449  hr = ID3DXFont_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW);
450 
451  heap_free(wstr);
452 
453  return hr;
454 }
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define ID3DXFont_PreloadTextW(p, a, b)
Definition: d3dx9core.h:178
#define D3D_OK
Definition: d3d.h:106
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ID3DXFontImpl_PreloadTextW()

static HRESULT WINAPI ID3DXFontImpl_PreloadTextW ( ID3DXFont iface,
const WCHAR string,
INT  count 
)
static

Definition at line 456 of file font.c.

457 {
458  struct d3dx_font *font = impl_from_ID3DXFont(iface);
459  WORD *indices;
460  int i;
461 
462  TRACE("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count);
463 
464  if (!string && !count)
465  return D3D_OK;
466 
467  if (!string)
468  return D3DERR_INVALIDCALL;
469 
470  if (count < 0)
471  count = lstrlenW(string);
472 
473  indices = heap_alloc(count * sizeof(*indices));
474  if (!indices)
475  return E_OUTOFMEMORY;
476 
477  GetGlyphIndicesW(font->hdc, string, count, indices, 0);
478 
479  for (i = 0; i < count; ++i)
481 
483 
484  return D3D_OK;
485 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
static const WORD * indices
Definition: font.c:53
Definition: mk_font.cpp:20
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define D3DERR_INVALIDCALL
Definition: font.c:41
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
#define lstrlenW
Definition: compat.h:609
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define ID3DXFont_PreloadGlyphs(p, a, b)
Definition: d3dx9core.h:176
static UINT UINT count
Definition: font.c:44
unsigned short WORD
Definition: ntddk_ex.h:93
#define debugstr_wn
Definition: kernel32.h:33
#define D3D_OK
Definition: d3d.h:106
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
DWORD WINAPI GetGlyphIndicesW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpstr, _In_ int c, _Out_writes_(c) LPWORD pgi, _In_ DWORD fl)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ID3DXFontImpl_QueryInterface()

static HRESULT WINAPI ID3DXFontImpl_QueryInterface ( ID3DXFont iface,
REFIID  riid,
void **  out 
)
static

Definition at line 81 of file font.c.

82 {
83  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
84 
85  if (IsEqualGUID(riid, &IID_ID3DXFont)
87  {
88  IUnknown_AddRef(iface);
89  *out = iface;
90  return S_OK;
91  }
92 
93  WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
94 
95  *out = NULL;
96  return E_NOINTERFACE;
97 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ ID3DXFontImpl_Release()

static ULONG WINAPI ID3DXFontImpl_Release ( ID3DXFont iface)
static

Definition at line 108 of file font.c.

109 {
110  struct d3dx_font *font = impl_from_ID3DXFont(iface);
112  unsigned int i;
113 
114  TRACE("%p decreasing refcount to %u\n", iface, ref);
115 
116  if (!ref)
117  {
118  for (i = 0; i < font->texture_count; ++i)
119  IDirect3DTexture9_Release(font->textures[i]);
120 
121  heap_free(font->textures);
122 
123  wine_rb_destroy(&font->glyph_tree, glyph_rb_free, NULL);
124 
125  DeleteObject(font->hfont);
126  DeleteDC(font->hdc);
128  heap_free(font);
129  }
130  return ref;
131 }
Definition: mk_font.cpp:20
#define IDirect3DTexture9_Release(p)
Definition: d3d9.h:1014
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
Definition: font.c:41
static void glyph_rb_free(struct wine_rb_entry *entry, void *context)
Definition: font.c:69
static struct d3dx_font * impl_from_ID3DXFont(ID3DXFont *iface)
Definition: font.c:76
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define TRACE(s)
Definition: solgame.cpp:4
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198
#define InterlockedDecrement
Definition: armddk.h:52
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
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ impl_from_ID3DXFont()

static struct d3dx_font* impl_from_ID3DXFont ( ID3DXFont iface)
inlinestatic

Definition at line 76 of file font.c.

77 {
78  return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface);
79 }
Definition: font.c:41
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ID3DXFont ID3DXFont_iface
Definition: font.c:43

Referenced by ID3DXFontImpl_AddRef(), ID3DXFontImpl_DrawTextW(), ID3DXFontImpl_GetDC(), ID3DXFontImpl_GetDescA(), ID3DXFontImpl_GetDescW(), ID3DXFontImpl_GetDevice(), ID3DXFontImpl_GetGlyphData(), ID3DXFontImpl_GetTextMetricsA(), ID3DXFontImpl_GetTextMetricsW(), ID3DXFontImpl_PreloadCharacters(), ID3DXFontImpl_PreloadGlyphs(), ID3DXFontImpl_PreloadTextW(), and ID3DXFontImpl_Release().

◆ morton_decode()

static uint32_t morton_decode ( uint32_t  x)
static

Definition at line 275 of file font.c.

276 {
277  x &= 0x55555555;
278  x = (x ^ (x >> 1)) & 0x33333333;
279  x = (x ^ (x >> 2)) & 0x0f0f0f0f;
280  x = (x ^ (x >> 4)) & 0x00ff00ff;
281  x = (x ^ (x >> 8)) & 0x0000ffff;
282  return x;
283 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by ID3DXFontImpl_PreloadGlyphs().

◆ read_line()

static const WCHAR* read_line ( HDC  hdc,
const WCHAR str,
unsigned int count,
WCHAR dest,
unsigned int dest_len,
int  width,
DWORD  format,
SIZE size 
)
static

Definition at line 559 of file font.c.

561 {
562  unsigned int orig_count = *count;
563  unsigned int i = 0;
564  int num_fit;
565 
566  *dest_len = 0;
567  while (*count && (str[i] != '\n' || (format & DT_SINGLELINE)))
568  {
569  --(*count);
570  if (str[i] != '\r' && str[i] != '\n')
571  dest[(*dest_len)++] = str[i];
572  ++i;
573  }
574 
575  num_fit = 0;
576  GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, size);
577 
578  if (num_fit < *dest_len && (format & DT_WORDBREAK))
579  {
580  unsigned int chars_used;
581 
582  word_break(hdc, dest, dest_len, num_fit, &chars_used, size);
583  *count = orig_count - chars_used;
584  i = chars_used;
585  }
586 
587  if (*count && str[i] == '\n')
588  {
589  --(*count);
590  ++i;
591  }
592 
593  if (*count)
594  return str + i;
595  return NULL;
596 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DT_WORDBREAK
Definition: winuser.h:544
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
BOOL WINAPI GetTextExtentExPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpszString, _In_ int cchString, _In_ int nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
static UINT UINT count
Definition: font.c:44
HDC hdc
Definition: main.c:9
#define DT_SINGLELINE
Definition: winuser.h:540
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
#define NULL
Definition: types.h:112
static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, unsigned int chars_fit, unsigned int *chars_used, SIZE *size)
Definition: font.c:518
static char * dest
Definition: rtl.c:135

Referenced by compute_rect(), and ID3DXFontImpl_DrawTextW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

◆ word_break()

static void word_break ( HDC  hdc,
const WCHAR str,
unsigned int str_len,
unsigned int  chars_fit,
unsigned int chars_used,
SIZE size 
)
static

Definition at line 518 of file font.c.

520 {
521  SCRIPT_LOGATTR *sla;
523  unsigned int i;
524 
525  *chars_used = 0;
526 
527  sla = heap_alloc(*str_len * sizeof(*sla));
528  if (!sla)
529  return;
530 
531  memset(&sa, 0, sizeof(sa));
532  sa.eScript = SCRIPT_UNDEFINED;
533 
534  ScriptBreak(str, *str_len, &sa, sla);
535 
536  /* Work back from the last character that did fit to a place where we can break */
537  i = chars_fit;
538  while (i > 0 && !sla[i].fSoftBreak) /* chars_fit < *str_len so this is valid */
539  --i;
540 
541  /* If the there is no word that fits put in all characters that do fit */
542  if (!sla[i].fSoftBreak)
543  i = chars_fit;
544 
545  *chars_used = i;
546  if (sla[i].fWhiteSpace)
547  ++(*chars_used);
548 
549  /* Remove extra spaces */
550  while (i > 0 && sla[i-1].fWhiteSpace)
551  --i;
552  *str_len = i;
553 
554  /* Remeasure the string */
556  heap_free(sla);
557 }
#define str_len
Definition: treelist.c:89
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
BOOL WINAPI GetTextExtentExPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpszString, _In_ int cchString, _In_ int nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
HDC hdc
Definition: main.c:9
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
#define NULL
Definition: types.h:112
HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la)
Definition: usp10.c:3047
#define SCRIPT_UNDEFINED
Definition: usp10.h:69
#define memset(x, y, z)
Definition: compat.h:39
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by read_line().

Variable Documentation

◆ D3DXFont_Vtbl

const ID3DXFontVtbl D3DXFont_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface)
Definition: font.c:808
static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT in_count, RECT *rect, DWORD format, D3DCOLOR color)
Definition: font.c:654
static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first, UINT last)
Definition: font.c:302
static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last)
Definition: font.c:227
static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface)
Definition: font.c:99
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(ID3DXFont *iface, TEXTMETRICW *metrics)
Definition: font.c:178
static HRESULT WINAPI ID3DXFontImpl_OnResetDevice(ID3DXFont *iface)
Definition: font.c:814
static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface)
Definition: font.c:185
static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface)
Definition: font.c:108
static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid, void **out)
Definition: font.c:81
static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *string, INT count)
Definition: font.c:456
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(ID3DXFont *iface, TEXTMETRICA *metrics)
Definition: font.c:171
static HRESULT WINAPI ID3DXFontImpl_GetDevice(ID3DXFont *iface, IDirect3DDevice9 **device)
Definition: font.c:133
static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, IDirect3DTexture9 **texture, RECT *black_box, POINT *cell_inc)
Definition: font.c:192
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count)
Definition: font.c:427
static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
Definition: font.c:487
static HRESULT WINAPI ID3DXFontImpl_GetDescW(ID3DXFont *iface, D3DXFONT_DESCW *desc)
Definition: font.c:159
static HRESULT WINAPI ID3DXFontImpl_GetDescA(ID3DXFont *iface, D3DXFONT_DESCA *desc)
Definition: font.c:146

Definition at line 820 of file font.c.

Referenced by D3DXCreateFontIndirectW().