Add standalone custom font support
はちみーをなめると〜 Game enhancement and translation mod for Honse Game. Cutting edge.
Brought to you by:
kairusds
Originally created by: RanKaeder
Users must provide a Unity AssetBundle containing a compatible Font asset. Custom fonts may require line-spacing adjustments.
Closes [#70]
Originally posted by: kairusds
The problem with this feaure is that it's still hacky/janky, it never solves the issue of the process being too complex just to load a custom font (the reason why the issue is still left open). You'd either need to install Unity 2022.3 (the entire edtor) just to make a new asset bundle with the font, or do the steps below:
I also thought of dynamically loading the raw font and compiling it as an asset bundle at init time but that's out of scope for this project when similar tools exist (like UABEA).
Originally posted by: RanKaeder
@kairusds
Yeah, that’s true. [#86] could actually be implemented using the same method as well, but I don’t think the feature itself has enough general use cases.
That said, custom fonts can be shared within a specific community, so I think it’s still practical to provide them as dedicated font packs. This way, people wouldn’t need to learn how to use Unity and build the asset bundles themselves.
Related
Tickets: #86
Originally posted by: kairusds
Okay that's fair
Related
Tickets: #86
Originally posted by: kairusds
I'll do some tests for now and maybe make this feature a bit more frictionless so people won't have to manually type the asset path everytime. I'll convert this to a draft PR for now and merge it once it's ready
Originally posted by: searinminecraft
This PR is cool and all, but the screenshot made me throw up lmao
Originally posted by: kairusds
Right, I forgot to mention but please refrain from posting images like what you just sent next time
Related
Tickets:
#70Originally posted by: kairusds
@RanKaeder Check if this is much better and also test it in Windows since I'm not on my PC right now. Also please check if the translations for
custom_font_fileandcustom_font_none_foundare proper.Instead of importing an asset bundle, the new change is to make it a "font pack" with the file extension
.hachifont(it's basically just a ZIP file with a different extension) and it only contains 3 files:includes_android, includes_win(the asset bundles that contains the font) andfont_path.txtwhich contains the asset path/name to the font.The
.hachifontpack structure is like this:Users can select fonts via the
custom_font_fileoption in the ConfigEditor at the General tab. It scans thehachimifolder for these files every 3 seconds while the editor window is open.And the limits are 2GB per asset bundle and 4KB for the
font_path.txtfile. Along with this change, I also made it so that the custom fonts gets loaded via memory asynchronously instead of from the disk.This should make it easier for non-tech savvy users to import and use custom fonts with ease.
Originally posted by: kairusds
Example
.hachifontfile: https://litter.catbox.moe/o5jw44mgl66gt7lk.hachifontOriginally posted by: RanKaeder
@kairusds
I tested this on the Windows DMM client. A .hachifont pack I created works correctly, including Chinese text.
However, Chinese text does not render correctly when using the o5jw44mgl66gt7lk.hachifont pack you provided. There are no related errors in the log, so this may be caused by the bundled font not including the required Chinese glyphs rather than an issue with the loader.
Originally posted by: kairusds
Yep, the font in the bundle doesn't have Chinese characters and is just the rodin font UmaTL uses so that shouldn't be a big deal
Originally posted by: kairusds
@RanKaeder Let me know if everything's good to go now and I'll merge it
Originally posted by: RanKaeder
@kairusds Everything looks good on my end. You can merge it.
Ticket changed by: kairusds