Author Topic: Font Maker fails  (Read 3648 times)

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Font Maker fails
« on: February 20, 2013, 01:39:37 PM »
I've been making fonts and atlases for a project in the past few days without a problem, but today, every font I try to make fails in the same way -- after i make the font, the font prefab is missing a sprite, and the new font has not been added to the font atlas. Throws an error when I look at the font prefab, below. Any suggestions?


NullReferenceException: Object reference not set to an instance of an object
UIFontInspector.OnPreviewGUI (Rect rect, UnityEngine.GUIStyle background) (at Assets/NGUI/Scripts/Editor/UIFontInspector.cs:277)
UnityEditor.Editor.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background)
UnityEditor.Editor.DrawPreview (Rect previewPosition)
UnityEditor.InspectorWindow.DrawPreviewAndLabels ()
UnityEditor.InspectorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font Maker fails
« Reply #1 on: February 20, 2013, 08:38:16 PM »
Might be some issue with the font's name? The line it fails on suggests that the font is null.

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Font Maker fails
« Reply #2 on: February 21, 2013, 11:20:41 AM »
Turns out it was a problem with GlyphDesigner -- quitting and relaunching that app solved it. Weird.

DoctorWhy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Font Maker fails
« Reply #3 on: February 21, 2013, 06:32:50 PM »
I am having this same exact problem. I first made the font with BMFont, and it looked like shit. So I replaced it and it still looked pretty bad. I tried to replace it again, and all of a sudden, every font is now throwing that error. All my previous fonts work (I can't preview any of the fonts because of that error), but I can't get the new font to work at all (it gets put on the atlas, but no text appears when running it). The font name is just "Apex_21", which didn't have a problem at all the last 2 tries. I don't know what GlyphDesigner is (a BMFont alternative?), so I can't just restart that. I tried remaking the Font in BMFont, but it still doesn't work. Maybe some type of issue occurred when I made the font bold in BMFont?  I don't know. But now the font maker is completely broken and won't work at all.

Attached is the font. I made it bold, size 21 when it broke.

EDIT:

In OnPreviewGUI on UIFontInspector, changing
  1. Texture2D tex = mFont.texture;

to
  1. Texture2D tex = null;
  2. if(mFont != null)
  3.     tex = mFont.texture;

Seems to have fixed the error and the fonts now work again, and I can bring in new fonts.  I feel this is just covering up an issue, but it will work for me for now.

EDIT 2:
I don't know if this has anything to do with it, but if you look at the preview image I attached (TextStretch.png), that is how the preview looks for just that one. It doesn't look like that in the actual text or the atlas, so it isn't really a big deal. But since the image sits at the very bottom of atlas, it is previewing strangely. Just thought I might want to point that out.
« Last Edit: February 21, 2013, 07:41:45 PM by DoctorWhy »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font Maker fails
« Reply #4 on: February 21, 2013, 10:00:26 PM »
The bleeding you see is due to the font being on the bottom as you noticed, and it's fine. The texture is set to be clamped on the edges. I will add the null check for the font being null... but it's strange that it would happen. I guess OnPreviewGUI is being called before OnInspectorGUI? Unity 4?

DoctorWhy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Font Maker fails
« Reply #5 on: February 22, 2013, 11:43:06 AM »
Ya, Unity4. By the looks of it, OnInspectorGUI is being called before OnPreviewGUI, and now I can't get mFont to be null.  Strange.