Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro TMP and custom font

Discussion in 'Unity UI & TextMesh Pro' started by Brathnann, Apr 4, 2017.

  1. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    3,975
    I know TMP let's you customize a font and all that, which is great, but we need to try and get a new build out a bit quicker than messing with trying to get things the way we want in TMP currently. We have a custom font that was designed in Photoshop and we used Unity's custom font feature to create our own custom font from it. We were using a small script to curve the text, but the script is giving errors in 5.6, so we wanted to use TMP's curve text feature. Is there a way to use our custom font that we already have set up with TMP?

    Thanks!
     
  2. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    It is possible but there is not automated way of doing it. Someone would have to create a script to do it which would not be difficult.

    Here is sort of the manual steps to do it which should give you a good idea of how a script could be implemented.

    1. Using the Font Asset Creator, create a font asset using your font and make sure the atlas size and padding value kind of matches what we used in your custom font atlas. Also try to add / include the same characters. Don't worry too much about each character as you can add / remove glyph from the glyph table manually.

    2. Import your new font atlas texture and with the Inspector panel set to debug mode on the font asset, replace the existing atlas by yours. Then select the embedded material and assign your texture to it.

    3. Then switch back to normal mode in the Inspector (ie. not debug mode) then you will need to manually edit each of the glyphs in the Glyph table to match the data with your .fnt data for your custom font. This process will be painful and this is where a script that would automatically convert the data from the .fnt to this required data format be handy :)

    This should work. I am in Iceland right now with limited access but I'll be checking in whenever possible. Worst case, I will be back in the US over the weekend and can help you / create that script when I return. If you need my assistance with this, please provide me (via email) with your custom font and the .fnt file.

    P.S. I used the wrong account on this post ... oops/.
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    3,975
    Thank you. Will take a look into this and see what we can do.
     
  4. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    88
    is it possible to use Foreign characters like Simplified Chinese or Japanese with TextMeshPro? When I try using the asset creator tool, TextMeshPro only recognizes the English characters.
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    It is absolutely possible.

    You have to make sure the font you are trying to use does contain characters for those given languages.

    Also make sure the you are familiar with the various options in the Font Asset Creator to select the characters for those given languages. Please see the following video which covers all these options

     
    brennan_agm likes this.
  6. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    37
    Hi everyone

    I created with TextMesh Pro a font atlas and saved this font but I need to add another character. When opening Font Asset Creator, I cannot choose this customized font I created, therefore I would have to create the Atlas again but I don't remember the settings I originally used.

    Is there a way to edit the Font Settings I used in Asset Creator, or even better a way to add another character to this atlas existing font? Bear in mind Asset Creator does not let me choose the TMP font I generated in Asset Creator, else it'd be straight forward.

    Thank you, Sergio
     
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    The potential key settings to retain would be Atlas size, Sampling Point Size and Padding value and of course what characters were contained in the previous font asset.

    The Sampling Point Size, Padding and Atlas size are listed in the font asset inspector. In terms of the characters previously contained in the font asset, when selecting Character Set options in the font asset creator like custom characters, you can specify another font asset (or the one you are trying to update) and it will pull the characters contained in that asset. See the following video about this.

    Lastly, you can save over the original font asset and this will retain its meta data / GUID and assignments. It will also update all material presets that were using this font asset's atlas texture (provided you follow the naming convention on material presets which is to retain the name of the font in the material preset name like "Arial SDF - something".
     
  8. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,504
    I'm having a heck of a time trying to figure out how to use my custom created font with Text Mesh Pro. It says it has support for bitmap fonts, but I see no way to drag and drop my own atlas and text file information. I have always used BMfont to put out my text file information and the texture map. It's worked like a charm in NGUI but I couldn't find a way to get it to work with Unity's built-in UI. Does the built in UI also not support bitmap fonts? Or better yet Text Mesh Pro supports custom bitmap fonts created externally?
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    Is your external font atlas texture edited in some external tool or are we just talking about a non edited font file?
     
  10. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,504
    It's an atlas texture and .fnt file produced out of an external tool called BMfont.
     
  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    I am familiar with BMFont. Just trying to figure out if you edited the font atlas texture produced by BMFont in Photoshop or if you simply generated a plain font atlas textures and .fnt.
     
    JamesArndt likes this.
  12. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,504
    Ah yes edited in Photoshop, using it as a PSD. I've updated the file path in the text file BMfont spits out so it's referencing the correct atlas.
     
  13. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    Although you can use a custom font atlas with TextMesh Pro, the process to make this work isn't very user friendly.

    If you can provide me (via PM or email) with the font atlas texture and .fnt file, I'll take a look to see if I can make that easier and if not (due to time constrains) at least provide you with some workflow to make it work.
     
  14. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,504
    Thank you very much for taking the time to help me, and to be willing to look into it. I actually just bit the bullet and tried a new workflow of using Text Mesh Pro's built in workflow. Turns out it has so many features you can put on a text object I don't really need to use Photoshop. I really only needed to add a beveled edge and a metallic texture over the font. When I first messaged on here for help I had no idea Text Mesh Pro had the ability to do all of the things I needed right inside of Unity. Again, thank you for responding so quickly and for offering support.
     
    Stephan_B likes this.
  15. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    You are most welcome :)
     
  16. jankymidget

    jankymidget

    Joined:
    Jul 26, 2015
    Posts:
    7
    Are there any optimizations that need to be made when using Text Mesh Pro or does it already atlas everything? I know nothing about the topic.
     
  17. vdogamr

    vdogamr

    Joined:
    Feb 23, 2018
    Posts:
    5
    I am using Unity 2018.1.6 and, I believe, TextMesh Pro 1.2.2. When I open the Asset Creator and click on the generate button, nothing happens. No errors are thrown and no atlas is generated. The button just clicks.

    Is there something I can do to figure out what is wrong? Is there a way to get it to work?
    Thanks for any help.
     
  18. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    What font are you using as source?

    What character set / ranges have you defined?

    Either the font file is invalid at which point you should be getting an error message in the console. Make sure you upgrade to version 1.2.4 from the package manager.

    If not the font file, then you might have select / defined a character range that doesn't contain any characters.

    See the following video which provides in depth explanation of the features / options of the Font Asset Creator.
     
  19. vdogamr

    vdogamr

    Joined:
    Feb 23, 2018
    Posts:
    5
    I am using Arial. I made a new project to just test using TextMesh Pro. I did not specifically add Arial to my project, so maybe I should pick a new one and add it specifically.

    As for ranges... I have tried all sorts of values. Granted, my original intent was to render the hiragana and katakana at ranges 3040 - 30FF, but then I just tried to render ASCII values. My final attempt was to do nothing other than select the font. I figured the default values would be the most likely to work.


    UPDATE:
    I tried copying a font from my WIndows/Font folder into my Assets folder. It worked. (Still using 1.2.2) I guess whatever font is selectable by default does not work. Still wish I received an error message, but I am glad it works now.
     
  20. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    The Arial font includes in Unity is not a valid font. In version 1.2.4 of the TMP UPM package, you should get a message / error from the Font Asset Creator when trying to use this font.

    This is the type of message that should be displayed in the Console:

    "Font Asset Creator - Error Code [Invalid_File_Path] has occurred trying to load the [Arial] font file. This typically results from the use of an incompatible or corrupted font file."
     
  21. Fledered

    Fledered

    Joined:
    Jun 15, 2017
    Posts:
    6
    Hello,

    I have this error message EVERY TIME and I can't do anything to prevent this. I tried everything.

    Help me, please...
     
  22. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    You have this error when using which font file? Can you provide a link to this font?

    Can you provide more insight on the steps you take to reproduce this error?
     
  23. Fledered

    Fledered

    Joined:
    Jun 15, 2017
    Posts:
    6
    Thank you for the reply !

    I tried with ttf and otf.

    I just import a downloaded font in Unity and when I try to generate a font atlas, I have the error message.

    It worked with a font included in another asset, but when I moved this font outside the project and reimported it, it didn't work.
     
  24. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    Can you create a video showing how you are doing these steps? This would help me identify where perhaps the issue is.

    Can you provide me with a link to one of the fonts you are tried that gives you an error? I would like to try the same font on my end.
     
    Fledered likes this.
  25. Fledered

    Fledered

    Joined:
    Jun 15, 2017
    Posts:
    6
  26. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    I just tried on my end using the "Some Time Later" font and it worked fine as you can see in the image below.

    upload_2018-9-9_1-53-54.png

    What version of Unity are you using?

    Anything special about the location of the project? Is the project located on some network drive or something?

    See if you get the same behavior in a new project?
     
  27. Fledered

    Fledered

    Joined:
    Jun 15, 2017
    Posts:
    6
    I use 2018.2.6f1, my project is on my computer.

    I tried with a new project and it worked.

    I'm really confused.
     
  28. Fledered

    Fledered

    Joined:
    Jun 15, 2017
    Posts:
    6
    But I can create TMP asset in the new project and import them in the original one.
     
  29. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    It is pretty strange indeed.

    The issue could be related to file permissions in your main project. Maybe...

    Another asset / plugin could be interfering with this as well. One way to verify this would be to add those plugin one at a time in the new project and testing if you eventually get that error back.
     
  30. veboys

    veboys

    Joined:
    May 26, 2014
    Posts:
    4

    I have the exactly same issue which @Fledered had with a different font. the font file is in the attachement.

    I have tried it in a new project, everything works fine, but not work in my main project with the log below:
    I am using Unity2018.2.1f1 and TMP1.2.4
     

    Attached Files:

  31. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    Just tested the font and it is working as expected.

    What happens if you (1) change the import settings on that font file. Maybe switch from Dynamic to Unicode just to see if that makes a difference. (2) if you still get the error, try deleting the font file and then re-importing it to see again if the error persists.
     
  32. veboys

    veboys

    Joined:
    May 26, 2014
    Posts:
    4
    I have tried these 2, the error persists!
     
  33. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,727
    But only in your existing project. Correct?

    What happens if you import that font file again but in a different folder?

    Issue has to be with some file permission or some corrupted data somehow. The challenge is figuring out what is causing this.
     
  34. veboys

    veboys

    Joined:
    May 26, 2014
    Posts:
    4
    Thank you very mush, Stephan!
    Finally, it works! I put the font file in a folder which is named in chinese before, when I chagne the folder name into engilsh, the error is gone!
     
    Stephan_B likes this.