Post: How do I center engine text?
01-09-2017, 01:11 AM #1
TheGreenPlanet
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); So ive been trying to get the width of a text so i can do whatever i want with it but it doesn't work :( my func looks something like this:
struct Font_s
{
int fontName;
float pixelHeight;
int glyphCount;
int material;
int glowMaterial;
int glyphs;
};


void*(*R_RegisterFont)(const char * font, int imageTrac)
int (*R_TextWidth)(const char *text, int maxChars, Font_s *font)
Font_s* (*R_NormalizedTextScale)(void *font, float scale) //This is actually a float

float GetTextWidth(const char *Text, const char *font, float scale)
{
return (float)R_TextWidth(Text, sizeof(Text), R_NormalizedTextScale(R_RegisterFont(font, 0), scale);
}

plz help Smile

btw the game calls it like this:

R_TextWidth(Text, sizeof(Text), UI_GetFontHandle(scr, font, scale));

but i dont want to use scr or any UI_ func cause theyre annoying.
Last edited by TheGreenPlanet ; 01-09-2017 at 01:17 AM.
01-11-2017, 03:44 AM #2
S63
Space Ninja
Originally posted by TheGreenPlanet View Post
So ive been trying to get the width of a text so i can do whatever i want with it but it doesn't work :( my func looks something like this:
struct Font_s
{
int fontName;
float pixelHeight;
int glyphCount;
int material;
int glowMaterial;
int glyphs;
};


void*(*R_RegisterFont)(const char * font, int imageTrac)
int (*R_TextWidth)(const char *text, int maxChars, Font_s *font)
Font_s* (*R_NormalizedTextScale)(void *font, float scale) //This is actually a float

float GetTextWidth(const char *Text, const char *font, float scale)
{
return (float)R_TextWidth(Text, sizeof(Text), R_NormalizedTextScale(R_RegisterFont(font, 0), scale);
}

plz help Smile

btw the game calls it like this:

R_TextWidth(Text, sizeof(Text), UI_GetFontHandle(scr, font, scale));

but i dont want to use scr or any UI_ func cause theyre annoying.


There's no point in explaining here as this should answer your question -> You must login or register to view this content.
01-11-2017, 09:08 AM #3
TheGreenPlanet
Do a barrel roll!
Originally posted by S63 View Post
There's no point in explaining here as this should answer your question -> You must login or register to view this content.


The thing is hes using UI_GetFontHandle.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo