Artifacts when drawing scaled text
Monkey Forums/Monkey Programming/Artifacts when drawing scaled text
| ||
Hi all, I made my own font and used Set Font and then used Scale 2,2 to draw it, and after I figured out that the x,y DrawText coords are also scaled, I finally got an output like this: (actual font I'm using has a transparent background) You can see there are various artifacts around the letters. I compiling as HTML 5 and viewing in Firefox. Perhaps it's better in other targets (not tested yet). As you can see my font chars are 12x12 and I've left a 2 pixel gap on the right and beneath each letter. What seems to be happening is each letter is drawing a small amount of the letter underneath it and the letter to the right of it from the main font texture. I'm sure I could fix this by shifting each of my characters one pixel right and down so that there's a gap all around each letter, although this will screw up the comma and semi-colon unless I add yet more padding. I'm just wondering if people have found a better solution, apart from writing their own bitmap font class (and would that also suffer from the same problem anyway?) A secondary issue is, when scaled up the text is smoothed. Normally this is a good thing, but in this case I'd like to turn off smoothing. Is that possible? Thanks for any pointers! |
| ||
double post :/ |
| ||
With the artifacts, have a mess around with the XYPadding flag in LoadImage... A secondary issue is, when scaled up the text is smoothed. Normally this is a good thing, but in this case I'd like to turn off smoothing. Is that possible? You need to hack mojo: http://www.monkeycoder.co.nz/Community/posts.php?topic=993 |
| ||
Yeah I used the XYPadding flag but it chopped off the top and left edges of pixels. I thought it was going to pad my image automatically, but instead it assumes my image is already padded. Not quite the same. |
| ||
Hey great hack, I liked your example in Flash. I prefer not to hack mojo unless absolutely necessary. Would love it if this hack was added to the "official" version. |
| ||
I havent really played much with the XYPadding to be honest... Actually I think the artifacts might be due to the filtering, so I would alter Mojo and see if that fixes both your issues. |
| ||
AngelFont is your friend, IMO. |
| ||
and so is http://ooeyug.com/texpac |
| ||
Thanks, will check out. |
| ||
@Grey Alien I had a similar issue with a texture atlas of sprites that I'm using in my game. The only method I found that worked is what you mentioned in the beginning. I have a 1 pixel padding around each sprite in the atlas. This should be the case for bitmap font sheets as well. I'm convinced it's the filtering that is causing it, and I haven't found a way of turning it off or changing the filtering method. |
| ||
Thanks Rus. I'll certainly bear this in mind for all future stuff I do in Monkey. I used to pad images/textures in BlitzMax anyway due to minor issues but it was never as bad as this. |