❔ Loading a Unity Font object from an assembly's Embedded Resource

Well, I'm trying to load a font I have as a resource embedded in my C# assembly. I've tried a number of things, my most recent attempt seen here (ignore the bad variable names, I'll clean it up once I get it working):
            Shell.print("=====FONTS=====");
            string resourcePath = Assembly.GetExecutingAssembly().GetManifestResourceNames()[0];
            Stream fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath);
            var tempFiles = new TempFileCollection();
            string file = tempFiles.AddExtension("otf");
            using (FileStream fs = File.OpenWrite(file))
            {
                fontStream.CopyTo(fs);
            }
            unifont = new Font(file);
            Shell.print(unifont.characterInfo.Length);
            Shell.print("===END FONTS===");
The idea being that once I successfully load the font, it will print something other than
0
. I have also tried passing the embedded "path"
TextAdventure.Assets.unifont-15.0.06.otf
straight to the
Font
constructor (both relative path & appended to the absolute path of the assembly). I have also put the
.otf
file in a Unity Asset Bundle and used
AssetBundle.LoadFromStream(fontStream).LoadAsset<Font>("assets/unifont-15.0.06.otf")
to try and grab the file.

Any ideas?
Was this page helpful?