soimy / maxrects-packer

A max rectangle 2d bin packer npm-module for packing glyphs or images into multiple sprite-sheet/atlas

Home Page:https://soimy.github.io/maxrects-packer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Border padding ?

Samsy opened this issue · comments

Is there a way to add pad on glyphs that are on the edges ? like a border-padding ?

( W @ % etc.. )

DrukTextWide-Bold-oldold

It is a rare case. For now, you can do this in the compositing procedure. I will add this feature when I have time.

What do you mean with compositing procedure ?
Can you point me where this thing could happen ? I'd try to get it working if you want it
The use case would be to bake in some drop-shadow for each letters, works with padding on all of them, except on the one that are on side ( not enough space )
Many thanks

This module is meant to do just position calculation of given rects. compositing procedure is when you read the x/y/w/h and put images together with node-canvas or jimp things.

But on your case, border must be taken into account for position calculation for the final atlas description xml/json. Tweaking the algorithm cannot be just a few words.
Don't worry, I'll do it soon. Stay tuned.

btw, @Samsy are you making MSDF font generator? Take a look at my repo https://github.com/soimy/msdf-bmfont-xml
Might save you some time.

Yes I'm using this one at first, but I'm trying to bake some drop shadow into glyph, problem is.. it needs space border padding for the letter on the edges :p

Many thanks again !

One trick will be a bigger distanceRange >= your shadow shift, with --vector svg output. Dropshadow and styling can be done within each glyph rectangle.
Small distanceRange even with border, your shadow outside the glyph rectangle will be trimmed off.

@Samsy new release 2.4.0-alpha.0 include this fix, can you confirm border feature working as you expected?
Also checkout new https://github.com/soimy/msdf-bmfont-xml/releases/tag/v2.5.0