diff options
-rw-r--r-- | source/blender/ftfont/FTF_Api.h | 8 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_Api.cpp | 7 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_TTFont.cpp | 38 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_TTFont.h | 10 | ||||
-rw-r--r-- | source/blender/src/headerbuttons.c | 2 | ||||
-rw-r--r-- | source/blender/src/interface.c | 24 | ||||
-rw-r--r-- | source/blender/src/language.c | 2 |
7 files changed, 78 insertions, 13 deletions
diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h index 5272697c777..5c6b441df0c 100644 --- a/source/blender/ftfont/FTF_Api.h +++ b/source/blender/ftfont/FTF_Api.h @@ -118,10 +118,16 @@ 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 * @param size diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp index 42fac0c4061..cf9171d6ba5 100644 --- a/source/blender/ftfont/intern/FTF_Api.cpp +++ b/source/blender/ftfont/intern/FTF_Api.cpp @@ -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 * diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index 3233082cca7..ef17a610cd9 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -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; } diff --git a/source/blender/ftfont/intern/FTF_TTFont.h b/source/blender/ftfont/intern/FTF_TTFont.h index e4cdfd75b16..18d30e944f3 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.h +++ b/source/blender/ftfont/intern/FTF_TTFont.h @@ -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; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index a2b790c1245..ade2ced24f4 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -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; diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index da825cbbdc0..a67707cb66c 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -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) diff --git a/source/blender/src/language.c b/source/blender/src/language.c index a8918c3862f..dfe29615e87 100644 --- a/source/blender/src/language.c +++ b/source/blender/src/language.c @@ -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__) |