When I draw text by DrawText function of Win32 API
Is there a way to determine which font will be used, or determine the font size, or bold, or italic?
PS I write in C#
When I draw text by DrawText function of Win32 API Is there a way
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As MSDN says,
Which means that you can obtain current font handle from the device context, and then obtain
LOGFONTstructure which provides you details about the font, that you requested.Since API is using currently selected font, to change it you need to have the new font handle available (you typically pre-create it, or otherwise get
HFONTfont handle using e.g.CreateFontorCreateFontIndirectAPI). Then prior to callingDrawTextyou replace current selected font with your own usingSelectObjectand once you are done you place the orignial font back with anotherSelectObjectcall.