bmGlyph and bitmap font for graphics 2.0

Thanks, I’m pretty sure I had that checked as it seemed sensible but I’ll double check when I get home.

Hi everyone,

The bmGlyph update is ready (for the non-MAS version, and under review for the MAS version) and it fixes the corona 2.0 export bug which occurred when the font was with no kernings informations.

I have also added a cool feature: shaded material. It Produces a shaded image from a height field. With this effect, you can achieve almost anything you want (sharp emboss, smooth emboss, any 3D material effect with your own material texture like plastics, glass, metals, etc…).

Untitled1.png

hope you will enjoy it :slight_smile:

cool, thanks

Hi,

I’ve just bought bmGlyph 2.1.0 off the Apple Appstore. I’m having problems with the kernings value being null. Tried both ticking and unticking yield the same results. Can anyone help?

This is the error I’m getting off the Corona compiler. 

File: bmf2.lua

Line: 157

Attempt to index field ‘kernings’ (a nil value)

I tried adding in the files from the sample build and it worked. This error only occurred when I tried adding my own custom fonts made with the software.

Thanks in advance!

Edit: I commented out the code from line 157 and it compiled without an issue. However, @2x and @4x scaling isn’t working. All I’m seeing is jumbled graphic. 

just add a nil check should do the trick

I have fixed the bmf2.lua, you can download it from there: https://github.com/tapouillo/bmf2—bitmap-font-for-Corona-graphics-2.0

it should work with the @2x and @4x suffix, can you check your config.lua and compare with the one on the github repository ?

Seems like the sample I’ve downloaded was an older version. Using the files from github fixed my problems. 

It’s working great now. Thanks!  :slight_smile:

Hi, 

Just bought bmGlyph and tried it out. Works great! 

One question: Can you change alignment? I want everything to be centre aligned by default. So I can just make my text and then do mytext.x = display.actualContentWidth/2 and it’ll always be centered.

Thanks!

hi,

sorry, but the bmf2.lua currently only support the left aligment if you have a multiple-line text. 

if you have a single line, you should be able to change the anchor point as any other object and set the x position to your width/2

Thanks for the quick reply. Strange, I do change the anchor point but it’s still never centered when I change the x position to width/2

00000056.png

Just purchased bmplyph as well. It’s a handy tool, especially since publishing to Windows Phone makes it almost mandatory.

I also noticed that I could not center the returned object properly. This is important because I have multi language buttons and I can’t be manually fixing the positions. I took the sample code and pared it down to just a single string. I drew lines in the middle of the screen vertically an horizontally so that you can see where the problem is.

I set the returned object x and y to the centre of the screen. I then changed the anchor points to 0, .5 and 1. 

Here’s the code:

require('bmf2') local dcx = display.contentCenterX local dcy = display.contentCenterY local dcw = display.contentWidth local dch = display.contentHeight display.setStatusBar(display.HiddenStatusBar) display.setDefault( "anchorX", .5) -- default to TopLeft anchor point for new objects display.setDefault( "anchorY", .5) local myfont = bmf2.loadFont( 'bmGlyphArial' ) local string = bmf2.newString(myfont, "88888") string.x = display.contentCenterX string.y = display.contentCenterY

and here are the 3 screen shots with the anchors set. Note that when the anchorX and anchorY are set to .5 the text is not centered.

I also noticed this comment in bmf2.lua

– object.align can be read/modified - left/right/center (multiline not yet fully supported for non-left)

However, when you use string.align = “center” (or left or right) it does not have any effect.

add this to see where the anchor points really are. 

function rotate() string:rotate(18) end timer.performWithDelay(100, rotate, 0)

Some more info on the .align property.

i did a test script with anchorx/anchory set to 0,0.5 and 1 respectively. For each one I then repeated with .align = left,center,right.

When anchorx/anchory are 0 or 1 .align doesn’t seem to affect anything. As you can see in the screenshot the strings are all on top of eachother. But, when anchorx/anchory = 0.5 the placement does differ but not correct. See attached screenshot where I used 9 different strings to represent their settings. i.e. 0C = anchorx/y = 0 align = center, etc.

require('bmf2') local dcx=display.contentCenterX local dcy=display.contentCenterY local dcw = display.contentWidth local dch = display.contentHeight local background = display.newRect(0, 0, dcw\*2, dch\*2) background:setFillColor(1, 1) display.setStatusBar(display.HiddenStatusBar) local myfont = bmf2.loadFont( 'CourierNew' ) local string01 = bmf2.newString(myfont, "0L") string01.x=display.contentCenterX string01.y=display.contentCenterY string01.align = "left" string01.anchorX = 0 string01.anchorY = 0 local string02 = bmf2.newString(myfont, "0C") string02.x=display.contentCenterX string02.y=display.contentCenterY string02.align = "center" string02.anchorX = 0 string02.anchorY = 0 local string03 = bmf2.newString(myfont, "0R") string03.x=display.contentCenterX string03.y=display.contentCenterY string03.align = "right" string03.anchorX = 0 string03.anchorY = 0 local string04 = bmf2.newString(myfont, "5L") string04.x=display.contentCenterX string04.y=display.contentCenterY string04.align = "left" string04.anchorX = 0.5 string04.anchorY = 0.5 string04.alpha = .3 local string05 = bmf2.newString(myfont, "5C") string05.x=display.contentCenterX string05.y=display.contentCenterY string05.align = "center" string05.anchorX = 0.5 string05.anchorY = 0.5 string05.alpha = .3 local string06 = bmf2.newString(myfont, "5R") string06.x=display.contentCenterX string06.y=display.contentCenterY string06.align = "right" string06.anchorX = 0.5 string06.anchorY = 0.5 string06.alpha = .3 local string07 = bmf2.newString(myfont, "1L") string07.x=display.contentCenterX string07.y=display.contentCenterY string07.align = "left" string07.anchorX = 1 string07.anchorY = 1 string07.alpha = .6 local string08 = bmf2.newString(myfont, "1C") string08.x=display.contentCenterX string08.y=display.contentCenterY string08.align = "center" string08.anchorX = 1 string08.anchorY = 1 string08.alpha = .6 local string09 = bmf2.newString(myfont, "1R") string09.x=display.contentCenterX string09.y=display.contentCenterY string09.align = "right" string09.anchorX = 1 string09.anchorY = 1 string09.alpha = .6 local line1 = display.newLine(dcx, 0,dcx, dch) line1:setStrokeColor(.5, .5, .5, 1) local line2 = display.newLine(0, dcy,dcw, dcy) line2:setStrokeColor(.5, .5, .5, 1)

OK, after more testing it’s obvious that centered text doesn’t work properly. The work around for me was to dump bmf2.lua and switch to bitmap font manager. https://github.com/autismuk/Font-Manager

Fixed the problem right away. You have to remember to export the fonts from bmglyph in cocos2d format to get the .fnt files instead of the .lua files. 

Hi, 

Just bought bmGlyph and tried it out. Works great! 

One question: Can you change alignment? I want everything to be centre aligned by default. So I can just make my text and then do mytext.x = display.actualContentWidth/2 and it’ll always be centered.

Thanks!

hi,

sorry, but the bmf2.lua currently only support the left aligment if you have a multiple-line text. 

if you have a single line, you should be able to change the anchor point as any other object and set the x position to your width/2

Thanks for the quick reply. Strange, I do change the anchor point but it’s still never centered when I change the x position to width/2

00000056.png

Just purchased bmplyph as well. It’s a handy tool, especially since publishing to Windows Phone makes it almost mandatory.

I also noticed that I could not center the returned object properly. This is important because I have multi language buttons and I can’t be manually fixing the positions. I took the sample code and pared it down to just a single string. I drew lines in the middle of the screen vertically an horizontally so that you can see where the problem is.

I set the returned object x and y to the centre of the screen. I then changed the anchor points to 0, .5 and 1. 

Here’s the code:

require('bmf2') local dcx = display.contentCenterX local dcy = display.contentCenterY local dcw = display.contentWidth local dch = display.contentHeight display.setStatusBar(display.HiddenStatusBar) display.setDefault( "anchorX", .5) -- default to TopLeft anchor point for new objects display.setDefault( "anchorY", .5) local myfont = bmf2.loadFont( 'bmGlyphArial' ) local string = bmf2.newString(myfont, "88888") string.x = display.contentCenterX string.y = display.contentCenterY

and here are the 3 screen shots with the anchors set. Note that when the anchorX and anchorY are set to .5 the text is not centered.

I also noticed this comment in bmf2.lua

– object.align can be read/modified - left/right/center (multiline not yet fully supported for non-left)

However, when you use string.align = “center” (or left or right) it does not have any effect.

add this to see where the anchor points really are. 

function rotate() string:rotate(18) end timer.performWithDelay(100, rotate, 0)

Some more info on the .align property.

i did a test script with anchorx/anchory set to 0,0.5 and 1 respectively. For each one I then repeated with .align = left,center,right.

When anchorx/anchory are 0 or 1 .align doesn’t seem to affect anything. As you can see in the screenshot the strings are all on top of eachother. But, when anchorx/anchory = 0.5 the placement does differ but not correct. See attached screenshot where I used 9 different strings to represent their settings. i.e. 0C = anchorx/y = 0 align = center, etc.

require('bmf2') local dcx=display.contentCenterX local dcy=display.contentCenterY local dcw = display.contentWidth local dch = display.contentHeight local background = display.newRect(0, 0, dcw\*2, dch\*2) background:setFillColor(1, 1) display.setStatusBar(display.HiddenStatusBar) local myfont = bmf2.loadFont( 'CourierNew' ) local string01 = bmf2.newString(myfont, "0L") string01.x=display.contentCenterX string01.y=display.contentCenterY string01.align = "left" string01.anchorX = 0 string01.anchorY = 0 local string02 = bmf2.newString(myfont, "0C") string02.x=display.contentCenterX string02.y=display.contentCenterY string02.align = "center" string02.anchorX = 0 string02.anchorY = 0 local string03 = bmf2.newString(myfont, "0R") string03.x=display.contentCenterX string03.y=display.contentCenterY string03.align = "right" string03.anchorX = 0 string03.anchorY = 0 local string04 = bmf2.newString(myfont, "5L") string04.x=display.contentCenterX string04.y=display.contentCenterY string04.align = "left" string04.anchorX = 0.5 string04.anchorY = 0.5 string04.alpha = .3 local string05 = bmf2.newString(myfont, "5C") string05.x=display.contentCenterX string05.y=display.contentCenterY string05.align = "center" string05.anchorX = 0.5 string05.anchorY = 0.5 string05.alpha = .3 local string06 = bmf2.newString(myfont, "5R") string06.x=display.contentCenterX string06.y=display.contentCenterY string06.align = "right" string06.anchorX = 0.5 string06.anchorY = 0.5 string06.alpha = .3 local string07 = bmf2.newString(myfont, "1L") string07.x=display.contentCenterX string07.y=display.contentCenterY string07.align = "left" string07.anchorX = 1 string07.anchorY = 1 string07.alpha = .6 local string08 = bmf2.newString(myfont, "1C") string08.x=display.contentCenterX string08.y=display.contentCenterY string08.align = "center" string08.anchorX = 1 string08.anchorY = 1 string08.alpha = .6 local string09 = bmf2.newString(myfont, "1R") string09.x=display.contentCenterX string09.y=display.contentCenterY string09.align = "right" string09.anchorX = 1 string09.anchorY = 1 string09.alpha = .6 local line1 = display.newLine(dcx, 0,dcx, dch) line1:setStrokeColor(.5, .5, .5, 1) local line2 = display.newLine(0, dcy,dcw, dcy) line2:setStrokeColor(.5, .5, .5, 1)

OK, after more testing it’s obvious that centered text doesn’t work properly. The work around for me was to dump bmf2.lua and switch to bitmap font manager. https://github.com/autismuk/Font-Manager

Fixed the problem right away. You have to remember to export the fonts from bmglyph in cocos2d format to get the .fnt files instead of the .lua files.