public override void OnInspectorGUI() { TTFTextFontStoreFontAsset tfs = target as TTFTextFontStoreFontAsset; EditorGUILayout.LabelField("This a TTFText embedded font"); EditorGUILayout.LabelField("Font Name", tfs.font.fontid); }
public TTFTextFontStoreFont EnsureFont(string fontid) { // ensures that a specific font is present the store // this function does not update the reference counts TTFTextFontStoreFont f = GetFont(fontid); if (f == null) { TTFTextFontStoreFont nf = new TTFTextFontStoreFont(); if (fontid.Length > 0) { nf.fontid = fontid; nf.charset = null; nf.AddRequiredCharacters(this.defaultAdditionalCharacters); // addd this embeddedFonts.Add(nf); f = nf; #if UNITY_EDITOR if (!Application.isPlaying) { string d = Application.dataPath; d = System.IO.Path.Combine(d, "Resources"); if (!System.IO.Directory.Exists(d)) { UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources"); } d = System.IO.Path.Combine(d, "TTFText"); if (!System.IO.Directory.Exists(d)) { UnityEditor.AssetDatabase.CreateFolder("Assets/Resources", "TTFText"); } d = System.IO.Path.Combine(d, "Fonts"); if (!System.IO.Directory.Exists(d)) { UnityEditor.AssetDatabase.CreateFolder("Assets/Resources/TTFText", "Fonts"); } f.BuildCharSet(f.fontid); UnityEditor.AssetDatabase.CreateAsset(TTFTextFontStoreFontAsset.CreateInstance <TTFTextFontStoreFontAsset>().Init(f), "Assets/Resources/TTFText/Fonts/" + f.fontid + ".asset"); Debug.Log("Font " + f.fontid + " has been embedded"); } #endif } } return(f); }
public bool LoadAllResourceFonts() { bool added = false; Object [] loaded_fonts = Resources.LoadAll("TTFText/Fonts", typeof(TTFTextFontStoreFontAsset)); // Debug.Log("Found "+loaded_fonts.Length.ToString()+" Fonts"); foreach (Object o in loaded_fonts) { TTFTextFontStoreFontAsset asset = (TTFTextFontStoreFontAsset)o; if (GetEmbeddedFont(asset.fontname, false) == null) { embeddedFonts.Add(asset.font); added = true; } } return(added); }
public bool TryLoadAssetFont(string s) { bool added = false; Object loaded_font = Resources.Load("TTFText/Fonts/" + s, typeof(TTFTextFontStoreFontAsset) ); if (loaded_font != null) { TTFTextFontStoreFontAsset asset = (TTFTextFontStoreFontAsset)loaded_font; if (GetEmbeddedFont(asset.fontname, false) == null) { embeddedFonts.Add(asset.font); added = true; } } return(added); }