The mechanics of using a font at a certain size

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
frumpy
Posts: 361
Joined: Sat Jan 30, 2016 12:01 pm

The mechanics of using a font at a certain size

#1 Post by frumpy »

clear_font.png
Hello,

I'm trying to use an own font which I'm making pixel-by-pixel.
My goal is to use a certain gauge at 100% or 50% size without any interpolation/antialiasing
on the fonts. I played quite a lot with this, but I don't understand the system behind it yet.

Lets say I am doing a font 8x6 pixels, textsize 8 or 16 pixels, antialiasing off - it's still blurred at
the edges. I was able to do this once with clearcut edges, but I lost the font. :/

So now I am trying to create a font 30 pixels high, but everything I do - it's always blurred.
How can I continue?

User avatar
Ralph
Posts: 7924
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: The mechanics of using a font at a certain size

#2 Post by Ralph »

Are you scaling the individual blocks to a whole number?

frumpy
Posts: 361
Joined: Sat Jan 30, 2016 12:01 pm

Re: The mechanics of using a font at a certain size

#3 Post by frumpy »

Yes,take a look at the screenshot - 8 pixels high, textsize 8 and 16 are blurred (scaling 200% t see it better).

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: The mechanics of using a font at a certain size

#4 Post by Corjan »

Hi,


This is always a bit of black magic (for me at least). It is partly up to the GPU.

Would you mind sending me a small test instrument, so I can test a bit?


Corjan

frumpy
Posts: 361
Joined: Sat Jan 30, 2016 12:01 pm

Re: The mechanics of using a font at a certain size

#5 Post by frumpy »

It's a bit magic, yes.
texttestzip.zip
(5.25 KiB) Downloaded 182 times
The attached instrument uses two fonts. The blurry one (testfont2) is 8 pixels high. The sharp one (testfont) should be
8 pixels high too, but I cannot check since I did not save it. Perhaps it's a matter of wideness?
The goal is to have a font which is 30 pixels high at 100% and 15 pixels at 50% instrument scale.
I will do some more testruns to check the width at the same heigth.

Thanks for looking into it!

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: The mechanics of using a font at a certain size

#6 Post by Keith Baxter »

Hi, @frumpy

You creating your font using?

https://fontforge.org/en-US/

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Corjan
Posts: 2939
Joined: Thu Nov 19, 2015 9:04 am

Re: The mechanics of using a font at a certain size

#7 Post by Corjan »

Hi,


Just checked both fonts in FontForge.

There seem to be some differences, see screenshot. I'm not sure how fonts work exactly, but you can tell from the numbers that stuff doesn't allign perfectly.
font_comp.png

Corjan

frumpy
Posts: 361
Joined: Sat Jan 30, 2016 12:01 pm

Re: The mechanics of using a font at a certain size

#8 Post by frumpy »

There is some magic to the fontsize. To make a font at 50% clear without any interpolation,
the fontsize and position of text has to be divideable by 2.
First I measured the required fontsize from a photo of the real instrument, then made it
the same pixelheight in fontstruct. Afterwards I tried a teststring in AM at different sizes
and zoomed in to find out which one is without interpolation. I seems fontsize in AM needs
to be +2 to the height of the letter.

My main goal was to increase the TRQ/TOT/N1 readability of the EC 135 VEMD, along the
way I tuned minor details too, like coordinates, limit colors, + sign to OAT and voltage and stuff.
comparison.png
Lots of work just for a little gain, looks like Pareto was right once again :)

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: The mechanics of using a font at a certain size

#9 Post by Keith Baxter »

Hi,

I discovered something today. The quality of font placed on a canvas is largely improved if a smaller font size is placed on a smaller canvas the the canvas is resized using move()

Code: Select all

robR_20blubkbgC="font:roboto_regular.ttf; size:20px; color: #3cb7da; halign:center; valign:center;background_color:black"
my_text1_cv=canvas_add(0,0,150,40)
my_text2_cv=canvas_add(0,0,150,40)


canvas_draw(my_text1_cv, function()
    _rect(0,0,150,40)
    _fill("black")
    _txt("Hellow World",robR_20blubkbgC,75,20)
end)
move(my_text1_cv,100,100,150,40)

canvas_draw(my_text2_cv, function()
    _rect(0,0,150,40)
    _fill("black")
    _txt("Hellow World",robR_20blubkbgC,75,20)
end)
move(my_text2_cv,100,160,675,180)
NOTE: You can also compress,stretch,and distort the text.
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply