Git Product home page Git Product logo

unity-bitmapfontimporter's Introduction

Bitmap Font Importer

Test Donate

Bitmap Font Importer is just perfect Unity asset plugin to import any custom bitmap font to your project.
It easy imports any bitmap font generated by third party tools like:littera, bmGlyph, Glyph Designer 2, ShoeBox or Bitmap Font Generator

Thiks @Xylph, this origin code form here

Feature

  • Free
  • Auto Import bitmap fonts
  • Support XML and Plain text format of .fnt
  • Support Multi texture
  • Reimport exists bitmap font
  • Source Code on Github
  • Tested with Unity 2019.4 and 2020.3
  • No runtime resources required
  • No scripting required

Install

Using npm (Ease upgrade in Package Manager UI)Recommend

Find the manifest.json file in the Packages folder of your project and edit it to look like this:

{
  "scopedRegistries": [
    {
      "name": "My Registry",
      "url": "https://registry.npmjs.org",
      "scopes": [
        "com.litefeel"
      ]
    }
  ],
  "dependencies": {
    "com.litefeel.bitmapfontimporter": "3.3.0",
    ...
  }
}

Using git

Find the manifest.json file in the Packages folder of your project and edit it to look like this:

{
  "dependencies": {
    "com.litefeel.bitmapfontimporter": "https://github.com/litefeel/Unity-BitmapFontImporter.git#3.3.0",
    ...
  }
}

Using .zip file (for Unity 5.0+)

  1. Download Source code from Releases
  2. Extract the package into your Unity project

How to Use?

Please see here

Support

unity-bitmapfontimporter's People

Contributors

eduardbosch avatar gitter-badger avatar litefeel avatar stelabouras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-bitmapfontimporter's Issues

URL did not work for Unity Package Manager (Unity 2018.4.1f1)

Had to fumble a bit with the url, partially my fault due to mistyping, but also because the #UMP did not work. It came back with an error before the program could even open, continuing resulted in the package not downloading from repo.

Did work with this added to manifest.json instead of following the README:
"com.litefeel.bitmapfontimporter": "https://github.com/litefeel/Unity-BitmapFontImporter.git"
(note that I did not use #UMP for the git url)

Doesn't work!

I have followed the suggested steps but it doesn't work in unity 5.4 . I cannot set the font on my test object, even with the ones provided by the plugin. Am I missing something?

Thanks!

Feature Request: Support font outlines

I tried to import a BMFont font with outlines and it didn't display correctly (displayed all garbled). I'm on Unity 2019.1. Would be awesome if this supported that.

Error with spaces in file path on OS X

The importer errors out if I try to import fonts from a path name with spaces in it. For example, the fnt file has the following path in it "file="/Users/damjanmozetic/Desktop/Call of Saregnar/Fonts/CoS\regular-export.png". The path of the files in the unity project is "/Users/damjanmozetic/Desktop/Call of Saregnar/Assets/_Game/Resources/regular-export.fnt".

litefeel.BFImporter: not found 'Assets/_Game/Resources//Users/damjanmozetic/Desktop/Call'.
UnityEngine.Debug:LogErrorFormat(Object, String, Object[])
litefeel.BFImporter:DoImportBitmapFont(String) (at Assets/BitmapFontImporter/Editor/BFImporter.cs:72)
litefeel.BFImporter:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/BitmapFontImporter/Editor/BFImporter.cs:16)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

Can't modify Character Space.

Hi,
I try to generate font from ShoeBox, then use ingame, but Character Space too wide, so i try all seting on FontSetting, but nothing change. I can't find any option to modify Character Space. Did BitmapFontImporter support this?

bitmap-4

Invalid file format when using TextMesh Pro Font Asset Creator

imported my png and fnt files , which are working good with any other tools outside Unity.
Generated .fontsetting file works good with Canvas/Ui/Text , but to work with TextMesh Pro I try to generate Font Atlas with "Font Asset Creator" and get error:

Font Asset Creator - Error Code [Invalid_File_Format] has occurred trying to load the [Arial] font file. This typically results from the use of an incompatible or corrupted font file. UnityEngine.Debug:Log(Object) TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow:DrawControls() (at Library/PackageCache/[email protected]/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:669) TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow:OnGUI() (at Library/PackageCache/[email protected]/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:257) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Any ideas what is causing this ?

[XML] Parse failed when XML contains comments.

Unity version : 2021.1.10f1
Importer version : 3.2.0

XML Content (abstract)

<?xml version="1.0"?>
<font>
  <info face="Waffleche" size="11" bold="0" italic="0" charset="" unicode="1" stretchH="100" smooth="0" aa="1" padding="2,2,2,2" spacing="3,3" outline="0"/>
  <common lineHeight="11" base="9" scaleW="1024" scaleH="1024" pages="1" packed="0" alphaChnl="0" redChnl="4" greenChnl="4" blueChnl="4"/>
  <pages>
    <page id="0" file="Waffleche_0.png" />
    <page id="1" file="Waffleche_1.png" />
  </pages>
  <chars count="2522">
    <!--Input icons-->
    <char id="9435"  x="1"   y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9441"  x="14"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9424"  x="27"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9425"  x="40"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9447"  x="53"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9448"  x="66"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9383"  x="79"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9389"  x="92"  y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="65324" x="105" y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="65330" x="118" y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="65291" x="131" y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9442"  x="144" y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="9436"  x="157" y="1" width="11" height="11" xoffset="2" yoffset="1" xadvance="13" page="1" chnl="15"/>
    <char id="8679"  x="169" y="1" width="22" height="11" xoffset="2" yoffset="1" xadvance="24" page="1" chnl="15"/>
    
    
    <!--Fonts-->
    <char id="10" x="6" y="6" width="9" height="12" xoffset="-2" yoffset="-1" xadvance="6" page="0" chnl="15" />
    <char id="32" x="23" y="6" width="22" height="5" xoffset="-8" yoffset="8" xadvance="6" page="0" chnl="15" />
    <char id="33" x="6" y="26" width="5" height="12" xoffset="1" yoffset="-1" xadvance="6" page="0" chnl="15" />
    <char id="34" x="6" y="46" width="7" height="6" xoffset="0" yoffset="-1" xadvance="6" page="0" chnl="15" />
...

Stack trace

NullReferenceException: Object reference not set to an instance of an object
litefeel.BFImporter.Editor.FntParse.ToInt (System.Xml.XmlNode node, System.String name) (at Library/PackageCache/com.litefeel.bitmapfontimporter@f6dbf0be50/Editor/FntParse.cs:111)
litefeel.BFImporter.Editor.FntParse.DoXMLPase (System.String& content) (at Library/PackageCache/com.litefeel.bitmapfontimporter@f6dbf0be50/Editor/FntParse.cs:79)
litefeel.BFImporter.Editor.FntParse.GetFntParse (System.String& text) (at Library/PackageCache/com.litefeel.bitmapfontimporter@f6dbf0be50/Editor/FntParse.cs:41)
litefeel.BFImporter.Editor.BFImporter.DoImportBitmapFont (System.String fntPatn) (at Library/PackageCache/com.litefeel.bitmapfontimporter@f6dbf0be50/Editor/BFImporter.cs:42)
litefeel.BFImporter.Editor.BFImporter.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Library/PackageCache/com.litefeel.bitmapfontimporter@f6dbf0be50/Editor/BFImporter.cs:16)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at <5e558c48ff1a4d2c8e2f0193394d0750>:0)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at <5e558c48ff1a4d2c8e2f0193394d0750>:0)

Can't use BestFit option.

Hi,
Thank you for best BitMap font importer.
I'm using it right now, but have 1 issue, i can't use BestFit option of Text. It always keep only 1 size, and not resize text inside border rect of RectTransform like normal Unity UI Text.
So did i miss something or currently this plugin not support this feature?
Many thank!

Problem in Unity 5.5

As mentioned in the comments on the Asset Store there is a problem that occurs after updating to Unity 5.5. At first I thought something had changed in Unity which broke the import entirely. After importing a font it does not render at all. Fonts that had been imported with an older version of Unity work fine until you re-import them. In the process of checking for changes in the generated files I found that there was no change after re-importing them. Then I stumbled upon the fact that closing and re-opening the Unity project fixed the problem.

So bottom line is that the plugin does still work in Unity 5.5 but it requires a restart after importing fonts. With this in mind it might be possible to reload some assets programmatically after importing.

Wrong regular expression

Hi,

this is an excpert of the .fnt-file I tried to use your BitmapFontImporter on:

info face="D:\someFolders\Fonts\fontGUI_shoe-export" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
common lineHeight=18 base=26 scaleW=98 scaleH=98 pages=1 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0
page id=0 file="D:\someFolders\Fonts\fontGUI_shoe-export.png"
chars count=67
char id=48 x=44 y=72 width=10 height=12 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 letter=\"0\"
char id=49 x=91 y=28 width=6 height=12 xoffset=0 yoffset=6 xadvance=7 page=0 chnl=0 letter=\"1\"
char id=50 x=22 y=69 width=10 height=12 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 letter=\"2\"
...
char id=89 x=0 y=15 width=10 height=14 xoffset=0 yoffset=4 xadvance=11 page=0 chnl=0 letter=\"Y\"
char id=90 x=0 y=0 width=10 height=14 xoffset=0 yoffset=4 xadvance=11 page=0 chnl=0 letter=\"Z\"
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=6 page=0 chnl=0 letter=\" \"
char id=9 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=48 page=0 chnl=0 letter=\"	\"

kernings count=0

It struggled with the last to lines with the space and the tab which gave some exceptions. I debugged it and found out, that your regular expression has a problem with that.
I modified your regular expression to the following and now it's working:

I changed FntParse.cs, line 124 from
pattern = new Regex(@"\S+="".+?""|\S+");
to
pattern = new Regex(@"\S+=\\"".+\\""|\S+");

Minus font size and m_Descent problem (for Bitmap Font Generator)

I generated a bitmap font by Bitmap Font Generator, then imported it by BitmapFontImporter. But, there was someting wrong:

  1. With the option "Match char height", Bitmap Font Generater wote a minus font size.
    But, BitmapFontImporter cannot handle the minus font size.
  2. BitmapFontImporter didn't write the m_Descent property to a .fontsetting file.
    I think without the m_Descent, UnityEngine.UI.Text component cannnot align text to the bottom of the rect (UnityEngine.TextAnchor.Lower*).

So, I wrote a patch to fix those problems.

I tested it on Unity 5.4.4p1 for Windows 64bit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.