@@ -7,47 +7,56 @@ use std::borrow::{Borrow, ToOwned};
7
7
use std:: ffi:: { CStr , CString } ;
8
8
use std:: io:: { Read , Seek } ;
9
9
use std:: ops:: { Deref , DerefMut } ;
10
+ use std:: fmt:: { self , Debug } ;
10
11
11
- /// Type for loading and manipulating character fonts.
12
- ///
13
- /// Fonts can be loaded from a file, from memory or from a custom stream,
14
- /// and supports the most common types of fonts.
15
- ///
16
- /// See the `from_file` function for the complete list of supported formats.
17
- ///
18
- /// Once it is loaded, a `Font` instance provides three types of information about the font:
19
- ///
20
- /// - Global metrics, such as the line spacing
21
- /// - Per-glyph metrics, such as bounding box or kerning
22
- /// - Pixel representation of glyphs
23
- ///
24
- /// Fonts alone are not very useful: they hold the font data but cannot make anything useful of it.
25
- /// To do so you need to use the `Text` type, which is able to properly output text with
26
- /// several options such as character size, style, color, position, rotation, etc.
27
- /// This separation allows more flexibility and better performances:
28
- /// indeed a `Font` is a heavy resource, and any operation on it is
29
- /// slow (often too slow for real-time applications).
30
- /// On the other side, a `Text` is a lightweight object which can combine the
31
- /// glyphs data and metrics of a `Font` to display any text on a render target.
32
- /// Note that it is also possible to bind several `Text` instances to the same `Font`.
33
- ///
34
- /// It is important to note that the `Text` instance doesn't copy the font that it uses,
35
- /// it only keeps a reference to it.
36
- /// Thus, a `Font` must not be destructed while it is used by a
37
- /// `Text` (i.e. never write a function that uses a local `Font` instance for creating a text).
38
- ///
39
- /// Apart from loading font files, and passing them to instances of `Text`,
40
- /// you should normally not have to deal directly with this type.
41
- /// However, it may be useful to access the font metrics or rasterized glyphs for advanced usage.
42
- ///
43
- /// Note that if the font is a bitmap font, it is not scalable,
44
- /// thus not all requested sizes will be available to use.
45
- /// This needs to be taken into consideration when using `Text`.
46
- /// If you need to display text of a certain size, make sure the corresponding bitmap font that
47
- /// supports that size is used.
48
- #[ derive( Debug ) ]
49
- #[ allow( missing_copy_implementations) ]
50
- pub enum Font { }
12
+ extern "C" {
13
+ /// Type for loading and manipulating character fonts.
14
+ ///
15
+ /// Fonts can be loaded from a file, from memory or from a custom stream,
16
+ /// and supports the most common types of fonts.
17
+ ///
18
+ /// See the `from_file` function for the complete list of supported formats.
19
+ ///
20
+ /// Once it is loaded, a `Font` instance provides three types of information about the font:
21
+ ///
22
+ /// - Global metrics, such as the line spacing
23
+ /// - Per-glyph metrics, such as bounding box or kerning
24
+ /// - Pixel representation of glyphs
25
+ ///
26
+ /// Fonts alone are not very useful:
27
+ /// they hold the font data but cannot make anything useful of it.
28
+ /// To do so you need to use the `Text` type, which is able to properly output text with
29
+ /// several options such as character size, style, color, position, rotation, etc.
30
+ /// This separation allows more flexibility and better performances:
31
+ /// indeed a `Font` is a heavy resource, and any operation on it is
32
+ /// slow (often too slow for real-time applications).
33
+ /// On the other side, a `Text` is a lightweight object which can combine the
34
+ /// glyphs data and metrics of a `Font` to display any text on a render target.
35
+ /// Note that it is also possible to bind several `Text` instances to the same `Font`.
36
+ ///
37
+ /// It is important to note that the `Text` instance doesn't copy the font that it uses,
38
+ /// it only keeps a reference to it.
39
+ /// Thus, a `Font` must not be destructed while it is used by a
40
+ /// `Text` (i.e. never write a function that uses a local `Font` instance for creating a text).
41
+ ///
42
+ /// Apart from loading font files, and passing them to instances of `Text`,
43
+ /// you should normally not have to deal directly with this type.
44
+ /// However, it may be useful to access the font metrics or rasterized glyphs for
45
+ /// advanced usage.
46
+ ///
47
+ /// Note that if the font is a bitmap font, it is not scalable,
48
+ /// thus not all requested sizes will be available to use.
49
+ /// This needs to be taken into consideration when using `Text`.
50
+ /// If you need to display text of a certain size, make sure the corresponding bitmap font that
51
+ /// supports that size is used.
52
+ pub type Font ;
53
+ }
54
+
55
+ impl Debug for Font {
56
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
57
+ write ! ( f, "Font at {:p}" , self )
58
+ }
59
+ }
51
60
52
61
impl Font {
53
62
/// Get the kerning value corresponding to a given pair of characters in a font
0 commit comments