- AntiAlias fonts (FTF) now are used in three sizes, like the normal

fonts, and switched based at the window zoom.

  Might be something to tweak when to switch exactly, but it works
  cool!
This commit is contained in:
2003-10-23 18:25:08 +00:00
parent 0c177df766
commit 9efe4b7f9a
7 changed files with 78 additions and 13 deletions

View File

@@ -118,9 +118,15 @@ FTF_EXPORT float FTF_GetStringWidth(char* str, unsigned int flag);
FTF_EXPORT void FTF_GetBoundingBox(char* str, float*llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag);
/**
* Following stuff added by phase
* Following stuff added by phase, ton
*/
/**
* SetFontSize
* @param size
*/
FTF_EXPORT void FTF_SetFontSize(char size);
/**
* SetFont
* @param str

View File

@@ -128,6 +128,13 @@ FTF_EXPORT int FTF_SetFont(char* str, int size)
return ttfont.SetFont(str, size);
}
/* added bt ton */
FTF_EXPORT void FTF_SetFontSize(char size)
{
ttfont.SetFontSize( size);
}
/**
* added by phase
*

View File

@@ -147,28 +147,51 @@ FTF_TTFont::FTF_TTFont(void)
FTF_TTFont::~FTF_TTFont(void)
{
if (font) delete font;
if (fonts) delete fonts;
if (fontm) delete fontm;
if (fontl) delete fontl;
}
void FTF_TTFont::SetFontSize(char size)
{
if(size=='s') font=fonts;
else if(size=='l') font=fontl;
else font=fontm;
}
int FTF_TTFont::SetFont(char* str, int size)
{
int err = 0;
bool success = 0;
delete font;
delete fonts;
fonts= NULL;
delete fontm;
fontm= NULL;
delete fontl;
fontl= NULL;
font = new FTGLPixmapFont(str);
err = font->Error();
if(err) {
// printf("Failed to open font %s\n", str);
printf("Failed to open font %s\n", str);
return 0;
} else {
success = font->FaceSize(size);
fontm= font;
fonts = new FTGLPixmapFont(str);
fontl = new FTGLPixmapFont(str);
success = fonts->FaceSize(size-2<8?8:size-2);
success = fontm->FaceSize(size);
success = fontl->FaceSize(size+2);
if(!success) return 0;
success = font->CharMap(ft_encoding_unicode);
success = fonts->CharMap(ft_encoding_unicode);
success = fontm->CharMap(ft_encoding_unicode);
success = fontl->CharMap(ft_encoding_unicode);
if(!success) return 0;
return 1;
@@ -214,7 +237,10 @@ void FTF_TTFont::SetEncoding(char* str)
void FTF_TTFont::SetSize(int size)
{
font->FaceSize(size);
fonts->FaceSize(size-2<8?8:size-2);
fontm->FaceSize(size);
fontl->FaceSize(size+2);
font_size = size;
}

View File

@@ -79,9 +79,11 @@ public:
void GetBoundingBox(char* str, float *llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag);
/**
* added by phase
* added by phase, ton
* functions to communicate with the preference menu
*/
void SetFontSize(char size);
int SetFont(char* str, int size);
void SetLanguage(char* str);
@@ -97,7 +99,11 @@ protected:
int font_size;
/** FTGL's */
FTFont* font;
FTFont* font; /* active */
FTFont* fonts; /* opened, small medium and large */
FTFont* fontm;
FTFont* fontl;
/** from system encoding in .locale to UNICODE */
// iconv_t cd;

View File

@@ -1492,7 +1492,7 @@ void do_global_buttons(unsigned short event)
break;
case B_SETFONTSIZE: /* is button from space.c *info* */
FTF_SetSize(U.fontsize);
FTF_SetSize(U.fontsize);
allqueue(REDRAWALL, 0);
break;

View File

@@ -2379,6 +2379,8 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
}
}
ui_set_ftf_font(block); // sets just a pointer in ftf lib... the button dont have ftf handles
Mat4CpyMat4(UIwinmat, block->winmat);
uiPanelPush(block); // push matrix; no return without pop!
@@ -3052,11 +3054,28 @@ static void ui_set_but_val(uiBut *but, double value)
}
void uiSetCurFont(uiBlock *block, int index)
static void ui_set_ftf_font(uiBlock *block)
{
if(block->aspect<1.05) {
FTF_SetFontSize('l');
}
else if(block->aspect<1.59) {
FTF_SetFontSize('m');
}
else {
FTF_SetFontSize('s');
}
}
void uiSetCurFont(uiBlock *block, int index)
{
ui_set_ftf_font(block);
if(block->aspect<0.60) {
block->curfont= UIfont[index].xl;
block->curfont= UIfont[index].xl;
}
else if(block->aspect<1.15) {
block->curfont= UIfont[index].large;
@@ -3071,6 +3090,7 @@ void uiSetCurFont(uiBlock *block, int index)
if(block->curfont==NULL) block->curfont= UIfont[index].large;
if(block->curfont==NULL) block->curfont= UIfont[index].medium;
if(block->curfont==NULL) printf("error block no font %s\n", block->name);
}
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small)

View File

@@ -212,7 +212,7 @@ void start_interface_font(void) {
}
} else {
U.language= 0;
U.fontsize= 11;
U.fontsize= 10;
U.encoding= 0;
#if defined (__APPLE__)