3

I used c# Graphics.DrawString method to draw text overlays on images. It can draw Turkish characters even if operating system does not have Turkish language package. However i am using directx-9 to draw now because of performance issues. If operating system has Turkish language package , directx draws Turkish characters, but if not, it does not draw.

Is there a way to draw Turkish characters via directx even if operating system does not have Turkish language package?

String comes from c# to c++ via wrapper.

drawStringWrapper(System::String^ text)
{
   char* textPtr = (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(text).ToPointer();
   drawStringD3DX(textptr);
}

This is how i create font,

D3DXCreateFont(dev,fontSize,0,FW_NORMAL,1,false,TURKISH_CHARSET,OUT_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_MODERN, L"Arial", &d3dxFont);

I tried ANSI_CHARSET and DEFAULT_CHARSET. Also i tried different fonts, ex:L"Generic Sans Serif"

Ksilon
  • 66
  • 7
  • The [legacy D3DX9](https://learn.microsoft.com/en-us/windows/desktop/directx-sdk--august-2009-) font solution captures TrueType fonts from the system at runtime so you either have to install the font or use one that is [already installed](https://en.wikipedia.org/wiki/List_of_typefaces_included_with_Microsoft_Windows). Alternatively you can capture the font to a bitmap at build time which how XNA Game Studio and [DirectX Tool Kit](https://github.com/microsoft/DirectXTK/wiki/Getting-Started) ``SpriteFont`` work. – Chuck Walbourn Jun 22 '19 at 05:09
  • when i check fonts folder (Run->fonts) computer already has "Arial" font. At left vertical tab has "Find Character". I check there and i can see Turkish characters there. Btw i am not sure, my problem is font or system displays options. – Ksilon Jun 24 '19 at 10:51
  • I find setting as "Language for non-Unicode programs" in Administrative language settings. Detail says "This setting (system locale) controls the language used when displaying text in programs that do not support Unicode". I changed this setting to Turkish(Turkey). After that my directx-9 draw all Turkish characters correctly. But i dont understand why directx-9 needs this setting although c# DrawString method draws correctly for all case. – Ksilon Jun 24 '19 at 11:27
  • Was the string you provided to draw a Unicode string or a local Turkish codepage string? – Chuck Walbourn Jun 24 '19 at 16:18
  • my program sets Culture tr-TR and i calls like this ```drawStringWrapper("ÇĞŞÖİ")```. If "Language for non-Unicode programs" is English, it draws Ç??Ö? . – Ksilon Jun 25 '19 at 13:09
  • That string is multibyte not Unicode. – Chuck Walbourn Jun 25 '19 at 18:04

0 Answers0