Click here to Skip to main content
15,881,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I try to draw a string in win32 program, there are some APIs like TextOut or DrawText and so on. If I want to draw a string of unicode which using wchar_t string, I should define the UNICODE marco. It works well untill some special charactors come out.
According the Unicode charset table, some special charactors don't draw well in those APIs.
For example, there are some kind of shape charactors like a heart shape character ❤ , coding value \u2764 , a telphone shape character ☎, coding value \u260E and so on.

When I try to draw these characters with win32 APIs , the result is not what I expected.

What I have tried:

Here is some codes I've tried.
C++
wchar_t msg[5]={0};
wchar_t a=0x2764;
TextOutW(hdc, 50, 20, msg,1);
Anyone ever tried this?
Posted
Updated 12-Jan-23 20:08pm
v3

1 solution

Yes, I have done this and the key is to use a font that depicts those characters the way you want. Try the Character Map application to see what they look like in various fonts. When you find a font that you like then you can create it and select it in your application. This page describes the process : Font Creation and Selection - Win32 apps | Microsoft Learn[^]
 
Share this answer
 
Comments
Yount_0701 13-Jan-23 2:19am    
I tried to change the font for the device context, it worked !
Thank you. The problem is the font !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900