14 #include "../include/tscope5/textio_internal.h"
15 #include "../include/tscope5/system_internal.h"
16 #include "../include/tscope5/bitmaps_internal.h"
18 #include <allegro5/allegro_font.h>
19 #include <allegro5/allegro_ttf.h>
45 ts5_log(TS5_LOGLEVEL_6,
"%s: ts5_check_textio\n", calling_function);
51 if (!_ts5_data.target) {
52 ts5_fatal(
"%s: no drawing target specified\n", calling_function);
55 if (_ts5_status.graphics.font_index == TS5_USERFONT) {
58 else if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]) {
60 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index] =
61 (TS5_FONT *)al_malloc(
sizeof(TS5_FONT));
63 char path[TS5_MAX_CHAR];
64 char path_with_prefix[TS5_MAX_CHAR];
66 int factor = _ts5_status.display[_ts5_status.active_display].sampling_factor;
68 if (_ts5_status.graphics.font_type == TS5_COURIER) {
69 sprintf(path,
"Courier New");
71 else if (_ts5_status.graphics.font_type == TS5_ARIAL) {
72 sprintf(path,
"Arial");
74 else if (_ts5_status.graphics.font_type == TS5_TIMES) {
75 sprintf(path,
"Times New Roman");
78 ts5_fatal(
"%s: invalid font type (%d)\n", calling_function,
79 _ts5_status.graphics.font_type);
82 if (_ts5_status.graphics.font_style == TS5_REGULAR) {
84 else if (_ts5_status.graphics.font_style == TS5_BOLD) {
85 sprintf(path,
"%s Bold", path);
87 else if (_ts5_status.graphics.font_style == TS5_ITALIC) {
88 sprintf(path,
"%s Italic", path);
90 else if (_ts5_status.graphics.font_style == TS5_BOLD_ITALIC) {
91 sprintf(path,
"%s Bold Italic", path);
94 ts5_fatal(
"%s: invalid font style (%d)\n", calling_function,
95 _ts5_status.graphics.font_style);
97 sprintf(path,
"%s.ttf", path);
100 sprintf(path_with_prefix,
"%s", path);
102 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font =
103 al_load_font(path_with_prefix,
104 _ts5_status.graphics.font_size, 0);
106 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->multisampled_font =
107 al_load_font(path_with_prefix,
108 _ts5_status.graphics.font_size * factor, 0);
111 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font) {
113 sprintf(path_with_prefix,
"fonts/%s", path);
115 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font =
116 al_load_font(path_with_prefix,
117 _ts5_status.graphics.font_size, 0);
119 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->multisampled_font =
120 al_load_font(path_with_prefix,
121 _ts5_status.graphics.font_size * factor, 0);
127 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font) {
129 sprintf(path_with_prefix,
"/usr/local/share/tscope5_data/%s", path);
131 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font =
132 al_load_font(path_with_prefix,
133 _ts5_status.graphics.font_size, 0);
135 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->multisampled_font =
136 al_load_font(path_with_prefix,
137 _ts5_status.graphics.font_size * factor, 0);
143 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font) {
145 char *systemdrive = getenv(
"SYSTEMDRIVE");
147 ts5_fatal(
"%s: could not determine system drive letter\n",
151 sprintf(path_with_prefix,
"%s%s%s", systemdrive,
152 "/MinGW4Tscope5/msys/1.0/local/share/tscope5_data/",
155 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->aliased_font =
156 al_load_font(path_with_prefix,
157 _ts5_status.graphics.font_size, 0);
159 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index]->multisampled_font =
160 al_load_font(path_with_prefix,
161 _ts5_status.graphics.font_size * factor, 0);
166 ts5_log(TS5_LOGLEVEL_2,
"%s: %s %s %d (index %d)\n",
167 calling_function,
"loading font", path,
168 _ts5_status.graphics.font_size,
169 _ts5_status.graphics.font_index);
171 _ts5_status.graphics.font =
172 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index];
174 if (!_ts5_status.graphics.font) {
175 ts5_fatal(
"%s: could not load font %s %d\n", calling_function, path,
176 _ts5_status.graphics.font_size);
180 _ts5_status.graphics.font =
181 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index];
207 ts5_log(TS5_LOGLEVEL_1,
"%s: Installing Tscope5 text input/output\n",
210 al_init_font_addon();
212 if (!al_init_ttf_addon()) {
213 ts5_fatal(
"%s: could not install Tscope5 text input/output\n",
231 ts5_log(TS5_LOGLEVEL_1,
"Uninstalling Tscope5 text input/output\n");
234 for (i = 0; i < TS5_NFONTS; i++) {
236 if (_ts5_status.graphics.fonts[i] != NULL) {
239 al_destroy_font(_ts5_status.graphics.fonts[i]->aliased_font);
240 al_destroy_font(_ts5_status.graphics.fonts[i]->multisampled_font);
241 al_free(_ts5_status.graphics.fonts[i]);
242 _ts5_status.graphics.fonts[i] = NULL;
246 ts5_log(TS5_LOGLEVEL_2,
"%s: %s %d\n",
247 "Uninstalling Tscope5 text input/output",
252 al_shutdown_ttf_addon();
253 al_shutdown_font_addon();
int _ts5_is_textio_installed
Is the textio subsystem installed?
int _ts5_is_tscope5_installed
Is Tscope5 installed?
void ts5_uninstall_textio()
Uninstall the textio subsystem.
void ts5_check_textio(char *calling_function)
Do some checks at the start of each textio function.
void ts5_install_bitmaps(char *calling_function)
Install the bitmaps subsystem.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
void ts5_install_tscope5(char *calling_function)
Install Tscope5.
void ts5_install_textio(char *calling_function)
Install the textio subsystem.
int _ts5_is_bitmaps_installed
Is the bitmaps subsystem installed?
void ts5_fatal(const char *format,...)
Exit safely with an error message.