Text: Help screen (F1), and font detection by file extension (unknown files are ignored)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@329 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2008-11-06 23:37:24 +00:00
parent 746b000d06
commit 83bfd14393
4 changed files with 70 additions and 37 deletions

View File

@ -103,7 +103,7 @@ ifeq ($(NOTTF),1)
TTFLABEL = -nottf
else
TTFCOPT =
TTFLOPT = `sdl-config --libs` -lSDL_ttf
TTFLOPT = -L/usr/local/lib -lSDL_ttf
TTFLIBS = libfreetype-6.dll SDL_ttf.dll
TTFLABEL =
endif

View File

@ -5917,6 +5917,8 @@ void Bouton_Texte()
A_redessiner=1;
A_previsionner=1;
}
if (Touche==Bouton[BOUTON_AIDE].Raccourci_gauche)
Fenetre_aide(BOUTON_TEXTE, NULL);
}
switch(Bouton_clicke)
{

View File

@ -1384,7 +1384,40 @@ static const char * TableAideEffets[] =
static const char * TableAideTexte[] =
{
AIDE_TITRE("TEXT")
AIDE_TEXTE(" *** Not implemented yet ***")
AIDE_TEXTE("")
AIDE_TEXTE("The text menu allows you to enter some text")
AIDE_TEXTE("and render it as a brush.")
AIDE_TEXTE("The current background and foreground colors")
AIDE_TEXTE("are very important, they determine the text")
AIDE_TEXTE("color, the transparent color, and also the")
AIDE_TEXTE("color range to use for antialiasing.")
AIDE_TEXTE("GrafX2 can use 'bitmap' fonts as long as")
AIDE_TEXTE("they are in the special layout supported ")
AIDE_TEXTE("by SFont.")
AIDE_TEXTE("TrueType fonts can also be used if this")
AIDE_TEXTE("version of GrafX2 was compiled with")
AIDE_TEXTE("TrueType support.")
AIDE_TEXTE("")
AIDE_TEXTE("- Txt: Click and enter your text here, a")
AIDE_TEXTE("line of up to 250 characters.")
AIDE_TEXTE("")
AIDE_TEXTE("- Clear txt: Empties the current text.")
AIDE_TEXTE("When the text is empty, a standard string")
AIDE_TEXTE("is shown instead in the preview area.")
AIDE_TEXTE("")
AIDE_TEXTE("- Antialias: Click to enable or disable")
AIDE_TEXTE("Antialiasing. Only affects TrueType fonts.")
AIDE_TEXTE("")
AIDE_TEXTE("- Size: Determine the font height. Only")
AIDE_TEXTE("affects TrueType fonts.")
AIDE_TEXTE("")
AIDE_TEXTE("- Font selector: Choose a font. You can")
AIDE_TEXTE("use the arrow keys (up and down) to quickly")
AIDE_TEXTE("browse your fonts.")
AIDE_TEXTE("TrueType fonts are indicated by 'TT'.")
AIDE_TEXTE("")
AIDE_TEXTE("- Preview area: Shows what the brush will")
AIDE_TEXTE("look like.")
};
static const char * TableAideLoupe[] =
{

68
texte.c
View File

@ -59,29 +59,46 @@ T_FONTE * Liste_fontes_debut;
T_FONTE * Liste_fontes_fin;
int Fonte_nombre;
// Inspiré par Allegro
#define EXTID(a,b,c) ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255)))
// Ajout d'une fonte à la liste.
void Ajout_fonte(const char *Nom)
{
T_FONTE * Fonte = (T_FONTE *)malloc(sizeof(T_FONTE));
int Taille=strlen(Nom)+1;
// Détermination du type:
if (Taille<5 ||
Nom[Taille-5]!='.')
return;
switch (EXTID(tolower(Nom[Taille-4]), tolower(Nom[Taille-3]), tolower(Nom[Taille-2])))
{
case EXTID('t','t','f'):
case EXTID('f','o','n'):
Fonte->EstTrueType = 1;
Fonte->EstImage = 0;
break;
case EXTID('b','m','p'):
case EXTID('g','i','f'):
case EXTID('j','p','g'):
case EXTID('l','b','m'):
case EXTID('p','c','x'):
case EXTID('p','n','g'):
case EXTID('t','g','a'):
case EXTID('t','i','f'):
case EXTID('x','c','f'):
case EXTID('x','p','m'):
case EXTID('.','x','v'):
Fonte->EstTrueType = 0;
Fonte->EstImage = 1;
break;
default:
return;
}
Fonte->Nom = (char *)malloc(Taille);
strcpy(Fonte->Nom, Nom);
// Détermination du type:
// On va faire simple: .TTF c'est TrueType, sinon on tente Bitmap.
if (Taille>=5 &&
Fonte->Nom[Taille-5]=='.' &&
tolower(Fonte->Nom[Taille-4]) == 't' &&
tolower(Fonte->Nom[Taille-3]) == 't' &&
tolower(Fonte->Nom[Taille-2]) == 'f')
{
Fonte->EstTrueType = 1;
Fonte->EstImage = 0;
}
else
{
Fonte->EstTrueType = 0;
Fonte->EstImage = 1;
}
// Gestion Liste
Fonte->Suivante = NULL;
if (Liste_fontes_debut==NULL)
@ -194,7 +211,6 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int Anti
SDL_Surface * Texte8Bit;
byte * BrosseRetour;
int Indice;
SDL_Color PaletteSDL[256];
SDL_Color Couleur_Avant;
SDL_Color Couleur_Arriere;
@ -230,25 +246,7 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int Anti
}
Texte8Bit=SDL_DisplayFormat(TexteColore);
/*
Texte8Bit=SDL_CreateRGBSurface(SDL_SWSURFACE, TexteColore->w, TexteColore->h, 8, 0, 0, 0, 0);
if (!Texte8Bit)
{
SDL_FreeSurface(TexteColore);
TTF_CloseFont(Fonte);
return NULL;
}
for(Indice=0;Indice<256;Indice++)
{
PaletteSDL[Indice].r=(Principal_Palette[Indice].R<<2) + (Principal_Palette[Indice].R>>4); //Les couleurs VGA ne vont que de 0 à 63
PaletteSDL[Indice].g=(Principal_Palette[Indice].V<<2) + (Principal_Palette[Indice].V>>4);
PaletteSDL[Indice].b=(Principal_Palette[Indice].B<<2) + (Principal_Palette[Indice].B>>4);
}
SDL_SetPalette(Texte8Bit,SDL_PHYSPAL|SDL_LOGPAL,PaletteSDL,0,256);
SDL_BlitSurface(TexteColore, NULL, Texte8Bit, NULL);
*/
SDL_FreeSurface(TexteColore);
BrosseRetour=Surface_en_bytefield(Texte8Bit, NULL);