diff options
40 files changed, 127 insertions, 1721 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index b76ce220ab3..9ec9efa6a8d 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -26,10 +26,6 @@ SUBDIRS(windowmanager editors avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna makesrna radiosity readblenfile render blenfont) -IF(WITH_INTERNATIONAL) - SUBDIRS(ftfont) -ENDIF(WITH_INTERNATIONAL) - IF(WITH_OPENEXR) SUBDIRS(imbuf/intern/openexr) ENDIF(WITH_OPENEXR) diff --git a/source/blender/Makefile b/source/blender/Makefile index a12b53e6153..b8809c87213 100644 --- a/source/blender/Makefile +++ b/source/blender/Makefile @@ -36,10 +36,6 @@ DIRS += makesdna makesrna yafray DIRS += python nodes gpu DIRS += blenfont -ifeq ($(WITH_FREETYPE2), true) - DIRS += ftfont -endif - ifeq ($(WITH_QUICKTIME), true) DIRS += quicktime endif diff --git a/source/blender/SConscript b/source/blender/SConscript index e38d593d9a8..f8b7fd358fe 100644 --- a/source/blender/SConscript +++ b/source/blender/SConscript @@ -28,9 +28,6 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_YAFRAY']: SConscript(['yafray/SConscript']) -if env['WITH_BF_INTERNATIONAL']: - SConscript (['ftfont/SConscript']) - if env['WITH_BF_DDS']: SConscript (['imbuf/intern/dds/SConscript']) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index e0962eadfca..7f07de80754 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -62,7 +62,6 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" /* XXX */ @@ -86,7 +85,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) sprintf(str, " %.2f", FRA2TIME(CFRA)); else sprintf(str, " %d", CFRA); - slen= (short)UI_GetStringWidth(G.font, str, 0) - 1; + slen= (short)UI_GetStringWidth(str) - 1; /* get starting coordinates for drawing */ x= cfra * xscale; @@ -98,8 +97,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - ui_rasterpos_safe(x-5, y+3, 1.0f); - UI_DrawString(G.fonts, str, 0); // XXX may need to be updated for font stuff + UI_DrawString(x-5, y+3, str); // XXX may need to be updated for font stuff /* restore view transform */ glScalef(xscale, 1.0, 1.0); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index fc52d9c4511..58e3aa8e172 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -57,7 +57,6 @@ #include "UI_interface_icons.h" #include "UI_view2d.h" #include "UI_resources.h" -#include "UI_text.h" #include "ED_markers.h" #include "ED_screen.h" @@ -85,9 +84,6 @@ static ListBase *context_get_markers(const bContext *C) /* ************* Marker Drawing ************ */ -/* XXX */ -extern void ui_rasterpos_safe(float x, float y, float aspect); - /* function to draw markers */ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) { @@ -140,18 +136,25 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* and the marker name too, shifted slightly to the top-right */ if (marker->name && marker->name[0]) { + float x, y; + if(marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); - ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0); + x= xpos*xscale+4.0; + y= (ypixels<=39.0)?(ypixels-10.0):29.0; } else { UI_ThemeColor(TH_TEXT); - if((marker->frame <= cfra) && (marker->frame+5 > cfra)) - ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0); - else - ui_rasterpos_safe(xpos*xscale+4.0, 17.0, 1.0); + if((marker->frame <= cfra) && (marker->frame+5 > cfra)) { + x= xpos*xscale+4.0; + y= (ypixels<=39.0)?(ypixels-10.0):29.0; + } + else { + x= xpos*xscale+4.0; + y= 17.0; + } } - UI_DrawString(G.font, marker->name, 0); + UI_DrawString(x, y, marker->name); } glScalef(xscale, 1.0, 1.0); } diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 6e58efbe73b..cfbd6d2bced 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -83,7 +83,6 @@ #include "UI_interface.h" #include "UI_interface_icons.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "ED_anim_api.h" diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 44fee85b085..43ba46a0f63 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -292,17 +292,6 @@ void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb); void uiBlockSetButLock(uiBlock *block, int val, char *lockstr); void uiBlockClearButLock(uiBlock *block); -/* Appearance/Cruft - * - * These functions should mostly dissappear ideally, or become internal. - * Font handling could move to blenfont/, and appearance could be dictated - * better by high level information instead of spread out all over. */ - -void uiSetCurFont(uiBlock *block, int index); -void *uiSetCurFont_ext(float aspect); -void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small); -void *uiBlockGetCurFont (uiBlock *block); - /* automatic aligning, horiz or verical */ void uiBlockBeginAlign(uiBlock *block); void uiBlockEndAlign(uiBlock *block); @@ -638,7 +627,8 @@ void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, str void uiStyleFontSet(struct uiFontStyle *fs); void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str); - +int UI_GetStringWidth(char *str); // XXX temp +void UI_DrawString(float x, float y, char *str); // XXX temp #endif /* UI_INTERFACE_H */ diff --git a/source/blender/editors/include/UI_text.h b/source/blender/editors/include/UI_text.h deleted file mode 100644 index 860fd5e15aa..00000000000 --- a/source/blender/editors/include/UI_text.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef UI_TEXT_H -#define UI_TEXT_H - -struct BMF_Font; - -void set_interface_font(char *str); /* headerbuttons.c */ -void start_interface_font(void); /* headerbuttons.c */ - -char *fontsize_pup(void); - -int UI_DrawString(struct BMF_Font* font, char *str, int translate); -float UI_GetStringWidth(struct BMF_Font* font, char *str, int translate); -void UI_GetBoundingBox(struct BMF_Font* font, char* str, int translate, rctf* bbox); - -void UI_set_international(int international); -int UI_get_international(void); - -void UI_RasterPos(float x, float y); -void UI_SetScale(float aspect); -void ui_text_init_userdef(void); - - -#endif /* UI_TEXT_H */ - diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ea3b1ca3bce..c397c3c2ecc 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -55,12 +55,6 @@ #include "BLF_api.h" #include "UI_interface.h" -#include "UI_text.h" - -#include "BMF_Api.h" -#ifdef INTERNATIONAL -#include "FTF_Api.h" -#endif #include "ED_screen.h" @@ -88,10 +82,6 @@ static void ui_free_but(const bContext *C, uiBut *but); static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but); -/* ************ GLOBALS ************* */ - -static uiFontOld UIfont[UI_ARRAY]; // no init needed - /* ************* translation ************** */ int ui_translate_buttons() @@ -1718,82 +1708,6 @@ void ui_set_but_soft_range(uiBut *but, double value) } } -/* ******************* Font ********************/ - -static void ui_set_ftf_font(float aspect) -{ -#ifdef INTERNATIONAL - if(aspect<1.15) { - FTF_SetFontSize('l'); - } - else if(aspect<1.59) { - FTF_SetFontSize('m'); - } - else { - FTF_SetFontSize('s'); - } -#endif -} - -void uiSetCurFont(uiBlock *block, int index) -{ - ui_set_ftf_font(block->aspect); - - if(block->aspect<0.60) { - block->curfont= UIfont[index].xl; - } - else if(block->aspect<1.15) { - block->curfont= UIfont[index].large; - } - else if(block->aspect<1.59) { - block->curfont= UIfont[index].medium; - } - else { - block->curfont= UIfont[index].small; - } - - 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); - -} - -/* called by node editor */ -void *uiSetCurFont_ext(float aspect) -{ - void *curfont; - - ui_set_ftf_font(aspect); - - if(aspect<0.60) { - curfont= UIfont[0].xl; - } - else if(aspect<1.15) { - curfont= UIfont[0].large; - } - else if(aspect<1.59) { - curfont= UIfont[0].medium; - } - else { - curfont= UIfont[0].small; - } - - if(curfont==NULL) curfont= UIfont[0].large; - if(curfont==NULL) curfont= UIfont[0].medium; - - return curfont; -} - -void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small) -{ - if(index>=UI_ARRAY) return; - - UIfont[index].xl= xl; - UIfont[index].large= large; - UIfont[index].medium= medium; - UIfont[index].small= small; -} - /* ******************* Free ********************/ static void ui_free_link(uiLink *link) @@ -3271,24 +3185,12 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, void UI_init(void) { - uiDefFont(UI_HELVB, - BMF_GetFont(BMF_kHelveticaBold14), - BMF_GetFont(BMF_kHelveticaBold12), - BMF_GetFont(BMF_kHelveticaBold10), - BMF_GetFont(BMF_kHelveticaBold8)); - uiDefFont(UI_HELV, - BMF_GetFont(BMF_kHelvetica12), - BMF_GetFont(BMF_kHelvetica12), - BMF_GetFont(BMF_kHelvetica10), - BMF_GetFont(BMF_kHelveticaBold8)); - ui_resources_init(); } void UI_init_userdef() { uiStyleInit(); - ui_text_init_userdef(); ui_theme_init_userdef(); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index fc3808a6608..fd99e6b84a0 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -48,12 +48,6 @@ #include "UI_interface.h" #include "UI_interface_icons.h" -#include "UI_text.h" - -#include "BMF_Api.h" -#ifdef INTERNATIONAL -#include "FTF_Api.h" -#endif #include "interface_intern.h" @@ -453,35 +447,6 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) } -/* ************** safe rasterpos for pixmap alignment with pixels ************* */ - -void ui_rasterpos_safe(float x, float y, float aspect) -{ - float vals[4], remainder; - int doit=0; - - glRasterPos2f(x, y); - glGetFloatv(GL_CURRENT_RASTER_POSITION, vals); - - remainder= vals[0] - floor(vals[0]); - if(remainder > 0.4 && remainder < 0.6) { - if(remainder < 0.5) x -= 0.1*aspect; - else x += 0.1*aspect; - doit= 1; - } - remainder= vals[1] - floor(vals[1]); - if(remainder > 0.4 && remainder < 0.6) { - if(remainder < 0.5) y -= 0.1*aspect; - else y += 0.1*aspect; - doit= 1; - } - - if(doit) glRasterPos2f(x, y); - - UI_RasterPos(x, y); - UI_SetScale(aspect); -} - /* ************** generic embossed rect, for window sliders etc ************* */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b41fe7b9b7d..cebf4f255f8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -51,7 +51,9 @@ #include "ED_screen.h" #include "UI_interface.h" -#include "UI_text.h" + +#include "BLF_api.h" + #include "interface_intern.h" #include "RNA_access.h" @@ -807,14 +809,17 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, short x) { + uiStyle *style= U.uistyles.first; // XXX pass on as arg char *origstr; - + + uiStyleFontSet(&style->widget); + origstr= MEM_callocN(sizeof(char)*(data->maxlen+1), "ui_textedit origstr"); BLI_strncpy(origstr, but->drawstr, data->maxlen+1); but->pos= strlen(origstr)-but->ofs; - while((but->aspect*UI_GetStringWidth(but->font, origstr+but->ofs, 0) + but->x1) > x) { + while((BLF_width(origstr+but->ofs) + but->x1) > x) { if (but->pos <= 0) break; but->pos--; origstr[but->pos+but->ofs] = 0; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index f2f0582a5e2..0c97c1fd008 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -831,7 +831,9 @@ static void icon_set_image(ID *id, DrawInfo *di, PreviewImage* prv_img, int mipl static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw, int rh, unsigned int *rect) { - ui_rasterpos_safe(x, y, aspect); + + glRasterPos2f(x, y); + // XXX ui_rasterpos_safe(x, y, aspect); if((w<1 || h<1)) { // XXX - TODO 2.5 verify whether this case can happen diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 84ce8ed5ec0..b62ba386330 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -366,7 +366,6 @@ extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event); extern void ui_draw_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); /* interface_draw.c */ -extern void ui_rasterpos_safe(float x, float y, float aspect); extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 6d7a0eae6af..5f365d3d7dc 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -59,7 +59,6 @@ #include "ED_screen.h" #include "UI_interface.h" -#include "UI_text.h" #include "UI_view2d.h" #include "interface_intern.h" diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 475f19b0cbd..85091fc45c2 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -32,6 +32,7 @@ #include "DNA_screen_types.h" #include "DNA_view2d_types.h" +#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "BLI_arithb.h" @@ -54,9 +55,10 @@ #include "BIF_gl.h" #include "UI_interface.h" -#include "UI_text.h" #include "UI_view2d.h" +#include "BLF_api.h" + #include "ED_screen.h" #include "interface_intern.h" @@ -259,6 +261,7 @@ typedef struct uiTooltipData { static void ui_tooltip_region_draw(const bContext *C, ARegion *ar) { + uiStyle *style= U.uistyles.first; // XXX pass on as arg uiTooltipData *data; int x1, y1, x2, y2; @@ -283,10 +286,10 @@ static void ui_tooltip_region_draw(const bContext *C, ARegion *ar) * an equal gap between the top of the background box and the top of the * string's bbox, and the bottom of the background box, and the bottom of * the string's bbox */ - ui_rasterpos_safe(5, ((y2-data->bbox.ymax)+(y1+data->bbox.ymin))/2 - data->bbox.ymin - y1, data->aspect); - UI_SetScale(1.0); - - UI_DrawString(data->font, data->tip, ui_translate_tooltips()); + + uiStyleFontSet(&style->widget); + BLF_position(5, ((y2-data->bbox.ymax)+(y1+data->bbox.ymin))/2 - data->bbox.ymin - y1, 0.0f); + BLF_draw(data->tip); } static void ui_tooltip_region_free(ARegion *ar) @@ -301,6 +304,7 @@ static void ui_tooltip_region_free(ARegion *ar) ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) { + uiStyle *style= U.uistyles.first; // XXX pass on as arg static ARegionType type; ARegion *ar; uiTooltipData *data; @@ -322,7 +326,10 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->tip= BLI_strdup(but->tip); data->font= but->font; data->aspect= but->aspect; - UI_GetBoundingBox(data->font, data->tip, ui_translate_tooltips(), &data->bbox); + + /* set font, get bb */ + uiStyleFontSet(&style->widget); + BLF_boundbox(data->tip, &data->bbox); ar->regiondata= data; @@ -759,12 +766,12 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b /* size and location */ if(md->title) - width= 1.5*aspect*strlen(md->title)+UI_GetStringWidth(block->curfont, md->title, ui_translate_menus()); + width= 1.5*aspect*strlen(md->title)+UI_GetStringWidth(md->title); else width= 0; for(a=0; a<md->nitems; a++) { - xmax= aspect*UI_GetStringWidth(block->curfont, md->items[a].str, ui_translate_menus()); + xmax= aspect*UI_GetStringWidth(md->items[a].str); if(md->items[a].icon) xmax += 20*aspect; if(xmax>width) @@ -872,12 +879,12 @@ uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiPopupBlockHandle *handle, void /* size and location */ /* expand menu width to fit labels */ if(md->title) - width= 2*strlen(md->title)+UI_GetStringWidth(block->curfont, md->title, ui_translate_menus()); + width= 2*strlen(md->title)+UI_GetStringWidth(md->title); else width= 0; for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(block->curfont, md->items[a].str, ui_translate_menus()); + xmax= UI_GetStringWidth(md->items[a].str); if(xmax>width) width= xmax; } @@ -1347,13 +1354,13 @@ uiBlock *ui_block_func_PUPMENU(bContext *C, uiPopupBlockHandle *handle, void *ar /* size and location, title slightly bigger for bold */ if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(uiBlockGetCurFont(block), md->title, ui_translate_buttons()); + width= 2*strlen(md->title)+UI_GetStringWidth(md->title); width /= columns; } else width= 0; for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(uiBlockGetCurFont(block), md->items[a].str, ui_translate_buttons()); + xmax= UI_GetStringWidth(md->items[a].str); if(xmax>width) width= xmax; if(strcmp(md->items[a].str, "%l")==0) height+= PUP_LABELH; @@ -1520,13 +1527,13 @@ uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiPopupBlockHandle *handle, void /* size and location, title slightly bigger for bold */ if(md->title) { - width= 2*strlen(md->title)+UI_GetStringWidth(uiBlockGetCurFont(block), md->title, ui_translate_buttons()); + width= 2*strlen(md->title)+UI_GetStringWidth(md->title); width /= columns; } else width= 0; for(a=0; a<md->nitems; a++) { - xmax= UI_GetStringWidth(uiBlockGetCurFont(block), md->items[a].str, ui_translate_buttons()); + xmax= UI_GetStringWidth(md->items[a].str); if(xmax>width) width= xmax; } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 82ff20b2495..ca773277132 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -52,7 +52,6 @@ #include "UI_interface.h" #include "UI_interface_icons.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "ED_datafiles.h" @@ -178,6 +177,26 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str) BLF_disable(BLF_CLIPPING); } +/* ************** helpers ************************ */ + +/* temporarily, does widget font */ +int UI_GetStringWidth(char *str) +{ + uiStyle *style= U.uistyles.first; + + uiStyleFontSet(&style->widget); + return BLF_width(str); +} + +/* temporarily, does widget font */ +void UI_DrawString(float x, float y, char *str) +{ + uiStyle *style= U.uistyles.first; + + uiStyleFontSet(&style->widget); + BLF_position(x, y, 0.0f); + BLF_draw(str); +} /* ************** init exit ************************ */ diff --git a/source/blender/editors/interface/text.c b/source/blender/editors/interface/text.c deleted file mode 100644 index c3dc40e59ef..00000000000 --- a/source/blender/editors/interface/text.c +++ /dev/null @@ -1,276 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is written by Rob Haarsma (phase) - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* XXX 2.50 this file must be cleanup still, using globals etc. */ - -#include <string.h> -#include <stdlib.h> - -#include "MEM_guardedalloc.h" - -#include "DNA_listBase.h" -#include "DNA_userdef_types.h" -#include "DNA_vec_types.h" - -#include "BKE_global.h" /* G */ -#include "BKE_utildefines.h" - -#include "BLI_blenlib.h" -#include "BLI_linklist.h" /* linknode */ - -#include "BIF_gl.h" -#include "UI_text.h" -#include "BLF_api.h" - -#include "ED_datafiles.h" - -#include "BMF_Api.h" - -#ifdef WITH_ICONV -#include "iconv.h" - -void string_to_utf8(char *original, char *utf_8, char *code) -{ - size_t inbytesleft=strlen(original); - size_t outbytesleft=512; - size_t rv=0; - iconv_t cd; - - cd=iconv_open("UTF-8", code); - - if (cd == (iconv_t)(-1)) { - printf("iconv_open Error"); - *utf_8='\0'; - return ; - } - rv=iconv(cd, &original, &inbytesleft, &utf_8, &outbytesleft); - if (rv == (size_t) -1) { - printf("iconv Error\n"); - return ; - } - *utf_8 = '\0'; - iconv_close(cd); -} -#endif // WITH_ICONV - -#ifdef INTERNATIONAL -#include "FTF_Api.h" -#endif - -void UI_RasterPos(float x, float y) -{ -#ifdef INTERNATIONAL - FTF_SetPosition(x, y); -#endif // INTERNATIONAL -} - -void UI_SetScale(float aspect) -{ -#ifdef INTERNATIONAL - FTF_SetScale(aspect); -#endif // INTERNATIONAL -} - -void ui_text_init_userdef(void) -{ - int id; - - id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); - if (id == -1) - printf("Warning can't load built-in font ??\n"); - else { - BLF_set(id); - BLF_size(12, 72); - BLF_size(11, 96); - BLF_size(14, 96); - } - -#ifdef INTERNATIONAL - if(U.transopts & USER_DOTRANSLATE) - start_interface_font(); - else - G.ui_international= FALSE; -#else // INTERNATIONAL - G.ui_international= FALSE; -#endif -} - -int UI_DrawString(BMF_Font* font, char *str, int translate) -{ -#ifdef INTERNATIONAL - if(G.ui_international == TRUE) { - if(translate) - { -#ifdef WITH_ICONV - if(translate & CONVERT_TO_UTF8) { - char utf_8[512]; - char *code; - - code= BLF_lang_find_code(U.language); - if (lme) { - if (!strcmp(code, "ja_JP")) - string_to_utf8(str, utf_8, "Shift_JIS"); /* Japanese */ - else if (!strcmp(code, "zh_CN")) - string_to_utf8(str, utf_8, "GB2312"); /* Chinese */ - } - return FTF_DrawString(utf_8, FTF_INPUT_UTF8); - } - else -#endif // WITH_ICONV - return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8); - } - else - return FTF_DrawString(str, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); - } else { - return BMF_DrawString(font, str); - } -#else // INTERNATIONAL - return BMF_DrawString(font, str); -#endif -} - -float UI_GetStringWidth(BMF_Font* font, char *str, int translate) -{ - float rt; - -#ifdef INTERNATIONAL - if(G.ui_international == TRUE) - if(translate && (U.transopts & USER_TR_BUTTONS)) - rt= FTF_GetStringWidth(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8); - else - rt= FTF_GetStringWidth(str, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); - else - rt= BMF_GetStringWidth(font, str); -#else - rt= BMF_GetStringWidth(font, str); -#endif - - return rt; -} - -void UI_GetBoundingBox(struct BMF_Font* font, char* str, int translate, rctf *bbox) -{ -#ifdef INTERNATIONAL - float dummy; - if(G.ui_international == TRUE) - if(translate && (U.transopts & USER_TR_BUTTONS)) - FTF_GetBoundingBox(str, &bbox->xmin, &bbox->ymin, &dummy, &bbox->xmax, &bbox->ymax, &dummy, FTF_USE_GETTEXT | FTF_INPUT_UTF8); - else - FTF_GetBoundingBox(str, &bbox->xmin, &bbox->ymin, &dummy, &bbox->xmax, &bbox->ymax, &dummy, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); - else - BMF_GetStringBoundingBox(font, str, &bbox->xmin, &bbox->ymin, &bbox->xmax, &bbox->ymax); -#else - BMF_GetStringBoundingBox(font, str, &bbox->xmin, &bbox->ymin, &bbox->xmax, &bbox->ymax); -#endif -} - -#ifdef INTERNATIONAL - -char *fontsize_pup(void) -{ - static char string[1024]; - char formatstring[1024]; - - strcpy(formatstring, "Choose Font Size: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d"); - - sprintf(string, formatstring, - "Font Size: 8", 8, - "Font Size: 9", 9, - "Font Size: 10", 10, - "Font Size: 11", 11, - "Font Size: 12", 12, - "Font Size: 13", 13, - "Font Size: 14", 14, - "Font Size: 15", 15, - "Font Size: 16", 16 - ); - - return (string); -} - -/* called from fileselector */ -void set_interface_font(char *str) -{ - - /* this test needed because fileselect callback can happen after disable AA fonts */ - if(U.transopts & USER_DOTRANSLATE) { - if(FTF_SetFont((unsigned char*)str, 0, U.fontsize)) { - BLF_lang_set(U.language); - if(strlen(str) < FILE_MAXDIR) strcpy(U.fontname, str); - G.ui_international = TRUE; - } - else { - U.fontname[0]= 0; - FTF_SetFont((unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size, U.fontsize); - G.ui_international = TRUE; // this case will switch to standard font - /* XXX 2.50 bad call okee("Invalid font selection - reverting to built-in font."); */ - } - /* XXX 2.50 bad call allqueue(REDRAWALL, 0); */ - } -} - -void start_interface_font(void) -{ - int result = 0; - - if(U.transopts & USER_USETEXTUREFONT) - FTF_SetMode(FTF_TEXTUREFONT); - else - FTF_SetMode(FTF_PIXMAPFONT); - - if(U.fontsize && U.fontname[0] ) { // we have saved user settings + fontpath - - // try loading font from U.fontname = full path to font in usersettings - result = FTF_SetFont((unsigned char*)U.fontname, 0, U.fontsize); - } - else if(U.fontsize) { // user settings, default - result = FTF_SetFont((unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size, U.fontsize); - } - - if(result==0) { // use default - U.language= 0; - U.fontsize= 11; - U.encoding= 0; - U.fontname[0]= 0; - result = FTF_SetFont((unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size, U.fontsize); - } - - if(result) { - BLF_lang_set(U.language); - G.ui_international = TRUE; - } - else { - printf("no font found for international support\n"); - G.ui_international = FALSE; - U.transopts &= ~USER_DOTRANSLATE; - U.fontsize = 0; - } - - /* XXX 2.50 bad call allqueue(REDRAWALL, 0); */ -} - -#endif /* INTERNATIONAL */ - diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 98aa16c84e4..34c8bfaab74 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -49,11 +49,12 @@ #include "ED_screen.h" +#include "BMF_Api.h" + +#include "UI_interface.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" -#include "UI_interface.h" #include "interface_intern.h" /* *********************************************************************** */ @@ -1373,8 +1374,8 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f } /* draw it */ - ui_rasterpos_safe(x, y, 1.0); - UI_DrawString(G.fonts, str, 0); // XXX check this again when new text-drawing api is done + glRasterPos2f(x, y); + BMF_DrawString(G.fonts, str); // XXX check this again when new text-drawing api is done } /* local defines for scrollers drawing */ diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index b87fdf65904..669320e72bf 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -82,7 +82,6 @@ #include "UI_interface.h" #include "UI_interface_icons.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "ED_anim_api.h" @@ -114,7 +113,6 @@ #endif // XXX old defines for reference only /* XXX */ -extern void ui_rasterpos_safe(float x, float y, float aspect); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); /********************************** Slider Stuff **************************** */ @@ -920,8 +918,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar) else UI_ThemeColor(TH_TEXT); offset += 3; - ui_rasterpos_safe(x+offset, y-4, 1.0f); - UI_DrawString(G.font, name, 0); + UI_DrawString(x+offset, y-4, name); /* reset offset - for RHS of panel */ offset = 0; diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index c65c486d4bb..d54d3ceb7d8 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -66,7 +66,6 @@ #include "UI_interface.h" #include "UI_interface_icons.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "WM_api.h" @@ -135,8 +134,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) */ /* space available for load/save buttons? */ - slen = UI_GetStringWidth(G.font, sfile->params->title, 0); - loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0)); + slen = UI_GetStringWidth(sfile->params->title); + loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(params->title)); if(ar->winx > loadbutton+20) { if(params->title[0]==0) { loadbutton= 0; @@ -150,7 +149,6 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiDefBut(block, TEX, 0 /* XXX B_FS_DIRNAME */,"", xmin+2, filebuty2, xmax-xmin-loadbutton-4, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, ""); if(loadbutton) { - uiSetCurFont(block, UI_HELV); uiDefBut(block, BUT, B_FS_EXEC, params->title, xmax-loadbutton, filebuty2, loadbutton, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, ""); uiDefBut(block, BUT, B_FS_CANCEL, "Cancel", xmax-loadbutton, filebuty1, loadbutton, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, ""); } @@ -198,14 +196,14 @@ static float shorten_string(char* string, float w, int flag) float sw = 0; float pad = 0; - sw = UI_GetStringWidth(G.font, string,0); + sw = UI_GetStringWidth(string); if (flag == FILE_SHORTEN_FRONT) { char *s = string; BLI_strncpy(temp, "...", 4); - pad = UI_GetStringWidth(G.font, temp,0); + pad = UI_GetStringWidth(temp); while (s && (sw+pad>w)) { s++; - sw = UI_GetStringWidth(G.font, s,0); + sw = UI_GetStringWidth(s); shortened = 1; } if (shortened) { @@ -219,7 +217,7 @@ static float shorten_string(char* string, float w, int flag) while (sw>w) { int slen = strlen(string); string[slen-1] = '\0'; - sw = UI_GetStringWidth(G.font, s,0); + sw = UI_GetStringWidth(s); shortened = 1; } if (shortened) { @@ -284,15 +282,11 @@ static void file_draw_string(short sx, short sy, const char* string, short width x = (float)(sx); y = (float)(sy-height); - // XXX was using ui_rasterpos_safe - glRasterPos2f(x, y); - UI_RasterPos(x, y); - /* XXX TODO: handling of international fonts. TODO: proper support for utf8 in languages different from ja_JP abd zh_CH needs update of iconv in lib/windows to support getting the system language string */ - UI_DrawString(G.font, fname, 0); + UI_DrawString(x, y, fname); } @@ -501,12 +495,12 @@ void file_draw_list(const bContext *C, ARegion *ar) UI_ThemeColor4(TH_TEXT); - sw = UI_GetStringWidth(G.font, file->relname, 0); + sw = UI_GetStringWidth(file->relname); file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END); spos += filelist_column_len(sfile->files, COLUMN_NAME) + 10; if (params->display == FILE_SHOWSHORT) { if (!(file->type & S_IFDIR)) { - sw = UI_GetStringWidth(G.font, file->size, 0); + sw = UI_GetStringWidth(file->size); spos += filelist_column_len(sfile->files, COLUMN_SIZE) + 10 - sw; file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); } @@ -514,33 +508,33 @@ void file_draw_list(const bContext *C, ARegion *ar) #if 0 // XXX TODO: add this for non-windows systems /* rwx rwx rwx */ spos += 20; - sw = UI_GetStringWidth(G.font, file->mode1, 0); + sw = UI_GetStringWidth(file->mode1); file_draw_string(spos, sy, file->mode1, sw, layout->tile_h); spos += 30; - sw = UI_GetStringWidth(G.font, file->mode2, 0); + sw = UI_GetStringWidth(file->mode2); file_draw_string(spos, sy, file->mode2, sw, layout->tile_h); spos += 30; - sw = UI_GetStringWidth(G.font, file->mode3, 0); + sw = UI_GetStringWidth(file->mode3); file_draw_string(spos, sy, file->mode3, sw, layout->tile_h); spos += 30; - sw = UI_GetStringWidth(G.font, file->owner, 0); + sw = UI_GetStringWidth(file->owner); file_draw_string(spos, sy, file->owner, sw, layout->tile_h); #endif - sw = UI_GetStringWidth(G.font, file->date, 0); + sw = UI_GetStringWidth(file->date); file_draw_string(spos, sy, file->date, sw, layout->tile_h, FILE_SHORTEN_END); spos += filelist_column_len(sfile->files, COLUMN_DATE) + 10; - sw = UI_GetStringWidth(G.font, file->time, 0); + sw = UI_GetStringWidth(file->time); file_draw_string(spos, sy, file->time, sw, layout->tile_h, FILE_SHORTEN_END); spos += filelist_column_len(sfile->files, COLUMN_TIME) + 10; if (!(file->type & S_IFDIR)) { - sw = UI_GetStringWidth(G.font, file->size, 0); + sw = UI_GetStringWidth(file->size); spos += filelist_column_len(sfile->files, COLUMN_SIZE) + 10 - sw; file_draw_string(spos, sy, file->size, sw, layout->tile_h, FILE_SHORTEN_END); } diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index 54dd7ff15ba..7de62056336 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -56,7 +56,6 @@ #include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" -#include "UI_text.h" #include "file_intern.h" #include "filelist.h" @@ -178,7 +177,7 @@ void file_header_buttons(const bContext *C, ARegion *ar) } xcotitle= xco; - xco+= UI_GetStringWidth(G.font, params->title, 0); + xco+= UI_GetStringWidth(params->title); uiBlockSetEmboss(block, UI_EMBOSS); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 1ba84566940..9d7f16000c9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -82,7 +82,7 @@ #include "PIL_time.h" -#include "UI_text.h" +#include "UI_interface.h" #include "filelist.h" @@ -695,21 +695,21 @@ void filelist_readdir(struct FileList* filelist) struct direntry* file = filelist_file(filelist, i); if (file) { int len; - len = UI_GetStringWidth(G.font, file->relname,0); + len = UI_GetStringWidth(file->relname); if (len > filelist->columns[COLUMN_NAME]) filelist->columns[COLUMN_NAME] = len; - len = UI_GetStringWidth(G.font, file->date,0); + len = UI_GetStringWidth(file->date); if (len > filelist->columns[COLUMN_DATE]) filelist->columns[COLUMN_DATE] = len; - len = UI_GetStringWidth(G.font, file->time,0); + len = UI_GetStringWidth(file->time); if (len > filelist->columns[COLUMN_TIME]) filelist->columns[COLUMN_TIME] = len; - len = UI_GetStringWidth(G.font, file->size,0); + len = UI_GetStringWidth(file->size); if (len > filelist->columns[COLUMN_SIZE]) filelist->columns[COLUMN_SIZE] = len; - len = UI_GetStringWidth(G.font, file->mode1,0); + len = UI_GetStringWidth(file->mode1); if (len > filelist->columns[COLUMN_MODE1]) filelist->columns[COLUMN_MODE1] = len; - len = UI_GetStringWidth(G.font, file->mode2,0); + len = UI_GetStringWidth(file->mode2); if (len > filelist->columns[COLUMN_MODE2]) filelist->columns[COLUMN_MODE2] = len; - len = UI_GetStringWidth(G.font, file->mode3,0); + len = UI_GetStringWidth(file->mode3); if (len > filelist->columns[COLUMN_MODE3]) filelist->columns[COLUMN_MODE3] = len; - len = UI_GetStringWidth(G.font, file->owner,0); + len = UI_GetStringWidth(file->owner); if (len > filelist->columns[COLUMN_OWNER]) filelist->columns[COLUMN_OWNER] = len; } } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index df1d0133e42..0353f590347 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -84,10 +84,8 @@ #include "UI_interface_icons.h" #include "UI_resources.h" #include "UI_view2d.h" -#include "UI_text.h" /* XXX */ -extern void ui_rasterpos_safe(float x, float y, float aspect); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); /* *************************** */ @@ -1363,8 +1361,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) else UI_ThemeColor(TH_TEXT); offset += 3; - ui_rasterpos_safe(x+offset, y-4, 1.0f); - UI_DrawString(G.font, name, 0); + UI_DrawString(x+offset, y-4, name); /* reset offset - for RHS of panel */ offset = 0; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ab042fce41f..b9407d26352 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -55,8 +55,8 @@ #include "ED_image.h" #include "ED_screen.h" +#include "UI_interface.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "WM_api.h" @@ -147,16 +147,13 @@ static void draw_render_info(SpaceImage *sima, ARegion *ar) glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1); UI_ThemeColor(TH_TEXT_HI); - glRasterPos2i(12, rect.ymin + 5); - UI_RasterPos(12, rect.ymin + 5); if(showspare) { - UI_DrawString(G.fonts, "(Previous)", 0); - glRasterPos2i(72, rect.ymin + 5); - UI_RasterPos(72, rect.ymin + 5); + UI_DrawString(12, rect.ymin + 5, "(Previous)"); + UI_DrawString(72, rect.ymin + 5, str); } - - UI_DrawString(G.fonts, str, 0); + else + UI_DrawString(12, rect.ymin + 5, str); } void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) @@ -192,10 +189,8 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f glDisable(GL_BLEND); glColor3ub(255, 255, 255); - glRasterPos2i(10, 10); - UI_RasterPos(10, 10); - UI_DrawString(G.fonts, str, 0); + UI_DrawString(10, 10, str); } /* image drawing */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index bf96d1c38aa..faf6fa8cdd8 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -87,7 +87,6 @@ #include "WM_types.h" #include "UI_view2d.h" -#include "UI_text.h" #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 28deb705b7b..f914dc66abc 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -77,7 +77,6 @@ #include "ED_util.h" #include "ED_types.h" -#include "UI_text.h" #include "UI_interface.h" #include "UI_interface_icons.h" #include "UI_resources.h" @@ -90,12 +89,11 @@ // XXX interface.h extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); -extern void ui_rasterpos_safe(float x, float y, float aspect); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); extern void ui_draw_tria_icon(float x, float y, float aspect, char dir); -static void snode_drawstring(void *curfont, SpaceNode *snode, char *str, int okwidth) +static void snode_drawstring(SpaceNode *snode, int x, int y, char *str, int okwidth) { char drawstr[NODE_MAXSTR]; int width; @@ -103,7 +101,7 @@ static void snode_drawstring(void *curfont, SpaceNode *snode, char *str, int okw if(str[0]==0 || okwidth<4) return; BLI_strncpy(drawstr, str, NODE_MAXSTR); - width= snode->aspect*UI_GetStringWidth(curfont, drawstr, 0); + width= UI_GetStringWidth(drawstr); if(width > okwidth) { int len= strlen(drawstr)-1; @@ -111,12 +109,12 @@ static void snode_drawstring(void *curfont, SpaceNode *snode, char *str, int okw while(width > okwidth && len>=0) { drawstr[len]= 0; - width= snode->aspect*UI_GetStringWidth(curfont, drawstr, 0); + width= snode->aspect*UI_GetStringWidth(drawstr); len--; } if(len==0) return; } - UI_DrawString(curfont, drawstr, 0); + UI_DrawString(x, y, drawstr); } @@ -730,8 +728,6 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else UI_ThemeColor(TH_TEXT); - ui_rasterpos_safe(rct->xmin+19.0f, rct->ymax-NODE_DY+5.0f, snode->aspect); - if(node->flag & NODE_MUTED) sprintf(showname, "[%s]", node->name); else if(node->username[0]) @@ -739,7 +735,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else BLI_strncpy(showname, node->name, 128); - snode_drawstring(snode->curfont, snode, showname, (int)(iconofs - rct->xmin-18.0f)); + snode_drawstring(snode, rct->xmin+19, rct->ymax-NODE_DY+5, showname, (int)(iconofs - rct->xmin-18.0f)); /* body */ UI_ThemeColor4(TH_NODE); @@ -820,8 +816,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } else { UI_ThemeColor(TH_TEXT); - ui_rasterpos_safe(sock->locx+8.0f, sock->locy-5.0f, snode->aspect); - UI_DrawString(snode->curfont, sock->name, 0); + UI_DrawString(sock->locx+8.0f, sock->locy-5.0f, sock->name); } } } @@ -835,13 +830,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN socket_circle_draw(sock, NODE_SOCKSIZE); UI_ThemeColor(TH_TEXT); - slen= snode->aspect*UI_GetStringWidth(snode->curfont, sock->name, 0); + slen= snode->aspect*UI_GetStringWidth(sock->name); while(slen > node->width) { ofs++; - slen= snode->aspect*UI_GetStringWidth(snode->curfont, sock->name+ofs, 0); + slen= snode->aspect*UI_GetStringWidth(sock->name+ofs); } - ui_rasterpos_safe(sock->locx-8.0f-slen, sock->locy-5.0f, snode->aspect); - UI_DrawString(snode->curfont, sock->name+ofs, 0); + UI_DrawString(sock->locx-8.0f-slen, sock->locy-5.0f, sock->name+ofs); } } @@ -909,7 +903,6 @@ static void node_draw_hidden(View2D *v2d, SpaceNode *snode, bNode *node) UI_ThemeColor(TH_TEXT); if(node->miniwidth>0.0f) { - ui_rasterpos_safe(rct->xmin+21.0f, centy-4.0f, snode->aspect); if(node->flag & NODE_MUTED) sprintf(showname, "[%s]", node->name); @@ -918,7 +911,7 @@ static void node_draw_hidden(View2D *v2d, SpaceNode *snode, bNode *node) else BLI_strncpy(showname, node->name, 128); - snode_drawstring(snode->curfont, snode, showname, (int)(rct->xmax - rct->xmin-18.0f -12.0f)); + snode_drawstring(snode, rct->xmin+21, centy-4, showname, (int)(rct->xmax - rct->xmin-18.0f -12.0f)); } /* scale widget thing */ @@ -1048,7 +1041,6 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - ui_rasterpos_safe(rect.xmin+8.0f, rect.ymax+5.0f, snode->aspect); if(gnode->username[0]) { strcpy(showname,"("); @@ -1059,7 +1051,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN else strcpy(showname, ngroup->id.name+2); - UI_DrawString(snode->curfont, showname, 0); + UI_DrawString(rect.xmin+8.0f, rect.ymax+5.0f, showname); /* links from groupsockets to the internal nodes */ node_draw_group_links(&ar->v2d, snode, gnode); @@ -1096,7 +1088,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* aspect+font, set each time */ snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); - snode->curfont= uiSetCurFont_ext(snode->aspect); + // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); UI_view2d_constant_grid_draw(C, v2d); /* backdrop */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 93297e37d4d..cf195f6d9c9 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -96,7 +96,6 @@ #include "UI_interface_icons.h" #include "UI_resources.h" #include "UI_view2d.h" -#include "UI_text.h" #include "RNA_access.h" @@ -106,10 +105,6 @@ #include "outliner_intern.h" -#ifdef INTERNATIONAL -#include "FTF_Api.h" -#endif - #include "PIL_time.h" @@ -3703,10 +3698,10 @@ static void outliner_draw_tree_element(Scene *scene, ARegion *ar, SpaceOops *soo if(active==1) UI_ThemeColor(TH_TEXT_HI); else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); else UI_ThemeColor(TH_TEXT); - glRasterPos2i(startx+offsx, *starty+5); - UI_RasterPos((float)startx+offsx, (float)*starty+5); - UI_DrawString(G.font, te->name, 0); - offsx+= (int)(OL_X + UI_GetStringWidth(G.font, te->name, 0)); + + UI_DrawString(startx+offsx, *starty+5, te->name); + + offsx+= (int)(OL_X + UI_GetStringWidth(te->name)); /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if(tselem->flag & TSE_CLOSED) { @@ -4240,7 +4235,7 @@ static void outliner_buttons(uiBlock *block, ARegion *ar, SpaceOops *soops, List else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); else len= sizeof(((ID*) 0)->name)-2; - dx= (int)UI_GetStringWidth(G.font, te->name, 0); + dx= (int)UI_GetStringWidth(te->name); if(dx<50) dx= 50; bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", (short)te->xs+2*OL_X-4, (short)te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, ""); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index e0dc54ee377..8e30db584af 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -62,7 +62,6 @@ #include "BIF_glutil.h" #include "UI_interface.h" -#include "UI_text.h" #include "UI_resources.h" #include "UI_view2d.h" diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 63e3bca1ad0..3fbb44baa6c 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -71,7 +71,6 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "UI_text.h" #include "UI_view2d.h" #include "RNA_access.h" diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 9dca9350754..5623e538eb4 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -48,7 +48,7 @@ #include "ED_sculpt.h" #include "ED_util.h" -#include "UI_text.h" +#include "UI_interface.h" /* ********* general editor util funcs, not BKE stuff please! ********* */ @@ -115,7 +115,7 @@ int GetButStringLength(char *str) { int rt; - rt= UI_GetStringWidth(G.font, str, (U.transopts & USER_TR_BUTTONS)); + rt= UI_GetStringWidth(str); return rt + 15; } diff --git a/source/blender/ftfont/CMakeLists.txt b/source/blender/ftfont/CMakeLists.txt deleted file mode 100644 index 134796d0799..00000000000 --- a/source/blender/ftfont/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# $Id$ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -FILE(GLOB SRC intern/*.cpp) - -SET(INC - . intern ../blenkernel ../blenlib ../makesdna ../include - ${FTGL_INC} - ${FREETYPE_INC} - ${GETTEXT_INC} -) - -ADD_DEFINITIONS(-DFTGL_LIBRARY_STATIC) - -IF(WIN32) - ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL) -ENDIF(WIN32) - -BLENDERLIB(bf_ftfont "${SRC}" "${INC}") -#env.BlenderLib ( 'bf_ftfont', sources, Split(incs), Split(defs), libtype=['international','player'], priority=[0, 205] ) diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h deleted file mode 100644 index 8b04f5c09c1..00000000000 --- a/source/blender/ftfont/FTF_Api.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef _FTF_API_H -#define _FTF_API_H - -#define FTF_EXPORT - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include "FTF_Settings.h" - -/** - * Set Font Size - * @param int size - */ -FTF_EXPORT void FTF_SetSize(int size); - -/** - * Get Font Size - * @return Font size - */ -FTF_EXPORT int FTF_GetSize(void); - -/** - * Ascender - * @return Ascend size - */ -FTF_EXPORT int FTF_Ascender(void); - -/** - * Descender - * @return Descend size - */ -FTF_EXPORT int FTF_Descender(void); - -/** - * String Translation and Code Conversion - * @param str source string - * @param ustr distnation string - * @param flag mode flag - */ -FTF_EXPORT void FTF_TransConvString(char* str, char* ustr, unsigned int flag); - -/** - * Draw a character at the current raster position. - * @param c the character to draw - * @param mode flag to forward to FTF_TransConvString() - * @return Width drawing - */ -//FTF_EXPORT float FTF_DrawCharacter(char c, unsigned int flag); - -/** - * Draws a string at the current raster postion. - * @param str The string to draw - * @param mode flag to forward to FTF_TransConvString() - * @return Width drawing - */ -FTF_EXPORT float FTF_DrawString(char* str, unsigned int flag); - - -/** - * Get a character width - * @param mode flag to forward to FTF_TransConvString() - */ -FTF_EXPORT float FTF_GetCharacterWidth(char c, unsigned int flag); - - -/** - * Get a string width - * @param mode flag to forward to FTF_TransConvString() - */ -FTF_EXPORT float FTF_GetStringWidth(char* str, unsigned int flag); - -/** - * Get Bounding Box - * @param llx Lower left near x coord - * @param lly Lower left near y coord - * @param llz Lower left near z coord - * @param urx Upper right far x coord - * @param ury Upper right far y coord - * @param urz Upper right far z coord - * @param mode flag to forward to FTF_TransConvString() - * not test yet. - */ -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, ton - */ - -/** - * SetFontSize - * @param size - */ -FTF_EXPORT void FTF_SetFontSize(char size); - -/** - * SetFont - * @param str - * @param size - */ -FTF_EXPORT int FTF_SetFont(const unsigned char* str, int datasize, int fontsize); - -/** - * SetLanguage - * @param str - * not test yet. - */ -FTF_EXPORT void FTF_SetLanguage(char* str); - -/** - * SetLanguage - * @param str - * not tested yet. - */ -FTF_EXPORT void FTF_SetEncoding(char* str); - -FTF_EXPORT void FTF_SetPosition(float x, float y); -FTF_EXPORT void FTF_SetMode(int mode); -FTF_EXPORT void FTF_SetScale(float fsize); - -FTF_EXPORT void FTF_End(void); - -/* Font preview functions */ -FTF_EXPORT int FTF_GetNewFont (const unsigned char *str, int datasize, int fontsize); -FTF_EXPORT float FTF_DrawNewFontString(char* str, unsigned int flag); - -#ifdef __cplusplus -} -#endif - -#endif /* __FTF_API_H */ - diff --git a/source/blender/ftfont/FTF_Settings.h b/source/blender/ftfont/FTF_Settings.h deleted file mode 100644 index ff9d78e3f58..00000000000 --- a/source/blender/ftfont/FTF_Settings.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) 2002 Blender Foundation. All Rights Reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - - * $Id$ - * Copyright (C) 2001 NaN Technologies B.V. - * Allows you to determine which fonts to include in the library. - */ - -#ifndef __FTF_SETTINGS_H -#define __FTF_SETTINGS_H - -#define FTF_BIT(num) ((unsigned int)1 << (num)) -#define FTF_NO_TRANSCONV 0 -#define FTF_INPUT_SYSTEM_ENCODING FTF_BIT(1) -#define FTF_USE_GETTEXT FTF_BIT(2) -#define FTF_INPUT_UTF8 FTF_BIT(3) -#define FTF_PIXMAPFONT 0 -#define FTF_TEXTUREFONT 1 - -#endif /* __FTF_SETTINGS_H */ diff --git a/source/blender/ftfont/Makefile b/source/blender/ftfont/Makefile deleted file mode 100644 index 73f75e77e73..00000000000 --- a/source/blender/ftfont/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# Bounces make to subdirectories. - -SOURCEDIR = source/blender/ftfont -DIRS = intern - -include nan_subdirs.mk diff --git a/source/blender/ftfont/SConscript b/source/blender/ftfont/SConscript deleted file mode 100644 index 9d475152194..00000000000 --- a/source/blender/ftfont/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python -import sys -Import ('env') - -sources = env.Glob('intern/*.cpp') - -incs = '. intern ../blenkernel ../blenlib ../makesdna ../editors/include' -incs += ' ' + env['BF_FTGL_INC'] -incs += ' ' + env['BF_FREETYPE_INC'] -incs += ' ' + env['BF_GETTEXT_INC'] - -defs = 'FTGL_STATIC_LIBRARY' -if sys.platform == 'win32': - defs += ' _WIN32 USE_GETTEXT_DLL' - -env.BlenderLib ( 'bf_ftfont', sources, Split(incs), Split(defs), libtype=['core'], priority=[210] ) diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp deleted file mode 100644 index 702d054e71c..00000000000 --- a/source/blender/ftfont/intern/FTF_Api.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) 2002 Blender Foundation. All Rights Reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - - * $Id$ - * Copyright (C) 2001 NaN Technologies B.V. - * - * Implementation of the API of FTGL library. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "../FTF_Api.h" -#include "FTF_TTFont.h" - -#ifdef __cplusplus -extern "C" { -#endif -//XXX #include "datatoc.h" -#ifdef __cplusplus -} -#endif - -#define FTF_EXPORT - -FTF_TTFont *newfont= 0; // preview font - -static FTF_TTFont *_FTF_GetFont(void) { - static FTF_TTFont *theFont = NULL; - - if (!theFont) { - theFont = new FTF_TTFont(); - } - - return theFont; -} - -FTF_EXPORT int FTF_GetNewFont (const unsigned char *str, int datasize, int fontsize) { - - if (newfont) delete newfont; - newfont= new FTF_TTFont(); - - if (!(newfont->SetFont((unsigned char*)str, datasize, fontsize))) { - //XXX newfont->SetFont((unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size, fontsize); - return 0; - } - return 1; -} - -FTF_EXPORT float FTF_DrawNewFontString(char* str, unsigned int flag) -{ - if (newfont) - return newfont->DrawString(str, flag); - return 0.0f; -} - -FTF_EXPORT void FTF_End(void) { - delete _FTF_GetFont(); - delete newfont; -} - -FTF_EXPORT void FTF_SetSize(int size) -{ - _FTF_GetFont()->SetSize(size); -} - -FTF_EXPORT int FTF_GetSize(void) -{ - return _FTF_GetFont()->GetSize(); -} - -/* -FTF_EXPORT int FTF_Ascender(void) -{ - return _FTF_GetFont()->Ascender(); -} - -FTF_EXPORT int FTF_Descender(void) -{ - return _FTF_GetFont()->Descender(); -} -*/ - -FTF_EXPORT void FTF_TransConvString(char* str, char* ustr, unsigned int flag) -{ - _FTF_GetFont()->TransConvString(str, ustr, flag); -} - -/* -FTF_EXPORT float FTF_DrawCharacter(char c, unsigned int flag) -{ - char str[2] = {c, '\0'}; - return FTF_DrawString(str, flag); -} -*/ - - -/* does color too, using glGet */ -FTF_EXPORT float FTF_DrawString(char* str, unsigned int flag) -{ - return _FTF_GetFont()->DrawString(str, flag); -} - - -/** - * not implemente yet. - */ -FTF_EXPORT float FTF_GetCharacterWidth(char c, unsigned int flag) -{ - char str[2] = {c, '\0'}; - return FTF_GetStringWidth(str, flag); -} - - -/** - * not implemente yet. - */ -FTF_EXPORT float FTF_GetStringWidth(char* str, unsigned int flag) -{ - return _FTF_GetFont()->GetStringWidth(str, flag); -} - - -/** - * not implemente yet. - * ## This return string box!! ## - */ -FTF_EXPORT void FTF_GetBoundingBox(char* str, float *llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag) -{ - _FTF_GetFont()->GetBoundingBox(str, llx, lly, llz, urx, ury, urz, flag); -} - -/** - * added by phase - * changed by ton; to allow both file load as memory load (datasize!=0) - */ -FTF_EXPORT int FTF_SetFont(const unsigned char* str, int datasize, int fontsize) -{ - return _FTF_GetFont()->SetFont(str, datasize, fontsize); -} - -/* added by ton */ - -FTF_EXPORT void FTF_SetFontSize(char size) -{ - _FTF_GetFont()->SetFontSize( size); -} - -/** - * added by phase - * - */ -FTF_EXPORT void FTF_SetLanguage(char* str) -{ - _FTF_GetFont()->SetLanguage(str); -} - -FTF_EXPORT void FTF_SetEncoding(char* str) -{ - _FTF_GetFont()->SetEncoding(str); -} - -FTF_EXPORT void FTF_SetPosition(float x, float y) -{ - _FTF_GetFont()->SetPosition(x, y); -} - -FTF_EXPORT void FTF_SetMode(int mode) -{ - _FTF_GetFont()->SetMode(mode); -} - -FTF_EXPORT void FTF_SetScale(float fsize) -{ - _FTF_GetFont()->SetScale(fsize); -} - - diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp deleted file mode 100644 index e8f2b82f970..00000000000 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) 2002 Blender Foundation. All Rights Reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <locale.h> -#include "libintl.h" -#include "BLI_blenlib.h" -#include "BKE_font.h" - -#include "../FTF_Settings.h" - -#include "FTF_TTFont.h" - -#ifdef __APPLE__ -#include "BKE_utildefines.h" -#endif - -#define DOMAIN_NAME "blender" - -#define SYSTEM_ENCODING_DEFAULT "UTF-8" -#define FONT_SIZE_DEFAULT 12 -//#define FONT_PATH_DEFAULT ".bfont.ttf" - -#define FTF_MAX_STR_SIZE 512 - -FTF_TTFont::FTF_TTFont(void) -{ -#ifdef __APPLE__ - char *bundlepath; -#endif - - font=NULL; - fontm= fonts= fontl= NULL; - font_size=FONT_SIZE_DEFAULT; - mode = FTF_PIXMAPFONT; - fsize = 1.0; - strcpy(encoding_name, SYSTEM_ENCODING_DEFAULT); - - //set messagepath directory - -#ifndef LOCALEDIR -#define LOCALEDIR "/usr/share/locale" -#endif - - strcpy(messagepath, ".blender/locale"); - - if ( !BLI_exist(messagepath) ) { // locale not in current dir - BLI_make_file_string("/", messagepath, BLI_gethome(), ".blender/locale"); - - if( !BLI_exist(messagepath) ) { // locale not in home dir - -#ifdef WIN32 - BLI_make_file_string("/", messagepath, BLI_gethome(), "/locale"); - if( !BLI_exist(messagepath) ) { -#endif -#ifdef __APPLE__ - /* message catalogs are stored inside the application bundle */ - bundlepath = BLI_getbundle(); - strcpy(messagepath, bundlepath); - strcat(messagepath, "/Contents/Resources/locale"); - if( !BLI_exist(messagepath) ) { // locale not in bundle (now that's odd..) -#endif - strcpy(messagepath, LOCALEDIR); - - if( !BLI_exist(messagepath) ) { // locale not in LOCALEDIR - strcpy(messagepath, "message"); // old compatibility as last - } -#ifdef WIN32 - } -#endif -#ifdef __APPLE__ - } -#endif - } - } -} - - -FTF_TTFont::~FTF_TTFont(void) -{ - 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(const unsigned char* str, int datasize, int fontsize) -{ - int err = 0; - bool success = 0; - - if (fonts) delete fonts; - if (fontm) delete fontm; - if (fontl) delete fontl; - fonts= NULL; - fontm= NULL; - fontl= NULL; - - if(mode == FTF_PIXMAPFONT) { - - if(datasize) font = new FTGLPixmapFont(str, datasize); - else font = new FTGLPixmapFont( (char *)str); - - err = font->Error(); - - if(err) { - printf("Failed to open font %s\n", str); - return 0; - } else { - - fontm= font; - - if(datasize) fonts = new FTGLPixmapFont(str, datasize); - else fonts = new FTGLPixmapFont((char *)str); - if(datasize) fontl = new FTGLPixmapFont(str, datasize); - else fontl = new FTGLPixmapFont((char *)str); - - success = fonts->FaceSize(fontsize-2<8?8:fontsize-2); - success = fontm->FaceSize(fontsize-1<8?8:fontsize-1); - success = fontl->FaceSize(fontsize); - if(!success) return 0; - - success = fonts->CharMap(ft_encoding_unicode); - success = fontm->CharMap(ft_encoding_unicode); - success = fontl->CharMap(ft_encoding_unicode); - if(!success) return 0; - - return 1; - } - - } else if(mode == FTF_TEXTUREFONT) { - - if(datasize) font = new FTGLTextureFont(str, datasize); - else font = new FTGLTextureFont( (char *)str); - - err = font->Error(); - - if(err) { - printf("Failed to open font %s\n", str); - return 0; - } else { - - fontm= font; - - if(datasize) fonts = new FTGLTextureFont(str, datasize); - else fonts = new FTGLTextureFont((char *)str); - if(datasize) fontl = new FTGLTextureFont(str, datasize); - else fontl = new FTGLTextureFont((char *)str); - - success = fonts->FaceSize(fontsize-2<8?8:fontsize-2); - success = fontm->FaceSize(fontsize-1<8?8:fontsize-1); - success = fontl->FaceSize(fontsize); -// success = fonts->FaceSize(fontsize/2); -// success = fontm->FaceSize(fontsize); -// success = fontl->FaceSize(fontsize*2); - if(!success) return 0; - - success = fonts->CharMap(ft_encoding_unicode); - success = fontm->CharMap(ft_encoding_unicode); - success = fontl->CharMap(ft_encoding_unicode); - if(!success) return 0; - - return 1; - } - } - return 0; -} - -void FTF_TTFont::SetLanguage(char* str) -{ - -#if defined (_WIN32) || defined(__APPLE__) - char envstr[12]; - - sprintf(envstr, "LANG=%s", str); - envstr[strlen(envstr)]='\0'; -#ifdef _WIN32 - gettext_putenv(envstr); -#else - putenv(envstr); -#endif -#else - char *locreturn = setlocale(LC_ALL, str); - if (locreturn == NULL) { - char *lang; - - lang = (char*)malloc(sizeof(char)*(strlen(str)+7)); - - lang[0] = '\0'; - strcat(lang, str); - strcat(lang, ".UTF-8"); - - locreturn = setlocale(LC_ALL, lang); - if (locreturn == NULL) { - printf("could not change language to %s nor %s\n", str, lang); - } - - free(lang); - } - - setlocale(LC_NUMERIC, "C"); -#endif - - - bindtextdomain(DOMAIN_NAME, messagepath); -// bind_textdomain_codeset(DOMAIN_NAME, encoding_name); - textdomain(DOMAIN_NAME); - - strcpy(language, str); -} - - -void FTF_TTFont::SetEncoding(char* str) -{ - strcpy(encoding_name, str); -// bind_textdomain_codeset(DOMAIN_NAME, encoding_name); -} - - -void FTF_TTFont::SetSize(int size) -{ - fonts->FaceSize(size-2<8?8:size-2); - fontm->FaceSize(size-1<8?8:size-1); - fontl->FaceSize(size); - - font_size = size; -} - -int FTF_TTFont::GetSize(void) -{ - return font_size; -} - -/* -int FTF_TTFont::Ascender(void) -{ - return (int)font->Ascender(); -} - -int FTF_TTFont::Descender(void) -{ - return (int)font->Descender(); -} - -*/ -int FTF_TTFont::TransConvString(char* str, char* ustr, unsigned int flag) -{ - return 0; -} - - -float FTF_TTFont::DrawString(char* str, unsigned int flag) -{ - float color[4]; - wchar_t wstr[FTF_MAX_STR_SIZE-1]={'\0'}; - - /* note; this utf8towchar() function I totally don't understand... without using translations it - removes special characters completely. So, for now we just skip that then. (ton) */ - if (FTF_USE_GETTEXT & flag) - utf8towchar(wstr, gettext(str)); - else if (FTF_INPUT_UTF8 & flag) - utf8towchar(wstr, str); - - glGetFloatv(GL_CURRENT_COLOR, color); - - if(mode == FTF_PIXMAPFONT) { - - glPixelTransferf(GL_RED_SCALE, color[0]); - glPixelTransferf(GL_GREEN_SCALE, color[1]); - glPixelTransferf(GL_BLUE_SCALE, color[2]); - - if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag) - font->Render(wstr); - else - font->Render(str); - - glPixelTransferf(GL_RED_SCALE, 1.0); - glPixelTransferf(GL_GREEN_SCALE, 1.0); - glPixelTransferf(GL_BLUE_SCALE, 1.0); - - } else if(mode == FTF_TEXTUREFONT) { - - glEnable(GL_BLEND); - glEnable(GL_TEXTURE_2D); - - glPushMatrix(); - glTranslatef(pen_x, pen_y, 0.0); - glScalef(fsize, fsize, 1.0); - - if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag) - font->Render(wstr); - else - font->Render(str); - - glPopMatrix(); - - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - } - - if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag) - return font->Advance(wstr); - else - return font->Advance(str); -} - - -float FTF_TTFont::GetStringWidth(char* str, unsigned int flag) -{ - wchar_t wstr[FTF_MAX_STR_SIZE-1]={'\0'}; - int len=0; - - if (strlen(str)==0) return 0.0; - - /* note; this utf8towchar() function I totally don't understand... without using translations it - removes special characters completely. So, for now we just skip that then. (ton) */ - - if (FTF_USE_GETTEXT & flag) { - len=utf8towchar(wstr, gettext(str)); - - if(mode == FTF_PIXMAPFONT) { - return font->Advance(wstr); - } else if(mode == FTF_TEXTUREFONT) { - return font->Advance(wstr);// * fsize; - } - } - else { - if(mode == FTF_PIXMAPFONT) { - return font->Advance(str); - } else if(mode == FTF_TEXTUREFONT) { - return font->Advance(str);// * fsize; - } - } - - return 0.0; -} - - -void FTF_TTFont::GetBoundingBox(char* str, float *llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag) -{ - wchar_t wstr[FTF_MAX_STR_SIZE-1]={'\0'}; - int len=0; - - if (FTF_USE_GETTEXT & flag) - len=utf8towchar(wstr,gettext(str)); - else - len=utf8towchar(wstr,str); - - font->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz); -} - - -void FTF_TTFont::SetPosition(float x, float y) -{ - pen_x = x; - pen_y = y; -} - - -void FTF_TTFont::SetMode(int m) -{ - mode = m; -} - - -void FTF_TTFont::SetScale(float size) -{ - fsize = size; -} - - diff --git a/source/blender/ftfont/intern/FTF_TTFont.h b/source/blender/ftfont/intern/FTF_TTFont.h deleted file mode 100644 index 51247a2d2a1..00000000000 --- a/source/blender/ftfont/intern/FTF_TTFont.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) 2002 Blender Foundation. All Rights Reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - - * $Id$ - * Copyright (C) 2001 NaN Technologies B.V. - */ - -#ifndef __FTF_TRUETYPE_FONT_H -#define __FTF_TRUETYPE_FONT_H - -#include "FTGLPixmapFont.h" -#include "FTGLTextureFont.h" - -#include <stdio.h> -//#include <iconv.h> - - -/** - * Base class for Using FTGL, iconv and gettext Library. - */ -class FTF_TTFont -{ -public: - /** - * Default constructor. - */ - FTF_TTFont(void); - - /** - * Destructor. - */ - virtual ~FTF_TTFont(void); - - - void SetSize(int size); - int GetSize(void); - -// int Ascender(void); -// int Descender(void); - - int TransConvString(char* str, char* ustr, unsigned int flag); - - /** - * Draws a string at the current raster position in current opengl color. - * @param str The string to draw. - * @param flag Whether use gettext and UTF8 or system encoding. - */ - float DrawString(char* str, unsigned int flag); - - float GetStringWidth(char* str, unsigned int flag); - - /** - * Get the bounding box for a string. - * - * @param str The string - * @param llx Lower left near x coord - * @param lly Lower left near y coord - * @param llz Lower left near z coord - * @param urx Upper right far x coord - * @param ury Upper right far y coord - * @param urz Upper right far z coord - */ - void GetBoundingBox(char* str, float *llx, float *lly, float *llz, float *urx, float *ury, float *urz, unsigned int flag); - - /** - * added by phase, ton - * functions to communicate with the preference menu - */ - void SetFontSize(char size); - - int SetFont(const unsigned char* str, int datasize, int fontsize); - - void SetLanguage(char* str); - - void SetEncoding(char* str); - - /** - * functions to communicate with blender ui rasterpos - */ - void SetPosition(float x, float y); - void SetMode(int mode); - void SetScale(float fsize); - -protected: - char messagepath[1024]; - - char language[32]; - char encoding_name[32]; - char font_name[128]; - int font_size; - - int mode; // 0 = pixmap, 1 = texture - float pen_x, pen_y; //rasterpos - float fsize; - - /** FTGL's */ - FTFont* font; /* active */ - - FTFont* fonts; /* opened, small medium and large */ - FTFont* fontm; - FTFont* fontl; - - /** from system encoding in .locale to UNICODE */ -// iconv_t cd; - - /** from UTF-8 to UNICODE */ -// iconv_t ucd; -}; - -#endif // __FTF_TRUETYPE_FONT_H diff --git a/source/blender/ftfont/intern/Makefile b/source/blender/ftfont/intern/Makefile deleted file mode 100644 index 6e145ee442e..00000000000 --- a/source/blender/ftfont/intern/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# - -LIBNAME = ftfont -DIR = $(OCGDIR)/blender/ftfont - -include nan_compile.mk - -CFLAGS += $(LEVEL_1_C_WARNINGS) - -#CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -CPPFLAGS += -I../../makesdna -CPPFLAGS += -I../../blenkernel -CPPFLAGS += -I../../blenlib -CPPFLAGS += -I../../editors/include -CPPFLAGS += -I$(NAN_FTGL)/include -CPPFLAGS += -I$(NAN_FTGL)/include/FTGL -CPPFLAGS += -I$(NAN_GETTEXT)/include -CPPFLAGS += -I$(NAN_FREETYPE)/include -ifeq ($(OS), windows) - CPPFLAGS += -I$(NAN_ICONV)/include - ifeq ($(FREE_WINDOWS), true) - CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2 - CPPFLAGS += -DUSE_GETTEXT_DLL - endif -else - CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2 -endif -CPPFLAGS += -I.. diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1fa184e74a4..64d61210c14 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -55,9 +55,6 @@ #include "BKE_packedFile.h" #include "BMF_Api.h" -#ifdef INTERNATIONAL -#include "FTF_Api.h" -#endif #include "BLI_blenlib.h" @@ -256,10 +253,6 @@ void WM_exit(bContext *C) // XXX UI_filelist_free_icons(); } -#ifdef INTERNATIONAL - FTF_End(); -#endif - GPU_extensions_exit(); // if (copybuf) MEM_freeN(copybuf); |