Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old October 15, 2023, 23:17   #21
t4nk
Swordsman
 
Join Date: May 2016
Posts: 336
t4nk is on a distinguished road
Quote:
Originally Posted by Magnate View Post
Also, the first time someone tries to start the new version it will fail if their ~/.angband/Angband/sdl2init.txt refers to one of the old .fon files. If they start it from the command link they will get an error which will prompt them to delete the file, but if they start it from the .desktop icon they won't. This will need quite a big warning, as there's no way Debian can fix that for them.
This is mentioned in main-sdl2.c, line 6540:

Code:
if (find_font_info(name) == NULL) {
	/* TODO maybe its not really an error? the font file was
	 * probably just deleted and now the ui wont event start... */
	return PARSE_ERROR_INVALID_VALUE;
}
I propose to return PARSE_ERROR_NONE then. BackwardsEric, your opinion?
t4nk is offline   Reply With Quote
Old October 15, 2023, 23:35   #22
t4nk
Swordsman
 
Join Date: May 2016
Posts: 336
t4nk is on a distinguished road
As an aside, fc-list :spacing=100 (in a shell) displays a list of monospace fonts installed on my machine (Debian Bookworm). This can perhaps be used for populating ANGBAND_DIR_FONTS?

edit: or even populating g_font_info[] directly? (#ifdef USE_FONTCONFIG, for example)

Last edited by t4nk; October 16, 2023 at 01:36.
t4nk is offline   Reply With Quote
Old October 16, 2023, 02:58   #23
t4nk
Swordsman
 
Join Date: May 2016
Posts: 336
t4nk is on a distinguished road
Quote:
Originally Posted by Magnate View Post
I don't know how much crying there will be about the lack of choice - what would you do:

- release as is and wait for people to file bugs that their favourite font is missing
- link to a load more fonts so there are about the same number as there were before (they won't be identical but I can get a similar range of sizes without any more deps)
- add a note somewhere (like a README, News or changelog) telling people how to make symlinks to fonts they want to use in the game (in fact we could add this to the manual??)
After looking into it more, I propose to add functionality to SDL2 (and perhaps to SDL1) to use Fontconfig, if that is available (which it should be on Linux). That way Angband will be able to find all monospace fonts installed in a standard way (apt-get). ANGBAND_DIR_FONTS then can be used in addition to that, or as a fallback, if Fontconfig is not present.

The incantation to the command-line utility is something like fc-list :spacing=mono:scalable=true:style=regular -f '%{file}\n'

However, it probably makes more sense to use Fontconfig as a library. The documentation of it I found rather difficult to understand, but the source of fc-list provides an example: https://gitlab.freedesktop.org/fontc...ref_type=heads

Last edited by t4nk; October 16, 2023 at 03:43.
t4nk is offline   Reply With Quote
Old October 16, 2023, 03:31   #24
backwardsEric
Swordsman
 
Join Date: Aug 2019
Posts: 434
backwardsEric is on a distinguished road
Quote:
Originally Posted by t4nk View Post
This is mentioned in main-sdl2.c, line 6540:

Code:
if (find_font_info(name) == NULL) {
	/* TODO maybe its not really an error? the font file was
	 * probably just deleted and now the ui wont event start... */
	return PARSE_ERROR_INVALID_VALUE;
}
I propose to return PARSE_ERROR_NONE then. BackwardsEric, your opinion?
That would be better, though if name is the same as the contents of DEFAULT_FONT, it should either use quit()/quit_fmt() or print a diagnostic message about the default font not being available and return something that isn't PARSE_ERROR_NONE. Because when name is the same as the contents of DEFAULT_FONT and that font isn't loadable, either load_subwindow() will fail with an assertion failure or there'll be a later NULL pointer dereference for the subwindow's font field.
backwardsEric is offline   Reply With Quote
Old October 16, 2023, 04:53   #25
t4nk
Swordsman
 
Join Date: May 2016
Posts: 336
t4nk is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
That would be better, though if name is the same as the contents of DEFAULT_FONT, it should either use quit()/quit_fmt() or print a diagnostic message about the default font not being available and return something that isn't PARSE_ERROR_NONE. Because when name is the same as the contents of DEFAULT_FONT and that font isn't loadable, either load_subwindow() will fail with an assertion failure or there'll be a later NULL pointer dereference for the subwindow's font field.
Mmm. That doesn't seem quite right to me. If subwindow->config is present, it won't even look at the DEFAULT_FONT:

Code:
static void load_subwindow(struct window *window, struct subwindow *subwindow)
{
    assert(window->loaded);
    assert(!subwindow->loaded);

    if (subwindow->font == NULL) {
        if (subwindow->config != NULL) {
            subwindow->font = make_font(window, 
                subwindow->config->font_name, subwindow->config->font_size);
        } else {
            subwindow->font = make_font(window, DEFAULT_FONT, 0);
        }
        assert(subwindow->font != NULL);
}
So I suppose the fix in config_subwindow_font() should be something like:

Code:
if (find_font_info(name) == NULL) {
    /* Looks like the old file was deleted, use the default one instead */
    subwindow->config->font_name = string_make(DEFAULT_FONT);
    subwindow->config->font_size = 0;
    return PARSE_ERROR_NONE;
}
Now, if DEFAULT_FONT is indeed not present, the ui won't work, which seems reasonable? Perhaps it could try the first font found in g_font_info[] in this case, or ask Fontconfig the equivalent of fc-match :spacing=mono. Or just die

Anyway, I'll need to reread all this stuff... and setup a Github account, because I don't remember the password for the old one... In the meantime, you might as well fix this one BTW, I think you did an excellent job maintaining this thing.

Last edited by t4nk; October 16, 2023 at 05:03.
t4nk is offline   Reply With Quote
Old October 16, 2023, 10:37   #26
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,110
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
That sounds great - I'm very happy to collaborate (though I know nothing about font management). The Debian packaging repo is at https://salsa.debian.org/games-team/angband in case you're interested in my hackish workarounds, but if we can get the fontconfig functionality into 4.2.6 I can dispense with all that!
__________________
"Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles
Magnate is offline   Reply With Quote
Old October 18, 2023, 22:22   #27
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,110
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
I'm pleased to say that Debian have accepted the revised version of the package which uses other fonts and does not depend on the .fon files. This gives us huge flexibility to use a wider range of fonts.
__________________
"Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles
Magnate is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
why does angband still use .fon files ? shirish Development 14 October 14, 2018 11:18
Spoiler Files? Will94 Vanilla 4 December 2, 2013 23:13
RST help files fph Development 13 September 6, 2011 20:08
Pref files relic Vanilla 11 August 9, 2011 20:40
Z+Angband export(decode) .raw files? PaulBlay Variants 2 February 7, 2009 01:06


All times are GMT +1. The time now is 10:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.