-
Hi, I searched around on here and discord but couldn't find any info on how to package a font into the p_fa.mpc file. Do you need to use unity for it or did someone write some code to do it? Also, is it possible to extract fonts from existing p_fa.mpc files? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I spent a little while playing around with this and I figured out how to bundle a font into p_fa.mpc. Note: This is for developers who want to ship a font with Memoria. If you just want to use a custom font in-game for yourself then follow the steps below by @Tirlititi. In order to import a font, it must be inside a Unity asset bundle. When you use Unity to generate the font asset it automatically generates a texture and material that are needed too. I couldn't figure out any way to import a font directly and get these to generate during runtime. You can use The Here are the steps for bundling a custom font:
using UnityEditor;
using UnityEngine;
using System.IO;
public class CreateAssetBundles
{
[MenuItem("Assets/Build AssetBundles")]
static void BuildAllAssetBundles()
{
string assetBundleDirectory = "Assets";
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.UncompressedAssetBundle, EditorUserBuildSettings.activeBuildTarget);
}
}
FF9_Data\EmbeddedAsset\FA
var newFontBundle = AssetBundle.CreateFromFile(PATH_TO_FONT_BUNDLE);
EncryptFontManager.defaultFont = EncryptFontManager.LoadFont(newFontBundle.LoadAsset<Font>("alpha brights")); You need to make sure the string passed to If all goes well you should see your font being used in-game.
Byte[] bundleBytes = AssetManager.LoadBytes("EmbeddedAsset/FA/fontBundle");
Byte[] encrypted = ByteEncryption.Encryption(bundleBytes);
System.IO.File.WriteAllBytes(PATH_TO_WRITE_FILE_TO, encrypted); If you put this code in the
|
Beta Was this translation helpful? Give feedback.
-
Thanks for this. It is interesting for generating
|
Beta Was this translation helpful? Give feedback.
-
@Tirlititi Yes, thank you for clarifying this. I should have mentioned that this is for developers who want to send font files to others along with Memoria. If you just want to use a custom font for yourself, then you can follow the directions you gave. |
Beta Was this translation helpful? Give feedback.
I spent a little while playing around with this and I figured out how to bundle a font into p_fa.mpc.
Note: This is for developers who want to ship a font with Memoria. If you just want to use a custom font in-game for yourself then follow the steps below by @Tirlititi.
In order to import a font, it must be inside a Unity asset bundle. When you use Unity to generate the font asset it automatically generates a texture and material that are needed too. I couldn't figure out any way to import a font directly and get these to generate during runtime. You can use
Font.CreateDynamicFontFromOSFont()
but this only works for fonts already installed on the users system.The
p_fa.mpc
file is just an…