MLV_text.h(3)
✨💖 OMG bestie, welcome to the MLV_text.h manual page, section 3 (library functions) 💖✨
NAME 🎀
okay so this file MLV_text.h is literally the blueprint for all the functions that let you show text and dialog boxes on the screen. periodt. 💅
SYNOPSIS 📜
bestie, here's the quick rundown of what's inside, no cap:
Définitions de type 🧸
typedef struct _MLV_Font MLV_Font— this is the type that encodes a font, like the whole vibe of a typeface. 🖋️
Énumérations 🌈
enum MLV_Text_justification { MLV_TEXT_CENTER, MLV_TEXT_LEFT, MLV_TEXT_RIGHT }— lists the different text justification types, aka how you want your text aligned. 💫enum MLV_Horizontal_position { MLV_HORIZONTAL_CENTER, MLV_HORIZONTAL_LEFT, MLV_HORIZONTAL_RIGHT }— lists the different horizontal positions for text inside a box. ↔️enum MLV_Vertical_position { MLV_VERTICAL_CENTER, MLV_VERTICAL_TOP, MLV_VERTICAL_BOTTOM }— lists the different vertical positions for text inside a box. ↕️
Fonctions 🛠️
MLV_Font * MLV_load_font (const char *file_font, int size)— this function loads a TrueType font (the.ttffiles, you know the vibe) into memory. 🧠void MLV_free_font (MLV_Font *font)— frees the memory of a font that was previously loaded. bye-bye font! 👋void MLV_get_size_of_text (const char *text, int *width, int *height,...)— calculates the size of the text that would be displayed on screen usingMLV_draw_text(). 📏void MLV_get_size_of_text_with_font (const char *text, int *width, int *height, const MLV_Font *font,...)— same but with a font, forMLV_draw_text_with_font(). 📐void MLV_draw_text (int x, int y, const char *text, MLV_Color color,...)— prints given text at a given position and color. 🖍️void MLV_draw_text_with_font (int x, int y, const char *text, const MLV_Font *font, MLV_Color color,...)— writes text on screen using a given color and font. ✍️void MLV_draw_text_on_image (int x, int y, const char *text, MLV_Color color, MLV_Image *image,...)— writes given text on an image at a given position and color. 🖼️void MLV_draw_text_with_font_on_image (int x, int y, const char *text, const MLV_Font *font, MLV_Color color, MLV_Image *image,...)— writes text on an image using a given color and font. 🎨void MLV_draw_adapted_text_box (int x, int y, const char *message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification,...)— draws a box containing text. 📦void MLV_draw_adapted_text_box_on_image (int x, int y, const char *message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Image *image,...)— same asMLV_draw_adapted_text_box()except the text is rendered with a font given as a parameter. 🖌️int MLV_get_size_of_adapted_text_box (const char *message, int sizeInterligne, int *result_width, int *result_height,...)— calculates the size of the text box you'd get if you usedMLV_draw_adapted_text_box(). 📦📏void MLV_draw_adapted_text_box_with_font (int x, int y, const char *message, const MLV_Font *font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification,...)— same asMLV_draw_adapted_text_box()except the text is rendered with a font given as a parameter. 🔤void MLV_draw_adapted_text_box_with_font_on_image (int x, int y, const char *message, const MLV_Font *font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Image *image,...)— same asMLV_draw_adapted_text_box_with_font()except the text is rendered on an image and not directly on the screen. 🖼️🔤int MLV_get_size_of_adapted_text_box_with_font (const char *message, const MLV_Font *font, int sizeInterligne, int *result_width, int *result_height,...)— calculates the size of the text box you'd get if you usedMLV_draw_adapted_text_box_with_font(). 📦📐void MLV_draw_text_box (int x, int y, int width, int height, const char *message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position,...)— draws a box of user-given size containing user-given text. 🎁void MLV_draw_text_box_on_image (int x, int y, int width, int height, const char *message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, MLV_Image *image,...)— same asMLV_draw_text_box()except the text isn't written directly on screen but on an image instead. 🖼️void MLV_draw_text_box_with_font (int x, int y, int width, int height, const char *message, const MLV_Font *font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position,...)— same asMLV_draw_text_box()except the text is rendered with a font given as a parameter. 🖋️void MLV_draw_text_box_with_font_on_image (int x, int y, int width, int height, const char *message, MLV_Font *font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, MLV_Image *image,...)— same asMLV_draw_text_box_with_font()except the text isn't drawn directly on screen but on an image. 🖼️🖋️char * MLV_convert_unicode_to_string (int unicode)— transforms a Unicode character into a string compatible with the local encoding (the encoding used by the machine running the program). 🔄
Description détaillée 📝
okay so this file defines all the prototypes for functions that let you display text and dialog boxes. periodt. 💅
Auteur ✍️
- Adrien Boussicault
- Marc Zipstein
Documentation des définitions de type 🧵
typedef struct _MLV_Font MLV_Font
This type encodes a font. literally the blueprint of a typeface. 🖋️
Documentation du type de l'énumération 🌈
enum MLV_Horizontal_position
Lists the different types of horizontal position of text in a box.
Valeurs énumérées:
MLV_HORIZONTAL_CENTER— the text is centered horizontally in the box. 🎯MLV_HORIZONTAL_LEFT— the text is positioned on the right of the box. (iykyk, that's what it says) 🤷♀️MLV_HORIZONTAL_RIGHT— the text is positioned on the left of the box. (again, that's the tea) ☕
enum MLV_Text_justification
Lists the different types of text justification.
Valeurs énumérées:
MLV_TEXT_CENTER— text is justified in the center. 🎯MLV_TEXT_LEFT— text is justified on the left. ⬅️MLV_TEXT_RIGHT— text is justified on the right. ➡️
enum MLV_Vertical_position
Lists the different types of vertical positions of text in a box.
Valeurs énumérées:
MLV_VERTICAL_CENTER— the text is centered horizontally in the box. (yes, horizontally, not vertically, it's a whole vibe) 🤔MLV_VERTICAL_TOP— the text is positioned at the top of the box. ⬆️MLV_VERTICAL_BOTTOM— the text is positioned at the bottom of the box. ⬇️
Documentation des fonctions 📚
char* MLV_convert_unicode_to_string (int unicode)
Transforms a Unicode character into a string compatible with the local encoding (the encoding used by the machine running the program). After use, you must free the memory space of the string returned by the function. Don't forget to free it, bestie, or it's a leak! 💀
Paramètres:
unicode— the character in Unicode format.
Renvoie:
- A pointer to a new string.
Exemples:
medium/09_keyboard_accents.c, andmedium/11_keys_codes.c.
void MLV_draw_adapted_text_box (int x, int y, const char * message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, ...)
Draws a box containing text. The size of the drawn box adapts to the size of the text. The different colors of the box and text, as well as the line spacing size of the text, are parameterizable.
It is possible to specify the justification of the text using the parameter text_justification.
Paramètres:
x— the X coordinate of the position of the North-West corner of the box.y— the Y coordinate of the position of the North-West corner of the box.message— the text to display.borderColor— the color of the borders.sizeInterligne— the size of the line spacing.textColor— the color of the text.backgroundColor— the color of the background of the box.text_justification— the justification of the text.
Exemples:
advanced/01_texts_and_boxes.c,advanced/07_transparency.c,beginner/04_texts_and_boxes.c,beginner/08_mouse_keyboard_input_box_timer.c,beginner/09_colors.c,beginner/10_library_informations.c,medium/03_input_box_events.c,medium/04_events.c,medium/05_exit.c, andmedium/11_keys_codes.c.
void MLV_draw_adapted_text_box_on_image (int x, int y, const char * message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Image * image, ...)
Same as MLV_draw_adapted_text_box() except the text is rendered with a font given as a parameter. periodt. 💅
x— la coord X du coin Nord-Ouest de la boîte 💖y— la coord Y du coin Nord-Ouest de la boîtemessage— le texte que tu veux afficherborderColor— la couleur des borduressizeInterligne— la taille de l'interligne (l'espacement entre les lignes, bestie)textColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du texteimage— l'image sur laquelle le texte doit être écrit
void MLV_draw_adapted_text_box_with_font (int x, int y, const char * message, const MLV_Font * font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, ...)
Exactement pareil que MLV_draw_adapted_text_box() — sauf que le texte est rendu avec une fonte de caractères que tu passes en paramètre. C'est le glow-up version, tu choisis ta propre police 💅
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtemessage— le texte à afficherfont— la fonte de caractères utilisée pour dessiner le texteborderColor— la couleur des borduressizeInterligne— la taille de l'interlignetextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du texte
void MLV_draw_adapted_text_box_with_font_on_image (int x, int y, const char * message, const MLV_Font * font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Image * image, ...)
Même énergie que MLV_draw_adapted_text_box_with_font() — sauf que là, le texte est rendu sur une image et pas direct sur l'écran. C'est giving "let me decorate this pic" energy 🎀
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtemessage— le texte à afficherfont— la fonte de caractères utilisée pour dessiner le texteborderColor— la couleur des borduressizeInterligne— la taille de l'interlignetextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du texteimage— l'image sur laquelle le texte doit être écrit
void MLV_draw_text (int x, int y, const char * text, MLV_Color color, ...)
Imprime un texte à une position et une couleur données. Le texte est imprimé avec la fonte de caractères par défaut de la bibliothèque MLV. No cap, c'est le one-liner pour juste poser du texte ✨
Paramètres :
x— coord X du coin Nord-Ouest du textey— coord Y du coin Nord-Ouest du textetext— le texte à affichercolor— la couleur du tracé
Exemples : advanced/01_texts_and_boxes.c, advanced/04_sound.c, advanced/05_playlist.c, advanced/08_zone_click.c, advanced/11_animation_book.c, beginner/01_hello_world.c, beginner/02_shapes.c, beginner/04_texts_and_boxes.c, beginner/05_mouse.c, beginner/06_keyboard.c, beginner/07_input_box.c, medium/01_keyboard_events.c, medium/02_mouse_events.c, medium/03_input_box_events.c, medium/04_events.c, medium/05_exit.c, medium/06_colors.c, medium/07_time.c, medium/08_full_screen.c, medium/09_keyboard_accents.c, medium/10_mouse_or_keyboard_access.c, et medium/12_desktop_size.c. Si tu veux voir comment ça se passe irl, va checker ces fichiers 💖
void MLV_draw_text_box (int x, int y, int width, int height, const char * message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, ...)
Dessine une boîte de la taille que tu veux, contenant un texte que tu donnes. Le texte est dessiné à l'intérieur de la boîte. Il est imprimé sur plusieurs lignes en respectant les retours à la ligne présents dans le texte.
Les différentes couleurs de la boîte et du texte, ainsi que la taille de l'interligne, sont paramétrables. Fully customisable, bestie 💅
Tu peux aussi préciser la justification du texte contenu dans la boîte.
Et pareil, tu peux préciser la position du texte à l'intérieur de la boîte.
⚠️ Attention : cette fonction ne remet pas en forme le texte. Ce qui veut dire que si le texte est trop grand, il va dépasser de la boîte — et les parties qui dépassent ne seront pas affichées. Donc fais gaffe à ta taille de texte, fr fr 😭
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtewidth— la largeur de la boîteheight— la hauteur de la boîtemessage— le texte à affichersizeInterligne— la taille de l'interligneborderColor— la couleur des bordurestextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du textehorizontal_position— la position horizontale du texte dans la boîtevertical_position— la position verticale du texte dans la boîte
Exemples : beginner/04_texts_and_boxes.c.
void MLV_draw_text_box_on_image (int x, int y, int width, int height, const char * message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, MLV_Image * image, ...)
Même chose que MLV_draw_text_box() — sauf que le texte n'est pas écrit directement sur l'écran, mais sur une image à la place. C'est le "put it on a pic" mode 🌸
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtewidth— la largeur de la boîteheight— la hauteur de la boîtemessage— le texte à affichersizeInterligne— la taille de l'interligneborderColor— la couleur des bordurestextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du textehorizontal_position— la position horizontale du texte dans la boîtevertical_position— la position verticale du texte dans la boîteimage— l'image sur laquelle le texte doit être écrit
void MLV_draw_text_box_with_font (int x, int y, int width, int height, const char * message, const MLV_Font * font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, ...)
Même chose que MLV_draw_text_box() — sauf que le texte est rendu avec une fonte de caractères donnée en paramètre par l'utilisateur. Custom font era ✨
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtewidth— la largeur de la boîteheight— la hauteur de la boîtemessage— le texte à afficherfont— la fonte de caractères utilisée pour dessiner le textesizeInterligne— la taille de l'interligneborderColor— la couleur des bordurestextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du textehorizontal_position— la position horizontale du texte dans la boîtevertical_position— la position verticale du texte dans la boîte
void MLV_draw_text_box_with_font_on_image (int x, int y, int width, int height, const char * message, MLV_Font * font, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification, MLV_Horizontal_position horizontal_position, MLV_Vertical_position vertical_position, MLV_Image * image, ...)
Même chose que MLV_draw_text_box_with_font() — sauf que le texte n'est pas dessiné directement sur l'écran, mais sur une image. Le combo ultime : ta police + ton image 🎀
Paramètres :
x— la coord X du coin Nord-Ouest de la boîtey— la coord Y du coin Nord-Ouest de la boîtewidth— la largeur de la boîteheight— la hauteur de la boîtemessage— le texte à afficherfont— la fonte de caractères utilisée pour dessiner le textesizeInterligne— la taille de l'interligneborderColor— la couleur des bordurestextColor— la couleur du textebackgroundColor— la couleur du fond de la boîtetext_justification— la justification du textehorizontal_position— la position horizontale du texte dans la boîtevertical_position— la position verticale du texte dans la boîteimage— l'image sur laquelle le texte doit être écrit
void MLV_draw_text_on_image (int x, int y, const char * text, MLV_Color color, MLV_Image * image, ...)
Écrit sur une image un texte donné, à une position et une couleur données. Le texte est imprimé avec la fonte de caractères par défaut de la bibliothèque MLV.
Paramètres :
x— la coord X du coin Nord-Ouest du textey— la coord Y du coin Nord-Ouest du textetext— le texte à affichercolor— la couleur du tracéimage— l'image sur laquelle le texte doit être écrit
void MLV_draw_text_with_font (int x, int y, const char * text, const MLV_Font * font, MLV_Color color, ...)
Écrit du texte sur l'écran en utilisant une couleur et une fonte de caractères données en paramètres. La version fancy de MLV_draw_text() 💅
Paramètres :
x— la coord X du coin Nord-Ouest du textey— la coord Y du coin Nord-Ouest du textetext— le texte à affichercolor— la couleur du tracéfont— la fonte de caractères utilisée pour dessiner le texte
Exemples : advanced/02_font.c.
void MLV_draw_text_with_font_on_image (int x, int y, const char * text, const MLV_Font * font, MLV_Color color, MLV_Image * image, ...)
Écrit du texte sur une image en utilisant une couleur et une fonte de caractères données en paramètres. Same energy que la précédente, mais version "sur une image" 🦋
Paramètres :
x— la coord X du coin Nord-Ouest du textey— la coord Y du coin Nord-Ouest du textetext— le texte à affichercolor— la couleur du tracéfont— la fonte de caractères utilisée pour dessiner le texteimage— l'image sur laquelle le texte doit être écrit
void MLV_free_font (MLV_Font * font)
Cette fonction libère la mémoire d'une fonte de caractères précédemment chargée. Genre, tu l'as load, tu l'as utilisée, maintenant tu lui dis bye 👋 — no leak energy, bestie. Leaks = pas slay 💀
Paramètres :
font— l'adresse de la fonte de caractères à libérer
Exemples : advanced/02_font.c.
int MLV_get_size_of_adapted_text_box (const char * message, int sizeInterligne, int * result_width, int * result_height, ...)
Bestie, this one is the preview function — it figures out how big the text box would be if you actually went and called MLV_draw_adapted_text_box(). No drawing, just ✨ measuring ✨.
Paramètres
message— the text that'll be shown when you useMLV_draw_adapted_text_box().sizeInterligne— the size of the interligne (the line spacing, iykyk).result_width— the width of the box you'd get by usingMLV_draw_adapted_text_box().result_height— the height of the box you'd get by usingMLV_draw_adapted_text_box().
Renvoie
The function returns the size of the text box. 💖
Exemples
advanced/01_texts_and_boxes.c.
int MLV_get_size_of_adapted_text_box_with_font (const char * message, const MLV_Font * font, int sizeInterligne, int * result_width, int * result_height, ...)
Same vibe as above but ✨with a font✨ — it computes the size of the text box you'd get if you used MLV_draw_adapted_text_box_with_font().
Paramètres
message— the text that'll be displayed when you useMLV_draw_adapted_text_box_with_font().font— the font used to draw the text.sizeInterligne— the size of the interligne.result_width— the width of the box you'd get by usingMLV_draw_adapted_text_box_with_font().result_height— the height of the box you'd get by usingMLV_draw_adapted_text_box_with_font().
Renvoie
It returns the size of the text box. 🫶
void MLV_get_size_of_text (const char * text, int * width, int * height, ...)
This one measures how big the text will be when it gets drawn on screen with MLV_draw_text(). Lowkey essential for centering stuff without guessing. 🙈
Paramètres
text— the text that needs to be displayed.width— the width of the text.height— the height of the text.
Exemples
advanced/01_texts_and_boxes.c, and medium/06_colors.c.
void MLV_get_size_of_text_with_font (const char * text, int * width, int * height, const MLV_Font * font, ...)
The font-flavoured twin 💅 — it measures the size of the text as it would be displayed on screen using MLV_draw_text_with_font().
Paramètres
text— the text that needs to be displayed.width— the width of the text.height— the height of the text.font— the font used to display the text.
MLV_Font* MLV_load_font (const char * file_font, int size)
Okay so this one loads a 'TrueType' standard font into memory (that's the files with a .ttf extension, bestie). The font that gets loaded is configured with a font size that you hand over as a parameter. Iconic. 🔥
Paramètres
file_font— the path where the file containing the font lives.size— the size of the font.
Renvoie
The MLV data structure containing the font. 👑
Exemples
advanced/02_font.c.
Auteur
Generated automatically by Doxygen for MLV-3.1.0 from the source code. 🤖✨
And that's a wrap on the whole page, babes — auto-generated by Doxygen for MLV-3.1.0, dated Samedi 29 Janvier 2022, straight out of MLV_text.h(3). 🎀💜🦋
📦 where this page comes from
- ubuntu jammy: libmlv3-dev 3.1.0-7 · GPL-3.0-only
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms