Latest Uploads
Invasion V ... prototype

rychan

Invasion V ... Prototype

rychan

Shields 64x64

Pakz

Ffs_Spam

Jayenkai

Hives Screen shot

rychan

Rpg Potion Sprites

Pakz

Forum Home

Txt within a field

UserMessage
Posted : Monday, 17 October 2011, 16:43 | Permalink
dna


Hey.

I'm trying to put text into a field. What the code does is measure the width of the field in pixels, gets the fontwidth() which is in pixels and then returns the maximum number of characters that can be placed into that field.

-->

Using Arial and the default size I get 24 for the fontwidth.

I use NN=Int(WID/FNT_WID)-1 after setting FONT_1=fontwidth() and WID being the width of the field. The number that returns is much smaller than the size of WID. Meaning that I get an amount of characters that is smaller than the space I want to fill.

Do I need to use a monospaced font?


-----
DNA
Posted : Monday, 17 October 2011, 20:14 | Permalink
dna



I tried using a monospaced font and the results were better but the text generated never went all the way across the row of the field.

-----
DNA
Posted : Monday, 17 October 2011, 20:22 | Permalink
dna


Hey all.

I found the solution. Use Stringwidth()


thanks


-----
DNA
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 565|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
CSS-Me-Do - SoCoder2
rskgames Fri 09:45
Delete Button on Showcases
Pakz Fri 09:13
Grenfell Fridge
Jayenkai Fri 09:02
ProcGen Book
Pakz Fri 07:11
XB360 /XBOne Pads
STEVIE G Thu 23:28
Crystal Maze
Jayenkai Thu 05:56
Cerberus X - the continuation of Monkey X
Jayenkai Thu 03:54
Winter Solstice
therevillsgames Wed 16:47
AGameAWeek : 2017 - Part One
Jayenkai Wed 15:10
Polymaniacs Trailer
STEVIE G Wed 10:11
More

Latest Items
Link : Learn C++
rychan Fri 03:13
Dev-Diary : My Journey into NES Development
Jayenkai Thu 03:58
Showcase : A Civilization Clone v0.3
rychan Thu 03:27
News : Newsletter #320
Jayenkai Tue 18:47
Blog : sadas
hardcoal22 Tue 02:50
Showcase : Flappadiddle
Jayenkai Mon 08:20
Article : Cookie Information
rychan Sun 12:28
Dev-Diary : Wii to N64 adapter
spinal Sat 11:50
Link : MonkeyX code examples
Jayenkai Sat 06:42
Link : Available Languages
Jayenkai Thu 13:22
Blog : Mr Testo Tests
Socoder Tue 07:21
Link : Chrome VR Experiments
Jayenkai Tue 06:49
Showcase : Orbital Projectiles
Jayenkai Tue 06:39
Showcase : Hives
zzoom Fri 16:10
More

Who's Online
GfK
Fri, at 13:04
Jayenkai
Fri, at 13:02
Socoder
Fri, at 13:02
rychan
Fri, at 12:33
STEVIE G
Fri, at 11:52
rockford
Fri, at 11:09
Pakz
Fri, at 10:53
spinal
Fri, at 10:16
rskgames
Fri, at 09:52
shroom_monk
Fri, at 09:28
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.