Return to FunctionReference page
Function
void destroySWFFont(SWFFont font);
Purpose
- Destroys a font object, freeing the memory associated with it.
Parameters
SWFFont font - The font object to be destroyed and its memory freed.
Returns
void - No return value
Language
- C
Ming version
- (unknown). At least 0.4.0 and onwards, possibly earlier versions as well.
Notes
None as yet
Example
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <ming.h>
4
5 int main(void)
6 {
7 // Create local variables
8 int i;
9 SWFDisplayItem image_display_item;
10 SWFFont font_object;
11 SWFMovieClip movie_clip;
12 SWFMovie test_movie;
13 SWFText text_object;
14
15
16 // Initialise the movie structure in memory
17 Ming_init();
18 test_movie = newSWFMovieWithVersion(7);
19
20 // Set the desired compression level for the output (9 = maximum compression)
21 Ming_setSWFCompression(9);
22
23 // Set the background color for the movie
24 SWFMovie_setBackground(test_movie, 0xff, 0xff, 0xff);
25
26 // Adjust the dimensions of the movie
27 SWFMovie_setDimension(test_movie, 800, 600);
28
29 // Set the frame rate for the movie to 24 frames per second
30 SWFMovie_setRate(test_movie, 24.0);
31
32 // Load a font from disk
33 font_object = newSWFFont_fromFile("font.fdb");
34 if (NULL == font_object)
35 {
36 // Something went wrong, so exit
37 printf("Unable to load font from file.\n");
38 return EXIT_FAILURE;
39 }
40
41 // Create a new, empty text object
42 text_object = newSWFText();
43
44 // Tell the text object to use the font previously loaded
45 SWFText_setFont(text_object, font_object);
46
47 // Set the height of the text
48 SWFText_setHeight(text_object, 18.0);
49
50 // Set the color of the text
51 SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff);
52
53 // Add a string to the text object
54 SWFText_addString(text_object, "This is some example text inside a movie clip", NULL);
55
56 // Create the movie clip object
57 movie_clip = newSWFMovieClip();
58
59 // Add the text object to the movie clip
60 SWFMovieClip_add(movie_clip, (SWFBlock) text_object);
61
62 // Advance the movie clip one frame, else it doesn't get displayed
63 SWFMovieClip_nextFrame(movie_clip);
64
65 // Add the movie clip object to the main movie
66 image_display_item = SWFMovie_add(test_movie, (SWFBlock) movie_clip);
67
68 // Move to 100, 100
69 SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0);
70
71 // Progressively move the text down and to the right
72 for (i = 0; i <= 250; i++)
73 {
74 SWFMovie_nextFrame(test_movie);
75 SWFDisplayItem_move(image_display_item, 2, 2);
76 }
77
78 // Save the swf movie file to disk
79 SWFMovie_save(test_movie, "ming-test.swf");
80
81 // Free the swf movie in memory
82 destroySWFMovie(test_movie);
83
84 // Free the movie clip object
85 destroySWFMovieClip(movie_clip);
86
87 // Free the swf text object
88 destroySWFText(text_object);
89
90 // Free the font object
91 destroySWFFont(font_object);
92
93 return EXIT_SUCCESS;
94 }