Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Miniwindows
➜ Bad return code when loading miniwindow fonts under Wine
|
Bad return code when loading miniwindow fonts under Wine
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Izocinoc
(1 post) Bio
|
| Date
| Sat 20 Dec 2008 12:16 AM (UTC) |
| Message
| The function WindowFont appears to return eOK regardless of whether the font is loaded correctly. I am running MUSHClient version 4.37 on Ubuntu. I put together the following test script.
font_name = "bad_font_name"
if WindowFont(win, "test_font", font_name, 8, false, false, false, false, 0, 49) == error_code.eOK then
Note('Font loaded successfully')
else
Note('Error loading font')
end
fonts = WindowFontList(win)
if fonts then
for _, v in ipairs (fonts) do
Note (v .. " -> " .. WindowFontInfo(win, v, 21))
end
end
When I run the script, I get the output:
Font loaded successfully
test_font -> Courier New
It looks like WindowFont is returning eOK even though I'm passing it a bad font name, and I'm ending up with Courier New loaded. | | Top |
|
| Posted by
| Worstje
Netherlands (899 posts) Bio
|
| Date
| Reply #1 on Sat 20 Dec 2008 01:28 AM (UTC) |
| Message
| | This bug has been confirmed here on plain WXP, too. :) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Sat 20 Dec 2008 02:49 AM (UTC) |
| Message
| It's not exactly a bug - you asked for a font which matched various specifications, and Windows (or Wine) did the best it could to match those. You did, after all, get a font loaded.
By comparison, if you create a word processor document using a font (eg. Comic) and then open it on a PC that doesn't have Comic installed, rather than no font at all, you are likely to end up with Courier, or the font that best matches the one you wanted (eg. serif / sans-serif), such as Helvetica.
If it really bothers you, you could make a wrapper function that loads the wanted font, and then checks that the font name (from WindowFontInfo) actually matches the font you wanted.
I assume you want some sort of font, so an approximation is better than nothing. You could do what I did in another thread, and check what is available, like this:
-- use 8 pt Dina or 10 pt Courier
local fonts = utils.getfontfamilies ()
-- choose a font that exists
if fonts.Dina then
font_name = "Dina"
elseif fonts ["Lucida Sans Unicode"] then
font_name = "Lucida Sans Unicode"
else
font_size = 10
font_name = "Courier"
end -- if
This is checking for Dina or Lucida Sans Unicode, and then failing that, uses Courier. A similar bit of code could work its way from your most preferred to least preferred font.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,278 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top