Jump to content

How do I find out which fonts KSP already has available?


Recommended Posts

When I first started making some code for a plugin I had no idea what fonts KSP had already available without me installing my own with the plugin, and I picked "Arial" purely as an utter guess, figuring if it has anything it probably has at least that. It worked.

But now I'd like to see what other fonts it may have before I start thinking about going out and installing one of my own. And I have no idea how to find out.

I'm thinking of making a Unity GUI.TextArea widget for the purpose of editing code for kOS. Since it's for displaying program code a fixed-width font would be ideal. If I had to I could try coercing a proportional font to behave like a fixed width font by setting the GUIStyle's fixedWidth and fixedHeight fields and seeing if that will work. But I suspect the result will look quite bad, as it usually does when trying to do that with a proportional font.

The kOS plugin uses a c-64 like font but it does it as raw bitmap textures it's pasting directly onto the screen. I doubt that would let me use it with GUI.TextArea widgets.

Link to comment
Share on other sites

I'm pretty sure Unity does not ship with any fonts of its own as I know that it relies on the system version of Arial and ArialBold for most text, these are included in Windows, OSX and Ubuntu but are missing from many other Linux distro's and in Wine which is why I made them available in the Linux compatibility thread.

Also if the Windows or OSX versions of Arial are corrupted or uninstalled, the text is lost on those platforms.

There's no info on the Unity site that I can find on fonts, so I guess you would have to either stick to common fonts, do a check of the filesystem for the font or just include your font if licensing permits.

Link to comment
Share on other sites

There's no info on the Unity site that I can find on fonts, so I guess you would have to either stick to common fonts, do a check of the filesystem for the font or just include your font if licensing permits.

Thanks for the fast reply. Assuming I find a TTF fixed width font to use, and that the licensing permits its use in the mod, can I just include it in the mod's GameData folder and tell unity where to find it?

Unity's documentation talks about having to put the font into your "assets folder" but I don't know where that is for a mod.

Link to comment
Share on other sites

Hmm I just dug some more and found that this will do it:


string msg= "";
Object[] fonts = UnityEngine.Resources.FindObjectsOfTypeAll( typeof(UnityEngine.Font) );
foreach (Object f in fonts) {
msg += "font="+((UnityEngine.Font)f).name+"\n";
}

I got this result in the msg string:


font=Arial
font=CALIBRI
font=HEADINGFONT
font=calibri
font=calibrib
font=calibriz
font=calibril
font=dotty

Sadly, none of those are fixed-width.

Link to comment
Share on other sites

Dotty rings a bell, it's the one used for the "Start Game" menu screen and version number.

I think Calibri is used for part descriptions, Arial is of course common as muck, as for Heeadingfont, no idea.

Link to comment
Share on other sites

Dotty rings a bell, it's the one used for the "Start Game" menu screen and version number.

I think Calibri is used for part descriptions, Arial is of course common as muck, as for Heeadingfont, no idea.

Unity *claims* that it will only load font files in the resources folder but I wonder about a font file called "../../GameData/modname/Resources/myfont", using the ..'s to escape from the KSP_Data/Resources folder.

I'll see about it next time. I'm done for tonight.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...