/// <summary>Loads this font from the local project files. Should be a folder named after the font family and in it a series of font files.</summary> /// <returns>True if at least one font face was loaded.</returns> public bool LoadFaces() { if (string.IsNullOrEmpty(Name)) { // This case results in every text asset being checked otherwise! return(false); } // Load all .ttf/.otf files: object[] faces = Resources.LoadAll(Name, typeof(TextAsset)); // For each font face.. for (int i = 0; i < faces.Length; i++) { // Get the raw font face data: byte[] faceData = ((TextAsset)faces[i]).bytes; if (faceData == null || faceData.Length == 0) { // It's a folder. continue; } // Load the font face - adds itself to the family within it if it's a valid font: try{ FontFace loaded; if (Fonts.DeferLoad) { loaded = FontLoader.DeferredLoad(faceData); } else { loaded = FontLoader.Load(faceData); } if (loaded != null && Family == null) { // Grab the family: Family = loaded.Family; } }catch { // Unity probably gave us a copyright file or something like that. // Generally the loader will catch this internally and return null. } } if (Family == null) { return(false); } return(true); }