@@ -143,19 +143,27 @@ int main(int argc, char *argv[])
143
143
editorOptions.sFontPath = " /Library/Fonts/Courier New.ttf" ;
144
144
#else
145
145
// Linux case
146
- const std::string fontPaths[2 ] = {
146
+ // TODO: use fonts.conf(5) or X resources or something like that
147
+ const char * fontPaths[] = {
148
+ " /usr/share/fonts/TTF/DejaVuSansMono.ttf" ,
149
+ " /usr/share/fonts/TTF/FreeMono.ttf" ,
150
+ " /usr/share/fonts/TTF/LiberationMono-Regular.ttf" ,
151
+ " /usr/share/fonts/TTF/VeraMono.ttf" ,
147
152
" /usr/share/fonts/corefonts/cour.ttf" ,
148
- " /usr/share/fonts/truetype/msttcorefonts/cour.ttf"
153
+ " /usr/share/fonts/truetype/msttcorefonts/cour.ttf" ,
154
+ NULL
149
155
};
150
156
editorOptions.sFontPath = " " ;
151
- int step = 0 ;
152
- while ( step < 2 && editorOptions. sFontPath . size () == 0 ) {
153
- const std::string & current = fontPaths[step++];
154
-
155
- if ( access (current. c_str (), R_OK) != - 1 ) {
156
- editorOptions. sFontPath = current ;
157
+ for ( int i = 0 ; fontPaths[i]; ++i)
158
+ {
159
+ if ( access (fontPaths[i], R_OK) != - 1 )
160
+ {
161
+ editorOptions. sFontPath = fontPaths[i];
162
+ break ;
157
163
}
158
164
}
165
+ // aiee - no font found, but don't report yet, it might still get changed
166
+ // though config.json
159
167
#endif
160
168
editorOptions.nOpacity = 0xC0 ;
161
169
editorOptions.bUseSpacesForTabs = true ;
@@ -199,7 +207,24 @@ int main(int argc, char *argv[])
199
207
if (options.get <jsonxx::Object>(" font" ).has <jsonxx::Number>(" size" ))
200
208
editorOptions.nFontSize = options.get <jsonxx::Object>(" font" ).get <jsonxx::Number>(" size" );
201
209
if (options.get <jsonxx::Object>(" font" ).has <jsonxx::String>(" file" ))
202
- editorOptions.sFontPath = options.get <jsonxx::Object>(" font" ).get <jsonxx::String>(" file" );
210
+ {
211
+ std::string fontpath = options.get <jsonxx::Object>(" font" ).get <jsonxx::String>(" file" );
212
+ // TODO: port this to other platforms
213
+ #if !defined(_WIN32) && !defined(__APPLE__)
214
+ if (access (fontpath.c_str (), R_OK) != -1 )
215
+ editorOptions.sFontPath = fontpath;
216
+ else
217
+ {
218
+ printf (" Couldn't open the font file '%s'.\n " , fontpath.c_str ());
219
+ return -1 ;
220
+ }
221
+ #endif
222
+ }
223
+ else if (!editorOptions.sFontPath .size ()) // coudn't find a default font
224
+ {
225
+ printf (" Couldn't find any of the default fonts. Please specify one in config.json\n " );
226
+ return -1 ;
227
+ }
203
228
}
204
229
if (options.has <jsonxx::Object>(" gui" ))
205
230
{
@@ -230,7 +255,7 @@ int main(int argc, char *argv[])
230
255
}
231
256
Capture::LoadSettings ( options );
232
257
}
233
- if ( !Capture::Open ( settings ) )
258
+ if (!Capture::Open (settings) )
234
259
{
235
260
printf (" Initializing capture system failed!\n " );
236
261
return 0 ;
@@ -256,6 +281,9 @@ int main(int argc, char *argv[])
256
281
printf (" Last shader works fine.\n " );
257
282
shaderInitSuccessful = true ;
258
283
}
284
+ else {
285
+ printf (" Shader error:\n %s\n " , szError);
286
+ }
259
287
}
260
288
if (!shaderInitSuccessful)
261
289
{
0 commit comments