Implemented font listing under linux in a quite hacky way. The directory list returned by XGetFontPath is not really usable, there are some path with appended :unscaled for non-ttf fonts, so i needed to add some null-pointer check to for_each_file after the opendir to avoid a crash. I think most of my ttf fonts gets listed, but at a quick glance i find some duplicates and the list is not alphabetically sorted. That would be a great improvement (sort and remove duplicates).
Also renamed Mask to Mask_table because XLib.h already defines some var called Mask. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@337 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									038303721c
								
							
						
					
					
						commit
						d5143b5f82
					
				
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@ -103,7 +103,7 @@ ifeq ($(NOTTF),1)
 | 
			
		||||
  TTFLABEL = -nottf
 | 
			
		||||
else
 | 
			
		||||
  TTFCOPT = 
 | 
			
		||||
  TTFLOPT = -L/usr/local/lib -lSDL_ttf
 | 
			
		||||
  TTFLOPT = -L/usr/local/lib -lSDL_ttf -lX11
 | 
			
		||||
  TTFLIBS = libfreetype-6.dll SDL_ttf.dll
 | 
			
		||||
  TTFLABEL = 
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
@ -669,7 +669,7 @@ void Bouton_Mask_Mode(void)
 | 
			
		||||
 | 
			
		||||
void Bouton_Mask_Menu(void)
 | 
			
		||||
{
 | 
			
		||||
  Menu_Tag_couleurs("Mask",Mask,&Mask_Mode,1, "MASK");
 | 
			
		||||
  Menu_Tag_couleurs("Mask",Mask_table,&Mask_Mode,1, "MASK");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								files.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								files.c
									
									
									
									
									
								
							@ -688,6 +688,7 @@ void for_each_file(const char * Nom_repertoire, void Callback(const char *))
 | 
			
		||||
  int Position_nom_fichier;
 | 
			
		||||
  strcpy(Nom_fichier_complet, Nom_repertoire);
 | 
			
		||||
  Repertoire_Courant=opendir(Nom_repertoire);
 | 
			
		||||
  if(Repertoire_Courant == NULL) return;	// Répertoire invalide ...
 | 
			
		||||
  strcat(Nom_fichier_complet, SEPARATEUR_CHEMIN);
 | 
			
		||||
  Position_nom_fichier = strlen(Nom_fichier_complet);
 | 
			
		||||
  while ((Enreg=readdir(Repertoire_Courant)))
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								global.h
									
									
									
									
									
								
							@ -452,7 +452,7 @@ GLOBAL short Tiling_Decalage_Y; // D
 | 
			
		||||
  // Mode Mask
 | 
			
		||||
 | 
			
		||||
GLOBAL byte Mask_Mode;  // Le mode Masque est enclenché
 | 
			
		||||
GLOBAL byte Mask[256];  // Tableau des couleurs constituant le masque
 | 
			
		||||
GLOBAL byte Mask_table[256];  // Tableau des couleurs constituant le masque
 | 
			
		||||
 | 
			
		||||
  // Mode loupe:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								graph.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								graph.c
									
									
									
									
									
								
							@ -1165,7 +1165,7 @@ void Afficher_pixel(word X,word Y,byte Couleur)
 | 
			
		||||
{
 | 
			
		||||
  if ( ( (!Trame_Mode)   || (Effet_Trame(X,Y)) )
 | 
			
		||||
    && (!((Stencil_Mode) && (Stencil[Lit_pixel_dans_ecran_courant(X,Y)])))
 | 
			
		||||
    && (!((Mask_Mode)    && (Mask[Lit_pixel_dans_ecran_brouillon(X,Y)]))) )
 | 
			
		||||
    && (!((Mask_Mode)    && (Mask_table[Lit_pixel_dans_ecran_brouillon(X,Y)]))) )
 | 
			
		||||
  {
 | 
			
		||||
    Couleur=Fonction_effet(X,Y,Couleur);
 | 
			
		||||
    Pixel_dans_ecran_courant(X,Y,Couleur);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								init.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								init.c
									
									
									
									
									
								
							@ -1734,7 +1734,7 @@ int Charger_CFG(int Tout_charger)
 | 
			
		||||
      case CHUNK_MASQUE: // Masque
 | 
			
		||||
        if (Tout_charger)
 | 
			
		||||
        {
 | 
			
		||||
          if (!read_bytes(Handle, Mask, 256))
 | 
			
		||||
          if (!read_bytes(Handle, Mask_table, 256))
 | 
			
		||||
            goto Erreur_lecture_config;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
@ -1957,11 +1957,11 @@ int Sauver_CFG(void)
 | 
			
		||||
 | 
			
		||||
  // Sauvegarde des informations du Masque
 | 
			
		||||
  Chunk.Numero=CHUNK_MASQUE;
 | 
			
		||||
  Chunk.Taille=sizeof(Mask);
 | 
			
		||||
  Chunk.Taille=sizeof(Mask_table);
 | 
			
		||||
  if (!write_byte(Handle, Chunk.Numero) ||
 | 
			
		||||
      !write_word_le(Handle, Chunk.Taille) )
 | 
			
		||||
    goto Erreur_sauvegarde_config;
 | 
			
		||||
  if (!write_bytes(Handle, Mask,256))
 | 
			
		||||
  if (!write_bytes(Handle, Mask_table,256))
 | 
			
		||||
    goto Erreur_sauvegarde_config;
 | 
			
		||||
 | 
			
		||||
  // Sauvegarde des informations du Stencil
 | 
			
		||||
@ -2108,7 +2108,7 @@ void Config_par_defaut(void)
 | 
			
		||||
 | 
			
		||||
  // Masque
 | 
			
		||||
  for (Indice=0; Indice<256; Indice++)
 | 
			
		||||
    Mask[Indice]=0;
 | 
			
		||||
    Mask_table[Indice]=0;
 | 
			
		||||
 | 
			
		||||
  // Stencil
 | 
			
		||||
  for (Indice=0; Indice<256; Indice++)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								texte.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								texte.c
									
									
									
									
									
								
							@ -34,6 +34,10 @@
 | 
			
		||||
#else
 | 
			
		||||
  #include <SDL/SDL_ttf.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
  #include <X11/Xlib.h>
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#include <SDL/SDL_image.h>
 | 
			
		||||
// SFont
 | 
			
		||||
@ -110,6 +114,7 @@ void Ajout_fonte(const char *Nom)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Trouve le nom d'une fonte par son numéro
 | 
			
		||||
char * Nom_fonte(int Indice)
 | 
			
		||||
{
 | 
			
		||||
@ -120,6 +125,8 @@ char * Nom_fonte(int Indice)
 | 
			
		||||
    Fonte = Fonte->Suivante;
 | 
			
		||||
  return Fonte->Nom;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Trouve le libellé d'affichage d'une fonte par son numéro
 | 
			
		||||
char * Libelle_fonte(int Indice)
 | 
			
		||||
{
 | 
			
		||||
@ -148,6 +155,8 @@ char * Libelle_fonte(int Indice)
 | 
			
		||||
    Libelle[Indice]=Nom_fonte[Indice];
 | 
			
		||||
  return Libelle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Vérifie si une fonte donnée est TrueType
 | 
			
		||||
int TrueType_fonte(int Indice)
 | 
			
		||||
{
 | 
			
		||||
@ -183,13 +192,24 @@ void Initialisation_Texte(void)
 | 
			
		||||
  strcat(Nom_repertoire, "fonts");
 | 
			
		||||
  for_each_file(Nom_repertoire, Ajout_fonte);
 | 
			
		||||
  
 | 
			
		||||
  // Parcours du répertoire systeme windows "fonts"
 | 
			
		||||
  #ifdef __WIN32__
 | 
			
		||||
    // Parcours du répertoire systeme windows "fonts"
 | 
			
		||||
    #ifndef NOTTF
 | 
			
		||||
    for_each_file("c:\\windows\\fonts", Ajout_fonte);
 | 
			
		||||
    #endif
 | 
			
		||||
  #endif
 | 
			
		||||
  #elif defined(__linux__)
 | 
			
		||||
    // Récupération de la liste des fonts avec fontconfig
 | 
			
		||||
    #define USE_XLIB
 | 
			
		||||
 | 
			
		||||
    #ifdef USE_XLIB
 | 
			
		||||
	int i,number;
 | 
			
		||||
	Display* dpy = XOpenDisplay(NULL);
 | 
			
		||||
	char** font_path_list = XGetFontPath(dpy,&number);
 | 
			
		||||
 | 
			
		||||
	for(i=0;i<number;i++)
 | 
			
		||||
	    for_each_file(*(font_path_list+i),Ajout_fonte);
 | 
			
		||||
    #endif
 | 
			
		||||
  #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Informe si texte.c a été compilé avec l'option de support TrueType ou pas.
 | 
			
		||||
@ -276,6 +296,7 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int Anti
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
byte *Rendu_Texte_SFont(const char *Chaine, int Numero_fonte, int *Largeur, int *Hauteur)
 | 
			
		||||
{
 | 
			
		||||
  SFont_Font *Fonte;
 | 
			
		||||
@ -324,6 +345,7 @@ byte *Rendu_Texte_SFont(const char *Chaine, int Numero_fonte, int *Largeur, int
 | 
			
		||||
  return BrosseRetour;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Crée une brosse à partir des paramètres de texte demandés.
 | 
			
		||||
// Si cela réussit, la fonction place les dimensions dans Largeur et Hauteur, 
 | 
			
		||||
// et retourne l'adresse du bloc d'octets.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user