ge211
ge211_resource.h
1 #pragma once
2 
3 #include "ge211_forward.h"
4 #include "ge211_util.h"
5 #include "ge211_error.h"
6 
7 #include <string>
8 #include <vector>
9 
10 namespace ge211 {
11 
12 namespace detail {
13 
14 std::vector<const char*> get_search_prefixes();
15 
16 class File_resource
17 {
18 public:
19  explicit File_resource(const std::string&);
20 
21  SDL_RWops* get_raw() const noexcept { return ptr_.get(); }
22  SDL_RWops* release() && { return ptr_.release(); }
23 
24 private:
25  static delete_ptr<SDL_RWops> open_rwops_(const std::string&);
26 
27  delete_ptr<SDL_RWops> ptr_;
28 };
29 
30 } // end namespace detail
31 
48 class Font
49 {
50 public:
53  Font(const std::string& filename, int size);
54 
55 private:
56  friend Text_sprite;
57 
58  TTF_Font* get_raw_() const noexcept { return ptr_.get(); }
59 
60  static detail::delete_ptr<TTF_Font>
61  load_(const std::string& filename,
62  detail::File_resource&& ttf_file,
63  int size);
64 
65  detail::delete_ptr<TTF_Font> ptr_;
66 };
67 
68 }
The game engine namespace.
Definition: ge211.h:17
Font(const std::string &filename, int size)
Loads a font from the specified TrueType font file, at the specified size.
Represents a font that can be used to render a sprites::Text_sprite.
A Sprite that displays text.