Skip to content

Commit

Permalink
Adapt for 2023.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobby233Liu authored Nov 12, 2023
1 parent ce72608 commit ab133aa
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions UndertaleModTool/Scripts/Community Scripts/ImportGMS2FontData.csx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ EnsureDataLoaded();

ScriptMessage(@"ImportGMS2FontData by Dobby233Liu
This script can import GM font asset data to your mod
(Designed for the data IDE v2022.6.0.23 generates)
(Designed for the data IDE v2022.8.2.108 generates)
Select the .yy file of the GM font asset you want to import"
);

Expand Down Expand Up @@ -53,8 +53,10 @@ and putting it in the same directory as the .yy file."
);

/*
If true, the script will attempt to add the new font (if any) and the new font glyph texture that it created to a texture group
This was an attempt to get fonts that this script creates appear in a specific 2022.3 game, but was proved unnecessary, as the problem was caused by something else
If true, the script will attempt to add the new font (if any) and the new font glyph texture
that it created to a texture group
This was an attempt to get fonts that this script creates appear in a specific 2022.3 game,
but it was proved unnecessary as the problem was caused by something else
*/
bool attemptToFixFontNotAppearing = false; // Data.GM2022_3;
// Default to putting the font into the default texgroup
Expand Down Expand Up @@ -138,7 +140,10 @@ if (fontData.ContainsKey("ascender"))
font.Ascender = (uint)fontData["ascender"];
if (fontData.ContainsKey("ascenderOffset"))
font.AscenderOffset = (int)fontData["ascenderOffset"];
// TODO: SDFSpread
if (fontData.ContainsKey("usesSDF") && (bool)fontData["usesSDF"] && fontData.ContainsKey("sdfSpread"))
font.SDFSpread = (uint)fontData["sdfSpread"];
if (fontData.ContainsKey("lineHeight"))
font.LineHeight = (uint)fontData["lineHeight"];

// FIXME: Too complicated?
List<int> charRangesUppersAndLowers = new();
Expand All @@ -153,7 +158,8 @@ font.RangeStart = (ushort)charRangesUppersAndLowers.DefaultIfEmpty(0).FirstOrDef
font.RangeEnd = (uint)charRangesUppersAndLowers.DefaultIfEmpty(0xFFFF).LastOrDefault();

List<UndertaleFont.Glyph> glyphs = new();
// From what I've seen, the keys of the objects in glyphs is just the character property of the object itself but in string form
// From what I've seen, the keys of the objects in glyphs is just
// the character property of the object itself but in string form
foreach (KeyValuePair<string, JToken> glyphKVEntry in (JObject)fontData["glyphs"])
{
var glyphData = (JObject)glyphKVEntry.Value;
Expand All @@ -175,6 +181,7 @@ foreach (var glyph in glyphs)
font.Glyphs.Add(glyph);

glyphs = font.Glyphs.ToList();
// TODO: applyKerning??
foreach (JObject kerningPair in fontData["kerningPairs"]?.Values<JObject>())
{
// Why do I need to do this. Thanks YoYo
Expand All @@ -187,4 +194,4 @@ foreach (JObject kerningPair in fontData["kerningPairs"]?.Values<JObject>())
});
}

ScriptMessage("Import complete.");
ScriptMessage("Import complete.");

0 comments on commit ab133aa

Please sign in to comment.