Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

Fallback font list for `surface.CreateFont` #2493

Open Denneisk opened 4 days ago

Denneisk commented 4 days ago

I think having a feature to specify a fallback font(s), in the case that a certain desired font can't be loaded, would be helpful. My ideal implementation would be to allow a list of font names instead of a single font name string for the font field.

surface.CreateFont( "MyCoolFont", {
    font = { "my cool ttf", "comic sans ms", "coolvetica" }
}) -- Will try to load 3 fonts before using the default fallback

The error Couldn't find/load font 'my cool ttf', falling back to 'Tahoma'.. should not occur, and instead an error would only appear if the last case "coolvetica" fails to load. Any failures before the last case should be silent.

My intention for this is for developers who would like to leverage OS-installed fonts without having to require the user to download any additional fonts from an addon/server. Similar to their use in web design, fallback fonts allow for a more consistent visual style in the case that a certain desired font cannot load for any reason.

garryspins commented 4 days ago

This or surface.IsFontValid so we could implement it ourselves, would much prefer that.