WindowFont no-ops if no Repaint after WindowCreate

Posted by Fiendish on Tue 13 Mar 2018 04:11 PM — 5 posts, 15,838 views.

USA Global Moderator #0

windowinfo = movewindow.install(win, miniwin.pos_top_right, miniwin.create_absolute_location, false, nil, {mouseup=MouseUp, mousedown=LeftClickOnly, dragmove=LeftClickOnly, dragrelease=LeftClickOnly},{x=default_x, y=default_y})
print("WINDOW CREATE", win, WindowCreate(win, windowinfo.window_left, windowinfo.window_top, width, height, windowinfo.window_mode, windowinfo.window_flags, theme.SECONDARY_BODY))
print("FONT", font_id, font_name, font_size, WindowFont(win, font_id, font_name, font_size, false, false, false, false))
print("FONT INFO", font_id, WindowFontInfo(win, font_id, 21), WindowFontInfo(win, font_id, 20))


prints


WINDOW CREATE my_font 0
FONT my_font Dina 8 0
FONT INFO my_font Arial 0


but (identical except for the explicit call to Repaint)


windowinfo = movewindow.install(win, miniwin.pos_top_right, miniwin.create_absolute_location, false, nil, {mouseup=MouseUp, mousedown=LeftClickOnly, dragmove=LeftClickOnly, dragrelease=LeftClickOnly},{x=default_x, y=default_y})
print("WINDOW CREATE", win, WindowCreate(win, windowinfo.window_left, windowinfo.window_top, width, height, windowinfo.window_mode, windowinfo.window_flags, theme.SECONDARY_BODY))
Repaint()
print("FONT", font_id, font_name, font_size, WindowFont(win, font_id, font_name, font_size, false, false, false, false))
print("FONT INFO", font_id, WindowFontInfo(win, font_id, 21), WindowFontInfo(win, font_id, 20))


prints


WINDOW CREATE my_font 0
FONT my_font Dina 8 0
FONT INFO my_font Dina 0
Amended on Tue 13 Mar 2018 04:13 PM by Fiendish
Australia Forum Administrator #1

I can’t reproduce that. Using a minimal (that doesn’t rely upon other code), verifiable example, I get:

win = "abc"
font_id = "f"
font_name = "Dina"
font_size = 10

print("WINDOW CREATE", win, 
      WindowCreate (win, 0, 0, 200, 200, miniwin.pos_center_all, 0, 0xFFFFFF))

print("FONT", font_id,
      font_name, font_size,
      WindowFont(win, font_id, font_name, font_size))

print("FONT INFO", font_id,
     WindowFontInfo(win, font_id, 21), WindowFontInfo(win, font_id, 20))
WINDOW CREATE abc 0
FONT f Dina 10 0
FONT INFO f Dina 0

The font name is not saved in any MUSHclient structure, but in the Windows font object:

  if (pFont->CreateFont (lfHeight, 
                          0, // int nWidth, 
                          0, // int nEscapement, 
                          0, // int nOrientation, 
                          Bold ? FW_BOLD : FW_NORMAL, // int nWeight, 
                          Italic, // BYTE bItalic, 
                          Underline, // BYTE bUnderline, 
                          Strikeout, // BYTE cStrikeOut, 
                          Charset,
                          0, // BYTE nOutPrecision, 
                          0, // BYTE nClipPrecision, 
                          0, // BYTE nQuality, 
                          PitchAndFamily, 
                          FontName) == 0)   // <--- HERE

I can’t offhand see why CMiniWindow::FontInfo would not return the correct name, and in any case it does for me.

Amended on Tue 27 Mar 2018 03:19 AM by Nick Gammon
Australia Forum Administrator #2
Quote:

WindowFont no-ops ...


You can't say that WindowFont no-ops because your own posted example shows that the font is indeed set up. Your point seems to be that the wrong name is returned by WindowFontInfo.
USA Global Moderator #3
Quote:
You can't say that WindowFont no-ops because your own posted example shows that the font is indeed set up. Your point seems to be that the wrong name is returned by WindowFontInfo.

I noticed that the wrong font was being drawn in a subsequent call to WindowText. This just seemed like a convenient way to communicate it. But if you can't reproduce it, I'll need to look further.

I'm also using Wine, and who knows what shenanigans go on behind the scenes there.
Amended on Wed 14 Mar 2018 06:39 AM by Fiendish
USA Global Moderator #4
This might only be an issue in Wine when calling WindowFont during startup using Default charset instead of specifying ANSI. Luckily the OS default isn't that useful when loading a font.