Author Topic: Font Changer  (Read 1272 times)

The original code is also nearly 2 years old, and maybe this has been done before considering how simple this is, oh well. It won't replace the fonts for the start game menu, but otherwise appears to work OK, and partially for glass, the start a game menu, and the advanced section of the custom game menu. I have done a pretty large touch up on the code today, which was originally 2 functions and now has somewhat easier configuration. Most things will have the font changed instantly, while others need to be updated somehow for the change to be reflected.

Code: [Select]
// potentially useful guis list
// PlayGui_ShapeNameHud - shape names

// ISSUES (old)
// changing text size on options is broken - no longer the case?

$fontChange::primaryFont = "Segoe UI";
$fontChange::fontSizeScale = 1;

function fontToggle(%bool)
{
if (%bool)
{
for(%i = 0; %i < GuiDataGroup.getCount(); %i++)
{
%obj = GuiDataGroup.getObject(%i);
if(%obj.getClassName() $= "GuiControlProfile")
{
// remember original values to reverse
if (%obj.origFont $= "")
{
%obj.origFont = %obj.fontType;
echo("original font name saved for datablock" SPC %obj.getName());
}
if (%obj.origFontSize $= "")
{
%obj.origFontSize = %obj.fontSize;
echo("original font size saved for datablock" SPC %obj.getName());
}
// changing the fonts selectively
switch$ (%obj.fontType)
{
case "Arial":
%obj.fontType = $fontChange::primaryFont;
case "Palatino Linotype":
%obj.fontType = "Segoe UI Semilight";
case "Impact":
%obj.fontType = "Segoe UI Semibold";
default :
%obj.fontType = $fontChange::primaryFont;
}
// changing the scale if need be (not recommended)
if ($fontChange::fontSizeScale !$= "" && $fontChange::fontSizeScale !$= "1" && !((%obj.origFontSize * $fontChange::fontSizeScale) == %obj.fontSize))
{
%obj.fontSize *= $fontChange::fontSizeScale;
}

%obj.updateFont();
echo("font changed for datablock" SPC %obj.getName());
}
}
}
else if (!%bool)
{
for(%i = 0; %i < GuiDataGroup.getCount(); %i++)
{
%obj = GuiDataGroup.getObject(%i);
if(%obj.getClassName() $= "GuiControlProfile")
{
%obj.fontType = %obj.origFont;
%obj.fontSize = %obj.origFontSize;
%obj.updateFont();
echo("font reverted for datablock" SPC %obj.getName());
}
}
}
}
// testing
echo("Font Changer toggle on");

Old screenshots