Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Create TextMeshPro Font Asset fails - Unity 2023.1.3, TMP 3.0.6

Discussion in 'UGUI & TextMesh Pro' started by lcompton, Jul 7, 2023.

  1. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    90
    Exceptions are being thrown when I create new TMP Font Assets from newly imported TTF and OTF fonts. This was working in 2022.3. Any idea why this is happening?

    Cannot initialize non-default texture with negative or zero width.
    UnityEngine.Texture2D:.ctor (int,int,UnityEngine.TextureFormat,bool)
    TMPro.TMP_FontAsset_CreationMenu:CreateFontAssetFromSelectedObject (UnityEngine.Object) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:220)
    TMPro.TMP_FontAsset_CreationMenu:CreateFontAsset () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:172)

    UnityException: Failed to create texture because of invalid parameters.
    UnityEngine.Texture2D.Internal_Create (UnityEngine.Texture2D mono, System.Int32 w, System.Int32 h, System.Int32 mipCount, UnityEngine.Experimental.Rendering.GraphicsFormat format, UnityEngine.Experimental.Rendering.TextureCreationFlags flags, System.IntPtr nativeTex, System.String mipmapLimitGroupName) (at <a14bafc3d16548339699574d795d5192>:0)
    UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Int32 mipCount, System.Boolean linear, System.IntPtr nativeTex, System.Boolean createUninitialized, System.Boolean ignoreMipmapLimit, System.String mipmapLimitGroupName) (at <a14bafc3d16548339699574d795d5192>:0)
    UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Boolean mipChain) (at <a14bafc3d16548339699574d795d5192>:0)
    TMPro.TMP_FontAsset_CreationMenu.CreateFontAssetFromSelectedObject (UnityEngine.Object target) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:220)
    TMPro.TMP_FontAsset_CreationMenu.CreateFontAsset () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:172)
     
  2. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    90
    I figured it out. I was creating the font asset the wrong way...

    The method that did not work...
    Right click on font file->Create->TextMeshPro->Font Asset

    The method that did work...
    Window->TextMeshPro->Font Asset Creator

    The generated assets work fine when created from the Font Asset Creator window.

    As I mentioned, the first method used to work, so this might be a bug. I'm happy I have a workaround.
     
  3. fengyushi

    fengyushi

    Joined:
    Jan 24, 2016
    Posts:
    2
    I have same problem(or bug).
    and when click on font file ->Create-> Text->Font Asset
    The editor create an asset that contains TMP Material but still a Textcore asset nor a TMP Font Asset file.
    That's really strange.
     
  4. fengyushi

    fengyushi

    Joined:
    Jan 24, 2016
    Posts:
    2
    Upgrade TMP version to 3.2.0-pre.5 can fix it .