Ghost In The Machine

BlitzMax Forums/BlitzMax Beginners Area/Ghost In The Machine

dw817(Posted 2016) [#1]
I am running into a strange error. I am wanting to create and scale a font that is 32x32 pixels. You can't load this in BlitzMAX though as you only have control over the height loaded, so I am doing a Rescale after that.

Odd thin vertical strips present themselves and only on certain characters when I do this. it's certainly a puzzle for me.

Can this be somehow circumvented and I am allowed to maintain the high quality 'square' fonts in a 32x32 field as I have them now ?




Casaber(Posted 2016) [#2]
This does not fix it competely yet but it seem to be about clamping?
I´m not sure which BMax commands override this so I stuck the commands here and there before text commands just to be sure it would be set every time.

Still there is some. But it´s different.

Strange problem it gives different results each time I run it :s

EDIT
I shut off the antalising also and went all the way but then.. there's no antialising of course, but at least there's no weird black stripes now. Not that I could see anyway.
It's a shame that it gets scaled unevenly then. But maybe that gives a clue what it is.

I´m thinking..maybe the SCALE messes up the internals of freefont text engine so it does not use integer coordinates. Just a thought.

I noticed that you could just change the original code to use SetBlend MASKBLEND to make it look rerally nice, a much more balanced scaling.
But you want heavy antialising for this?

Throwing out an idea as font are actually images in Bmax after loading it, and because SCALE makes makes a very uncontrolled blurry scale IMHO.
What about.. if you draw the font with the right width (and overdo the height as needed), and draw on something say a PIXMAP, and then use a good rescaling (hope the inbuild PIXMAP resize works nicely) to reduce the height to match the width. I think compressing that way would give the best look. Was the alpha solved using pixmaps? OR maybe even easier to try first.. to invert the scale to use not more than 1 on any scaler.
SetScale 1,28.0/TextHeight(" " ) < stretches OUT horizontally
you could calculate the inverted how much Y should COMPRESS instead? ( SETSCALE ?,1 )




dw817(Posted 2016) [#3]
I found a solution, Casaber. A strange one. But let's see if someone can solve WHY it's doing what it's doing. I'm not happy w the solution and ultimately it should still give artefacts even in the corrected code.


Casaber(Posted 2016) [#4]
Okay ya. There's a lots of small tricky corners to solve before the heavy coding can start for real. It's frustrating. I edited my post with some messy ideas.


dw817(Posted 2016) [#5]
Good Morning, Casaber.

Trying out your code, it does release the artefacts at a cost of removing the smoothness of the font. Here is a working solution to keep both, yet strange. Apparently you cannot scale fonts less than 100% vertically without having problems.




dw817(Posted 2016) [#6]
Ah, success !

I finally found a way to save Truetype Fonts as images MAINTAINING the original transparency percentage needed for each character ! Also fixes the artefact problem.



Code follows:



I'm thinking a nice GUI to allow you to convert any Truetype font to a transparent .PNG graphic table would be in order.


Casaber(Posted 2016) [#7]
WOW that'd looked good on a tshirt.
Nice.


Casaber(Posted 2016) [#8]
The black outlines got abit cutout here and there, like if it was painted outside the actual square that it was cut out from later. Is that intentionally?


dw817(Posted 2016) [#9]
Morning Casaber. YES ! If you check the code you'll see that I am deliberately making a black outline for the white text, 1 pixel above and left, and 2-pixels below and right.

In this, you can have this text appear on a very bright color and you will still be able to see it clearly.

Not now as I've got to run errands but later I wanted to make a 'fire and forget' font to image generator that can take any .TTF, no matter how its scaled or positioned, and place it in an image table of a select size perfectly.