Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, Quad, 1 invisible), 7,124 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Create Fonts #222512
08/19/08 18:39
08/19/08 18:39
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
I do not know if anyone can use this, I use it for creating my fonts for tool tips and things of that nature to match the screen res I am using...for TRUE TYPE FONTS

Code:
vFont[6] = {8,12, 16, 24, 32, 48, 72}; //Size of the Fonts I want to use for each res I have in the game

//This is is Main
//video_settings[0] is just the variable I have holding my res variable.

strToolFont create_font("Airal",vFont[video_settings[0]], "b");
fnt_tool = font_create(strToolFont);

//////////////////////////////
// FUNCTION create_font(STRING* strFont, var sizeFont, STRING* strFormat)
// strFont - Name of the Font
// sizeFont = fontSize;
// strFormat = Bold Itallics 
//////////////////////////////
function create_font(STRING* strFont, var sizeFont, STRING* strFormat)
{
   STRING* tempstr = "#255";
   STRING* tempsize = "#2";
   
   str_clip(tempstr,255);
   str_clip(tempsize, 2);
   
   str_cpy(tempstr,strFont);
   
   str_for_num(tempsize, sizeFont);
   str_cat(tempstr,tempsize);
   
   str_cat(tempstr,strFormat);	
}


What it basically does is get the setting variable (I use the Widescreen Code posted here by mpdeveloper_B posted in the user contr.. and the panel refresh code by eleroux for scaling my panels to set up my panels...and then to get the correct font size of the truetype font i use the above code, which I wrote)

This way I create the font I will need when the engine runs based on the users settings...

If it confuses anyone Ill try to explain it better, as this is my first code I have posted...


John C Leutz II

Re: Create Fonts [Re: lostzac] #222518
08/19/08 18:58
08/19/08 18:58

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Nice and handy contib.
Thanx a lot!

Re: Create Fonts [Re: ] #222521
08/19/08 19:09
08/19/08 19:09
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Well I hope it helps some people with there menu systems or dialogs...I will post more code from my RPG as I prefect it, I've been working on this project for a year...lol Taken me half that time to just research and write the dang tec doc...lol


John C Leutz II

Re: Create Fonts [Re: lostzac] #229559
09/28/08 16:04
09/28/08 16:04
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Well I lost this code during a format so when I returned here to copy it back into a project I was working on I found some errors that escaped my attention so I worked on it a little and here's the new code

VECTOR desktop_size;
var vFont[5] = {8, 12, 24, 30, 36, 48};
var videoFont = 0;

void main()
{
//Set up the Menu
desktop_size.x = sys_metrics(0); // SM_CXSCREEN
desktop_size.y = sys_metrics(1); // SM_CYSCREEN
set_resolution(desktop_size.x,desktop_size.y);

//Create the MenuFonts
strToolFont = create_font("Airal",videoFont, "b");
fnt_tool = font_create(strToolFont);

//CreateMenu
pToolHud = pan_create(strToolHud,1);
panelRefresh(pToolHud);
set(pToolHud, VISIBLE);


}
STRING* strToolFont;

//////////////////////////////
// function set_resolution(x_,y_)
// Sets the screensize to the x_ and y_
//////////////////////////////
function set_resolution(x_,y_)
{
var new_ratio;
var view_aspect;

if(x_ == 640 && y_ == 480) {videoFont = vFont[0];}
if(x_ == 800 && y_ == 600) {videoFont = vFont[1];}
if(x_ == 1024 && y_ == 768) {videoFont = vFont[2];}
if(x_ == 1280 && y_ == 1024) {videoFont = vFont[3];}
if(x_ == 1400 && y_ == 1050) {videoFont = vFont[4];}
if(x_ == 1600 && y_ == 1200) {videoFont = vFont[5];}

video_set(x_, y_, 32, 1);
wait(1);
new_ratio = x_ / y_;
view_aspect = new_ratio / (4/3);
camera.aspect = view_aspect;
}

//////////////////////////////
// function panelRefresh(PANEL* sPanel)
// Rescales sPanel to fit the new resouloution
//////////////////////////////
function panelRefresh(PANEL* sPanel)
{
var HUD_reference[2] = {1600, 1200};
var PosX;
var PosY;

//Temp Postion
PosX = sPanel.pos_x;
PosY = sPanel.pos_y;

//Position
sPanel.pos_x = (screen_size.x / HUD_reference[0]) * PosX;
sPanel.pos_y = (screen_size.y / HUD_reference[1]) * PosY;

//Scaling
sPanel.scale_x = (screen_size.x / HUD_reference[0]);
sPanel.scale_y = (screen_size.y / HUD_reference[1]);
}

//////////////////////////////
// FUNCTION create_font(STRING* strFont, var sizeFont, STRING* strFormat)
// strFont - Name of the Font
// sizeFont = fontSize;
// strFormat = Bold Itallics
//////////////////////////////
function create_font(STRING* strFont, var sizeFont, STRING* strFormat)
{
STRING* tempstr = "#255";
STRING* tempsize = "#2";

str_clip(tempstr,255);
str_clip(tempsize, 2);

str_cpy(tempstr,strFont);
str_cat(tempstr,"#");

str_for_num(tempsize, sizeFont);
str_cat(tempstr,tempsize);

str_cat(tempstr,strFormat);
return(tempstr);
}

*Your pan_create I am sure will look diffrent then mine but heres how I set it up
STRING* strButton0 = "TEST";

FONT* fnt_tool;
//////////////////////////////
// Tool Hud
//////////////////////////////
PANEL* pToolHud;
STRING* strToolHud =
{
bmap = imgToolHud;
button 0, 39, buttonDn, buttonUp, buttonDn, NULL, NULL, NULL;
digits(206, 75, strButton0, fnt_tool, 0, NULL);
flags = CENTER_X, FILTER;
}

This is really an easy way to set up some dynamic menus based on your users settings Hope it works for you all now and you enjoy it


John C Leutz II


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1