Hi all,

This is a super short one - I wanted to chronicle my research somewhere to save someone the hassle of spending however long I have trying to tackle this problem: working out how wide a textdraw actually is based on its text content.

In my case, I have a UI system with textboxes and the likes - and I wanted to shorten the string down if it was longer then the textbox, so using the below, if the text width is greater than the width of the textbox, I cut off the remainder, the size of three .'s and some padding, resulting in:



Another use case would be if you wanted to put "hyperlinks" in your textdraw contents - so that you can trigger things once a certain word is pressed without having to manually work out and hard code position.

Solution:
1. The GTA San Andreas\data\fonts.dat file contains (in cleartext) the baseline widths of each character in rows of 8 - where the 1st digit on the left reflects the first character after the # and the first number. For example, ! is 15 pixels wide.

Code:
15 9 17 27 20 34 23 12 # 0 ! " £ $ % & '
12 12 21 20 12 14 12 15 # 8 ( ) * + , - . /
23 15 21 21 21 21 21 21 # 16 0 1 2 3 4 5 6 7
20 21 12 12 24 24 24 19 # 24 8 9 : ; < = > ?
10 22 19 19 22 16 19 24 # 32 tmA B C D E F G
22 11 16 21 15 28 24 27 # 40 H I J K L M N O
20 25 19 19 18 23 23 31 # 48 P Q R S T U V W
23 19 21 21 13 35 11 21 # 56 X Y Z ! _
10 19 20 14 20 19 13 20 # 64 ! a b c d e f g
19 9 9 19 9 29 19 21 # 72 h i j k l m n o
19 19 15 15 14 18 19 27 # 80 p q r s t u v w
20 20 17 21 17 20 15 15 # 88 x y z $ [ ]
22 22 22 22 29 19 16 16 # 96 À Á Â Ã Æ Ç È É
16 16 11 11 11 11 27 27 # 104 Ê Ë Ì Í Î Ï Ò Ó
27 27 23 23 23 23 20 19 # 112 Ô Ö Ù Ú Û Ü ß à
19 19 19 30 14 19 19 19 # 120 á â ã æ ç è é ê
19 9 9 9 9 21 21 21 # 128 ë ì í î ï ò ó ô
21 18 18 18 18 24 19 19 # 136 ö ù ú û ü Ñ ñ ¿
20 18 19 19 21 19 19 19 # 144 0 1 2 3 4 5 6 7
19 19 16 19 19 19 20 19 # 152 8 9 : A B C D E
16 19 19 9 19 20 14 29 # 160 F G H I J K L M
19 19 19 19 19 19 21 19 # 168 N O P Q R S T U
20 32 21 19 19 19 19 19 # 176 V W X Y Z À Á Â
19 29 19 19 19 19 19 9 # 184 Ã Æ Ç È É Ê Ë Ì
9 9 9 19 19 19 19 19 # 192 Í Î Ï Ò Ó Ô Ö Ù
19 19 19 19 21 19 10 9 # 200 Ú Û Ü ß Ñ ¿ ' .
2. There are however two things to note:
- These are multiplied against the textdraw width - for example, at 0.5 the actual width of the ! character is 7.5 - not 15.
- These also work off the basis of the virtual 640x480 textdraw canvas which applies regardless of resolution. For example, at 1280x1024, the letter ! at 1.0 letter width will ACTUALLY be 30 pixels wide on your screen. However most of the time this shouldn't matter because all other textdraws will also be drawn on the 640x480 grid; I include this only so that you all have a proper understanding of why this is.