Sign in to follow this  

Default font problem win32 C

Recommended Posts

I am totally lost in windows font handling. I can't, for the life, get the attributes of the currently used (and never altered) font.

I can't use GetObject, because I never changed the font of the DC, so the LOGFONT structure will be empty (or whatever, according to MSDN). I can't use SystemParametersInfo with SPI_GETNONCLIENTMETRICS, because I cannot find the appropriate font, and I am sure it's nowhere near what I want.

It's simpler to explain with code and the output.
[source]LOGFONT cur_font = {0};
HFONT hcur_font,hrotated_font;



hrotated_font = CreateFontIndirect(&(Nm.lfStatusFont));

hcur_font = (HFONT)SelectObject(hDC, (HFONT)hrotated_font);


SelectObject(hDC, (HFONT)hcur_font);

TextOut(hDC,500,500,"horizontal",(int)strlen("horizontal"));[/source] And
[source]LOGFONT cur_font = {0};
HFONT hcur_font,hrotated_font;

GetObject(hcur_font=(HFONT)GetCurrentObject(hDC, OBJ_FONT),sizeof(LOGFONT),&cur_font);

hrotated_font = CreateFontIndirect(&cur_font);

SelectObject(hDC, (HFONT)hrotated_font);


SelectObject(hDC, (HFONT)hcur_font);


With the first, the output:
With the second method, I get a puny little "vertical" text.
The "horizontal" text is the default font (the font that gets displayed if I don't do anything with fonts)

Of course, I could get around this by explicitly defining the font for both texts, but it's just mind boggling that I cannot simply get the attributes of the font that's displayed.....

I am totally lost, thanks for any hints!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this