File: 02_font.c

package info (click to toggle)
mlv 3.1.0-8
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 10,596 kB
  • sloc: ansic: 18,982; sh: 4,760; makefile: 381; objc: 246; xml: 92
file content (122 lines) | stat: -rw-r--r-- 3,959 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
 *
 * Ce programme explique comment utiliser de nouvelles polices de caractères 
 * pour afficher du texte.
 *
 * La police de caractère par default est DejaVuSerif-Bold. Il n'est pas 
 * possible de changer ou supprimer la police par default mais, les fonctions 
 * suivantes vous explique comment charger une nouvelle police et comment 
 * l'utiliser pour afficher du texte avec cette dernière.
 *
 *------------------------------------------------------------------------------
 * MLV_Font* MLV_load_font : Charge une police de caractères en mémoire. Cette
 *                           police est chargée à partir du chemin d'accés du 
 *                           fichier contenant la police et de la taille de la
 *                           police souhaitée.
 *
 * MLV_Font* MLV_load_font(
 *    const char*    file_font,    Chemin d'accès du fichier contenant la police
 *                                 de caractères  
 *    int            size          Taille de la police de caractères
 * );
 *
 *------------------------------------------------------------------------------
 * void MLV_free_font : Ferme une police de caractères qui a précédement été 
 *                       mis en mémoire.
 *
 * void MLV_free_font(
 *    MLV_Font*    font    La police de caractères à fermer.
 * );
 *
 *------------------------------------------------------------------------------
 * MLV_draw_text_with_font : Imprime un texte donné à une position, une police 
 *                           de caractères et une couleur données.
 *
 * void MLV_draw_text_with_font(
 *     int             x,       Coordonnée en X de la position du coin 
 *                              Nord-Ouest de la boîte
 *     int             y,       Coordonnée en Y de la position du coin
 *                              Nord-Ouest de la boîte
 *     const char *    text,    texte à afficher
 *     MLV_Font*       font,    police de caractères à utiliser pour afficher le
 *                              texte
 *     MLV_Color       color    couleur du tracé
 * );
 *
 *------------------------------------------------------------------------------
 */



#include <MLV/MLV_all.h>


//
// Attention ! 
// Pour pouvoir compiler ce programme sous windows et sous macintosh,
// Il faut, pour la déclaration du main, respecter strictement la syntaxe
// suivante :
//
int main( int argc, char *argv[]){
	//
	// Créé et affiche la fenetre
	//
	MLV_create_window( "advanced - 2 - font", "font", 640, 480 );
	
	//
	// Charge une font en mémoire
	//
	MLV_Font* font = MLV_load_font( "Garuda-Oblique.ttf" , 20 );

	//
	// Affiche un texte avec la font qui vient d'être chargée
	//
	MLV_draw_text_with_font(
		10, 10,
		"Le texte est écrit avec la font Garuda-Oblique.", 
		font, MLV_COLOR_GREEN
	);

	//
	// Met à jour l'affichage de la fenêtre
	//
	MLV_update_window();

	//
	// Attend 5 seconde avant la fin du programme.
	//
	MLV_wait_seconds( 5 );


	//
	// Ferme proprement la font qui a été chargée en mémoire durant le 
	// programme.
	//
	MLV_free_font( font );

	//
	// Ferme la fenetre
	//
	MLV_free_window();
	return 0;
}

/*
 *   This file is part of the MLV Library.
 *
 *   Copyright (C) 2010,2011,2012,2013 Adrien Boussicault, Marc Zipstein
 *
 *
 *    This Library is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This Library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this Library.  If not, see <http://www.gnu.org/licenses/>.
 */