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 char path[TS5_MAX_CHAR];
61 char path_with_prefix[TS5_MAX_CHAR];
63 if (_ts5_status.graphics.font_type == TS5_COURIER) {
64 sprintf(path,
"Courier New");
66 else if (_ts5_status.graphics.font_type == TS5_ARIAL) {
67 sprintf(path,
"Arial");
69 else if (_ts5_status.graphics.font_type == TS5_TIMES) {
70 sprintf(path,
"Times New Roman");
73 ts5_fatal(
"%s: invalid font type (%d)\n", calling_function,
74 _ts5_status.graphics.font_type);
77 if (_ts5_status.graphics.font_style == TS5_REGULAR) {
79 else if (_ts5_status.graphics.font_style == TS5_BOLD) {
80 sprintf(path,
"%s Bold", path);
82 else if (_ts5_status.graphics.font_style == TS5_ITALIC) {
83 sprintf(path,
"%s Italic", path);
85 else if (_ts5_status.graphics.font_style == TS5_BOLD_ITALIC) {
86 sprintf(path,
"%s Bold Italic", path);
89 ts5_fatal(
"%s: invalid font style (%d)\n", calling_function,
90 _ts5_status.graphics.font_style);
92 sprintf(path,
"%s.ttf", path);
95 sprintf(path_with_prefix,
"%s", path);
96 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index] =
97 al_load_font(path_with_prefix,
98 _ts5_status.graphics.font_size, 0);
101 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]) {
102 sprintf(path_with_prefix,
"fonts/%s", path);
103 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index] =
104 al_load_font(path_with_prefix,
105 _ts5_status.graphics.font_size, 0);
111 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]) {
113 sprintf(path_with_prefix,
"/usr/local/share/tscope5_data/%s", path);
114 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index] =
115 al_load_font(path_with_prefix,
116 _ts5_status.graphics.font_size, 0);
122 if (!_ts5_status.graphics.fonts[_ts5_status.graphics.font_index]) {
125 char *systemdrive = getenv(
"SYSTEMDRIVE");
127 ts5_fatal(
"%s: could not determine system drive letter\n",
131 sprintf(path_with_prefix,
"%s%s%s", systemdrive,
132 "/MinGW4Tscope5/msys/1.0/local/share/tscope5_data/",
135 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index] =
136 al_load_font(path_with_prefix,
137 _ts5_status.graphics.font_size, 0);
142 ts5_log(TS5_LOGLEVEL_2,
"%s: %s %s %d (index %d)\n",
143 calling_function,
"loading font", path,
144 _ts5_status.graphics.font_size,
145 _ts5_status.graphics.font_index);
147 _ts5_status.graphics.font =
148 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index];
150 if (!_ts5_status.graphics.font) {
151 ts5_fatal(
"%s: could not load font %s %d\n", calling_function, path,
152 _ts5_status.graphics.font_size);
156 _ts5_status.graphics.font =
157 _ts5_status.graphics.fonts[_ts5_status.graphics.font_index];
183 ts5_log(TS5_LOGLEVEL_1,
"%s: Installing Tscope5 text input/output\n",
186 al_init_font_addon();
188 if (!al_init_ttf_addon()) {
189 ts5_fatal(
"%s: could not install Tscope5 text input/output\n",
207 ts5_log(TS5_LOGLEVEL_1,
"Uninstalling Tscope5 text input/output\n");
210 for (i = 0; i < TS5_NFONTS; i++) {
212 if (_ts5_status.graphics.fonts[i] != NULL) {
215 al_destroy_font(_ts5_status.graphics.fonts[i]);
216 _ts5_status.graphics.fonts[i] = NULL;
220 ts5_log(TS5_LOGLEVEL_2,
"%s: %s %d\n",
221 "Uninstalling Tscope5 text input/output",
226 al_shutdown_ttf_addon();
227 al_shutdown_font_addon();