How to draw text on screen C#
This is something that's poorly documented and yet pretty basic stuff.
Credit goes out to @M8T for providing the SHVDN2 code. Given DN2 is no longer supported, I've tweaked it for DN3.
This is the function which does the magic:
public TextElement(string caption, PointF position, float scale, Color color, Font font, Alignment alignment, bool shadow, bool outline, float wrapWidth);
Notes: The scale parameter is the font size. Any thing over 0.5 will be fairly large.
The font options themselves are very limited, going to research if window fonts are available.
Shadow refers to a text shadow, outline to text outline. Wrap width would be useful if you want one sentence for example to be wrapped rather than go all they way across the screen, just like the word wrap in notepad.
To add a new line (line break/carriage return in C# you use \n\n staying inside the quotation marks of your text.
private void DrawText()
var pos = new Point(200, 200);
var TextString = "Lesson Topics Today: \n\n Part 1. Drawing Text \n\n Part 2. Customizations";
var Text4Screen = new GTA.UI.TextElement(TextString, pos, 0.5f, Color.White, GTA.UI.Font.ChaletComprimeCologne, GTA.UI.Alignment.Left, true, true, 1000); //last parameter is wrap width
Text4Screen.Enabled = true;
This is the native equivalent, not as user friendly, slightly modified from a post by @ikt
/* Function.Call(Hash.SET_TEXT_FONT, 0);
Function.Call(Hash.SET_TEXT_SCALE, 0.0, 0.5f);
Function.Call(Hash.SET_TEXT_COLOUR, 0, 25, 70, 255); // r/g/b/alpha
Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_TEXT, "CELL_EMAIL_BCON"); //Used to be known as _SET_TEXT_ENTRY
Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, "This is where the text goes on the screen");
Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_TEXT, 0.3, 0.2); //Used to be known as _DRAW_TEXT
These are the only fonts I could find for drawing text on the screen. Does anyone know if it's possible to expand this list without playing with the source code?
// An enumeration of fonts the game supports.
public enum Font
ChaletLondon = 0,
HouseScript = 1,
Monospace = 2,
ChaletComprimeCologne = 4,
Pricedown = 7