[Tutorial] Short: Calculating width of textdraws
#2

Very useful. This could even be used for properly splitting chat lines!



Put it in an include. A VERY simple include:

pawn Code:
#define IsTextdrawChar(%0) \
    (!!(0 <= %0 < 224))

#define GetCharLength(%0) \
    (IsTextdrawChar(%0) ? _letterSizes[%0] : 0)

new Float:_letterSizes[224] = {
    15.0,   9.0,  17.0,  27.0,  20.0,  34.0,  23.0,  12.0,  //   ! " Ј $ % & '
    12.0,  12.0,  21.0,  20.0,  12.0,  14.0,  12.0,  15.0,  // ( ) * + , - . /
    23.0,  15.0,  21.0,  21.0,  21.0,  21.0,  21.0,  21.0,  // 0 1 2 3 4 5 6 7
    20.0,  21.0,  12.0,  12.0,  24.0,  24.0,  24.0,  19.0,  // 8 9 : ; < = > ?
    10.0,  22.0,  19.0,  19.0,  22.0,  16.0,  19.0,  24.0,  // tmA B C D E F G
    22.0,  11.0,  16.0,  21.0,  15.0,  28.0,  24.0,  27.0,  // H I J K L M N O
    20.0,  25.0,  19.0,  19.0,  18.0,  23.0,  23.0,  31.0,  // P Q R S T U V W
    23.0,  19.0,  21.0,  21.0,  13.0,  35.0,  11.0,  21.0,  // X Y Z       ! _
    10.0,  19.0,  20.0,  14.0,  20.0,  19.0,  13.0,  20.0,  // ! a b c d e f g
    19.0,   9.0,   9.0,  19.0,   9.0,  29.0,  19.0,  21.0,  // h i j k l m n o
    19.0,  19.0,  15.0,  15.0,  14.0,  18.0,  19.0,  27.0,  // p q r s t u v w
    20.0,  20.0,  17.0,  21.0,  17.0,  20.0,  15.0,  15.0,  // x y z     $ [ ]
    22.0,  22.0,  22.0,  22.0,  29.0,  19.0,  16.0,  16.0,  // А Б В Г Ж З И Й
    16.0,  16.0,  11.0,  11.0,  11.0,  11.0,  27.0,  27.0,  // К Л М Н О П Т У
    27.0,  27.0,  23.0,  23.0,  23.0,  23.0,  20.0,  19.0,  // Ф Ц Щ Ъ Ы Ь Я а
    19.0,  19.0,  19.0,  30.0,  14.0,  19.0,  19.0,  19.0,  // б в г ж з и й к
    19.0,   9.0,   9.0,   9.0,   9.0,  21.0,  21.0,  21.0,  // л м н о п т у ф
    21.0,  18.0,  18.0,  18.0,  18.0,  24.0,  19.0,  19.0,  // ц щ ъ ы ь С с ї
    20.0,  18.0,  19.0,  19.0,  21.0,  19.0,  19.0,  19.0,  // 0 1 2 3 4 5 6 7
    19.0,  19.0,  16.0,  19.0,  19.0,  19.0,  20.0,  19.0,  // 8 9 : A B C D E
    16.0,  19.0,  19.0,   9.0,  19.0,  20.0,  14.0,  29.0,  // F G H I J K L M
    19.0,  19.0,  19.0,  19.0,  19.0,  19.0,  21.0,  19.0,  // N O P Q R S T U
    20.0,  32.0,  21.0,  19.0,  19.0,  19.0,  19.0,  19.0,  // V W X Y Z А Б В
    19.0,  29.0,  19.0,  19.0,  19.0,  19.0,  19.0,   9.0,  // Г Ж З И Й К Л М
     9.0,   9.0,   9.0,  19.0,  19.0,  19.0,  19.0,  19.0,  // Н О П Т У Ф Ц Щ
    19.0,  19.0,  19.0,  19.0,  21.0,  19.0,  10.0,   9.0   // Ъ Ы Ь Я С ї ' .
};
Reply


Messages In This Thread
Short: Calculating width of textdraws - by Alcatrik - 10.10.2016, 20:45
Re: Short: Calculating width of textdraws - by Crayder - 10.10.2016, 22:42
Re: Short: Calculating width of textdraws - by Dutheil - 11.10.2016, 18:33
Re: Short: Calculating width of textdraws - by Eoussama - 11.10.2016, 18:35
Re: Short: Calculating width of textdraws - by Crayder - 02.01.2017, 12:44
Re: Short: Calculating width of textdraws - by Ivan_Ino - 06.01.2017, 15:56
Re: Short: Calculating width of textdraws - by Freaksken - 18.09.2017, 17:52
Re: Short: Calculating width of textdraws - by kristo - 23.10.2018, 19:36

Forum Jump:


Users browsing this thread: 1 Guest(s)