Ticket #36: noX11.patch
File noX11.patch, 6.2 KB (added by , 8 years ago) |
---|
-
io.c
24 24 // Fonctions de lecture/ecriture file, gèrent les systèmes big-endian et 25 25 // little-endian. 26 26 27 #define _XOPEN_SOURCE 500 28 27 29 #include <SDL_endian.h> 28 30 #include <string.h> 29 31 #include <sys/stat.h> … … 51 53 #include "io.h" 52 54 #include "realpath.h" 53 55 56 #include "text.h" 57 54 58 // Lit un octet 55 59 // Renvoie -1 si OK, 0 en cas d'erreur 56 60 int Read_byte(FILE *file, byte *dest) … … 389 393 closedir(current_directory); 390 394 } 391 395 396 void For_each_font_in_tree(const char * directory_name) 397 { 398 // Pour scan de répertoire 399 DIR* current_directory; //Répertoire courant 400 struct dirent* entry; // Structure de lecture des éléments 401 char full_filename[MAX_PATH_CHARACTERS]; 402 int filename_position; 403 strcpy(full_filename, directory_name); 404 current_directory=opendir(directory_name); 405 if(current_directory == NULL) return; // Répertoire invalide ... 406 filename_position = strlen(full_filename); 407 #if defined(__AROS__) 408 if (filename_position==0 || (strcmp(full_filename+filename_position-1,PATH_SEPARATOR) && strcmp(full_filename+filename_position-1,":"))) 409 #else 410 if (filename_position==0 || strcmp(full_filename+filename_position-1,PATH_SEPARATOR)) 411 #endif 412 { 413 strcat(full_filename, PATH_SEPARATOR); 414 filename_position = strlen(full_filename); 415 } 416 while ((entry=readdir(current_directory))) 417 { 418 struct stat Infos_enreg; 419 strcpy(&full_filename[filename_position], entry->d_name); 420 stat(full_filename,&Infos_enreg); 421 if (S_ISREG(Infos_enreg.st_mode)) 422 { 423 Add_font(full_filename); 424 }else if (S_ISDIR(Infos_enreg.st_mode)) 425 { 426 if (strcmp(entry->d_name,".") != 0 && strcmp(entry->d_name,"..") != 0) 427 For_each_font_in_tree(full_filename); 428 } 429 } 430 closedir(current_directory); 431 } 432 392 433 /// Scans a directory, calls Callback for each file or directory in it, 393 434 void For_each_directory_entry(const char * directory_name, void Callback(const char *, byte is_file, byte is_directory, byte is_hidden)) 394 435 { … … 453 494 454 495 byte Create_lock_file(const char *file_directory) 455 496 { 456 #if defined (__amigaos__)||(__AROS__) ||(__ANDROID__)497 #if defined (__amigaos__)||(__AROS__) 457 498 #warning "Missing code for your platform, please check and correct!" 458 499 #else 459 500 char lock_filename[MAX_PATH_CHARACTERS]; 460 501 461 #ifdef GCWZERO462 strcpy(lock_filename,"/media/home/.grafx2/");463 #else464 502 strcpy(lock_filename,file_directory); 465 #endif466 503 strcat(lock_filename,"gfx2.lck"); 467 504 468 505 #ifdef __WIN32__ -
text.c
2 2 */ 3 3 /* Grafx2 - The Ultimate 256-color bitmap paint program 4 4 5 Copyright 2014 Sergii Pylypenko6 5 Copyright 2011 Pawel Góralski 7 6 Copyright 2008 Yves Rizoud 8 7 Copyright 2008 Franck Charlet … … 39 38 #endif 40 39 41 40 #if defined(__CAANOO__) || defined(__WIZ__) || defined(__GP2X__) 42 // No fontconfig41 // No X11 43 42 #elif defined(__linux__) 44 #include < fontconfig/fontconfig.h>43 #include <X11/Xlib.h> 45 44 #endif 46 45 #endif 47 46 … … 327 326 #endif 328 327 329 328 #elif defined(__CAANOO__) || defined(__WIZ__) || defined(__GP2X__) 330 // No fontconfig: Only use fonts from Grafx2329 // No X11 : Only use fonts from Grafx2 331 330 #elif defined(__linux__) 332 331 #ifndef NOTTF 333 #define USE_FC 332 // #define USE_XLIB 334 333 335 #ifdef USE_FC 334 #ifdef USE_XLIB 335 /* 336 the following X calls lock Grafx2 into X Windows. 337 Grafx2 will not run in console mode outside X. 338 Also this does not find the newer "built-ins". 339 */ 336 340 { 337 FcStrList* dirs; 338 dirs = FcConfigGetFontDirs(NULL); 339 char* fdir = FcStrListNext(dirs); 340 while(fdir != NULL) 341 { 342 For_each_file(fdir,Add_font); 343 fdir = FcStrListNext(dirs); 344 } 341 int i,number; 342 Display* dpy = XOpenDisplay(NULL); 343 char** font_path_list = XGetFontPath(dpy,&number); 344 XCloseDisplay(dpy); 345 345 346 FcStrListDone(dirs); 346 for(i=0;i<number;i++) 347 For_each_file(*(font_path_list+i),Add_font); 348 349 XFreeFontPath(font_path_list); 347 350 } 351 #else 352 /* 353 on Linux SDL does NOT need X Windows to use TTF, 354 but there are so many places usable fonts can be 355 we need to search by hand "one step up" of known 356 possibilities. 357 */ 358 { 359 int i,number; 360 char *font_path_list[7] = { 361 "/usr/share/fonts", // mostly under here 362 "/usr/local/share/fonts", // maybe here too 363 "/usr/local/share/lib/X11/fonts", // we check the following on other/older systems 364 "/usr/openwin/lib/X11/fonts", 365 "/usr/dt/config/xfonts" 366 }; 367 number = 7; 368 369 font_path_list[5] = getenv("HOME"); 370 strcat(font_path_list[5], "/.fonts"); // traditionally, current users can also have fonts 371 372 font_path_list[6] = getenv("HOME"); 373 strcat(font_path_list[6], "/.local/share/fonts"); // new systems are beginning to use this 374 375 for(i=0;i<number;i++) 376 For_each_font_in_tree(*(font_path_list+i)); 377 378 } 379 348 380 #endif 381 349 382 #endif 350 383 #elif defined(__amigaos4__) || defined(__amigaos__) 351 384 #ifndef NOTTF … … 419 452 bg_color.unused=fg_color.unused=255; 420 453 421 454 // Text rendering: creates a 8bit surface with its dedicated palette 422 #ifdef __ANDROID__423 455 if (antialias) 424 text_surface=TTF_RenderUTF8_Shaded(font, str, fg_color, bg_color );425 else426 text_surface=TTF_RenderUTF8_Solid(font, str, fg_color);427 #else428 if (antialias)429 456 text_surface=TTF_RenderText_Shaded(font, str, fg_color, bg_color ); 430 457 else 431 458 text_surface=TTF_RenderText_Solid(font, str, fg_color); 432 #endif433 459 if (!text_surface) 434 460 { 435 461 TTF_CloseFont(font); … … 534 560 font_surface=IMG_Load(Font_name(font_number)); 535 561 if (!font_surface) 536 562 { 537 char buffer[256]; 538 strcpy(buffer, "Error loading font.\n"); 539 strcat(buffer,IMG_GetError()); 540 Verbose_message("Warning",buffer); 541 // TODO this leaves a non-erased cursor when the window closes. 563 Verbose_message("Warning","Error loading font.\nThe file may be corrupt."); 542 564 return NULL; 543 565 } 544 566 // Font is 24bit: Perform a color reduction