Search Unity

TextMesh Pro Looking for a system to easily create dynamic SDF fonts out of system fonts as fallback

Discussion in 'UGUI & TextMesh Pro' started by timrobin, Oct 23, 2020.

  1. timrobin

    timrobin

    Joined:
    May 31, 2017
    Posts:
    8
    Hello Stephan :) First let me thank you for supporting all our TMP requests and needs so vigorously over the past years, that system really has come very far and it's very pleasant to use it :)

    I was wondering if there are plans to make it possible to easily support dynamic SDF system fonts.
    We use a custom static SDF font in our game - all good. However now we are approaching launch and with it localization into different languages, including of course japanese, chinese and korean and all the fun that comes with it :)
    Now we could of course include the fonts in our game and create dynamic SDF fonts out of them, but because of application size concerns (since it's a mobile game) it's not trivial to do.

    The real question: I noticed that with the old `Text` Unity component, it somehow knows how to fall back to fonts that can just render the glyphs wanted. Throwing cyrillic, japanese, traditional chinese, whatever at it - it just renders it, even if it falls back multiple times and of course doesn't match the style of the game. But there's _something_.

    I think I know from an answer from you one or two years ago, that you would like to give programmers as much freedom to customize and take control over the look of their game as possible - but I'm still wondering if it would be possible to also have somehow an easy way to use what seem to be Unity/system fonts for dynamic atlases as fallback languages, because sometimes the effort to program this system by ourselves for TMP is just too expensive (even though there are methods like Font.CreateDynamicFontFromOSFont and so) ):

    For example it's not possible to create a dynamic font out of the "Arial" that seems to come with Unity and seems to be included in every Unity app on every device and seems to be able to render every glyph there is (if that's the case) - are there plans/could you build that support for us, please? :)

    For now we will use TMP for all the static text in the game and the old `Text` component for player names/guild names/chat messages, even though they look pretty pixelated, because we currently don't have the resources and I can't seem to find a system done by someone else in the internet yet.

    Thank you for your time and I'm sorry about the long post ._.
    All the best
    Tim
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since I was about to go to sleep, here is the quick and short answer so you don't have to wait 8 or more hours before I reply.

    I will be adding a new font asset type which will "Dynamic OS" where it will behave like any other dynamic font asset in the Editor. However, unlike Dynamic font assets where the referenced source font file is included in the build, it will not with Dynamic OS font assets.

    When the font asset is first loaded on the target platform, TMP will get / cache the path and names of all font files on the platform and then provided it finds a font file matching the one referenced by the dynamic font asset, will use that font file as it source.

    Just like the other font asset types, you will be able to assign Dynamic OS font assets as local fallbacks to another font asset or as global fallback. The order in which they appear in the local or global fallback list will determine which one gets used first.

    If the source font file referenced by a dynamic OS font asset is not available on the target platform, it will be skipped. This will enable users to define a list of dynamic OS font assets for multiple target platforms.

    A list of font files present on most major platforms is available from those companies. Most of these fonts are also available for download so you can import them in Unity to create dynamic OS font assets using them.

    Using actual font assets as opposed to just some name reference, will enable users to define their Generation Settings and even tweak face metrics as needed to make sure these work well with any other font assets. Furthermore, this will ensure from a quality assurance point of view that the font file used in the editor will be the same and look the same as the one(s) on the target platforms.

    Multi Atlas texture support will be available for Dynamic OS font assets as well thus enabling them to potentially handle every single glyph contained in those system font files.

    In terms of ETA, I am planning on introducing those in the next release cycle which will be version 1.6.x for Unity 2018.4, version 2.2.x for Unity 2019.4 and version 3.1.x for Unity 2020.x. These might not be in the first preview release but will follow shortly thereafter.
     
    Baydogan and timrobin like this.
  3. timrobin

    timrobin

    Joined:
    May 31, 2017
    Posts:
    8
    That sounds really neat, looking forward to it! Thank you for your swift reply and have a good night! :)