Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Font point size adjusted for same size on all displays

Author
Message
Daryn Alsup
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Apr 2013 03:20
How do I calcualte the correct font size so that it occupies the same amount of space on the screen on all display modes? I have no idea but I'm trying to find a correlation between point size and screen size. Any ideas or suggestion

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Apr 2013 21:43
Hello,

First you have to decide what the ideal display is for your fonts. Maybe you think 1024X768 is ideal (realizing that the screen display may differ). For your ideal display size with your ideal font size, find the ratio of the width and height of the text against the screen size.

It won't be exact put a pretty good width to use is a capital Q

idealfontwidth=TEXT WIDTH("Q")

A decent measure for font height are the letters "gM"

idealfontheight=TEXT HEIGHT("gM")

Now find the relationship between the screen width and height and the font sizes:

widthratio#=idealfontwidth/idealscreenwidth
heightratio#=idealfontheight/idealscreenheight

Maybe save these values in a setup file or something to be used for whatever display is required. You are only creating and saving these once ahead of time outside of the program that you intend to have varying display sizes. These values ARE NOT created within the program you want to resize the font in.

In the program that the display may vary from computer to computer or for wahtever reason, load in the values from a file or hard code them into the source.

The new font size is always based on the font height (at least that's how it used to be) so use the font height ratio to set the new font size:

fontsize=screen height() * heightratio#
SET FONT SIZE fontsize

You can use the width ratio to help you tweak

Enjoy your day.
Daryn Alsup
16
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Apr 2013 16:37
How do most games do it (asking how c++ does it here) There has to be some dll out there or in the system folders that calculates it... something that all games call or use in majority - for example the font of windows gui is always hard set, unless you change it in display settings...

I will look into this method and fool around with it like im a slut.

I see a lil' byte, its 1/4th a dword, Double float, Double float - but it doesnt beat a Global. Very very frightning, integers dividing me! Look a constant oh a constant. Oh-oh I just want the byte!
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Apr 2013 17:02
They'll all do it the same way. Change the size based on the display height.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]

Login to post a reply

Server time is: 2025-05-17 20:52:46
Your offset time is: 2025-05-17 20:52:46