vladimirgamalyan / fontbm

BMFont compatible, cross-platform (Linux/macOS/Windows) command line bitmap font generator (FreeType2 based).
MIT License
241 stars 38 forks source link

Fonts generated by FontBM differ from their BMFont equivalents in size #11

Closed edwinfinch closed 2 years ago

edwinfinch commented 3 years ago

Hi Vlad,

First off, FontBM seems like a great tool that should work perfectly for my project. I appreciate the work you've done with it.

I've been able to integrate it seamlessly so far, I'm just running into one issue.

I generated a font using FontBM on macOS, and I noticed the size of the characters generated by FontBM differ quite a lot from the exact same (or even slightly lesser) font size on BMFont.

BMFont

BMFont - bebas_time_large_0

FontBM

FontBM - bebas_time_large_0

This is strange since the font size on FontBM is even a tad smaller than the one on BMFont, yet the fonts themselves are still larger. You can also see this numerically by checking the width/height values of each character.

BMFont (truncated to save space)

info face="Bebas Neue" size=104 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 outline=0
common lineHeight=105 base=83 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0
page id=0 file="bebas_time_large_0.png"
chars count=11
char id=48   x=61    y=0     width=28    height=63    xoffset=3     yoffset=21    xadvance=34    page=0  chnl=15

FontBM (also truncated)

info face="Bebas Neue" size=-103 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=0,0,0,0 spacing=1,1 outline=0
common lineHeight=103 base=92 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
page id=0 file="bebas_time_large_0.png"
chars count=11
char id=48   x=1     y=149   width=34    height=74    xoffset=3     yoffset=19    xadvance=40    page=0  chnl=15

The command I'm using to generate this font is:

fontbm --font-file fonts/bebas_regular.ttf --output ./notenduro/resources-round-240x240/fonts/watchface/bebas_time_large --background-color 0,0,0 --spacing-vert 1 --spacing-horiz 1 --chars 48,49,50,51,52,53,54,55,56,57,58 --font-size 88

Is there something I'm doing wrong here?

Thank you very much for your time.

viralpatel380 commented 3 years ago

SnowB Use this instead ! Thank me later ;)

vladimirgamalyan commented 2 years ago

Hi @edwinfinch, I just tried to reproduce the problem, here is a picture to compare the glyphs (font size == 88):

image

Looks pretty the same (considering different rendering engines: WinGDI and Freetype2).

Command line for fontbm:

%fontbm% --font-file %font_file% --output %output% --background-color 0,0,0 --spacing-vert 1 --spacing-horiz 1 --chars 48,49,50,51,52,53,54,55,56,57,58 --font-size 88

Config file for BMFont:

# AngelCode Bitmap Font Generator configuration file
fileVersion=1

# font settings
fontName=Bebas Neue
fontFile=./fonts/BebasNeue-Regular.ttf
charSet=0
fontSize=-88
aa=1
scaleH=100
useSmoothing=1
isBold=0
isItalic=0
useUnicode=1
disableBoxChars=1
outputInvalidCharGlyph=0
dontIncludeKerningPairs=0
useHinting=1
renderFromOutline=0
useClearType=0

# character alignment
paddingDown=0
paddingUp=0
paddingRight=0
paddingLeft=0
spacingHoriz=0
spacingVert=0
useFixedHeight=0
forceZero=0

# output file
outWidth=256
outHeight=256
outBitDepth=32
fontDescFormat=0
fourChnlPacked=0
textureFormat=png
textureCompression=0
alphaChnl=4
redChnl=0
greenChnl=0
blueChnl=0
invA=0
invR=0
invG=0
invB=0

# outline
outlineThickness=0

# selected chars
chars=48-58

# imported icon images

I can try to reproduce the problem with your copy of bebas_regular.ttf, could you please share it?

edwinfinch commented 2 years ago

Thanks for taking a look at this Vlad!

Here's my copy of Bebas Regular: https://io.lazarus.watch/_resources/other/bebas_regular.ttf

Let me know if I can be of any more help.

vladimirgamalyan commented 2 years ago

I tried with your font, the same result, then noticed your BMFont data file contains size=104, it means "Match char height" (Font Settings dialog) is not ticked (otherwise this value is negative). In this mode BMFont/fontbm sizes don't correspondent to each other, I think it was the problem.

vladimirgamalyan commented 2 years ago

added a notify about char sizes to README