X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcwindowdraw.C;h=6a8412dedc0c06c6a5afcdbdfc19b1fc02ae8ced;hb=b55798fc64eee00c6fab3b4763e791befb7275f9;hp=61865c50e19a576702f1d0b11bb536c7e7e2f697;hpb=4c1a91d9f9373e564ecbeb8f568e4a3e7fe48e64;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index 61865c50..6a8412de 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -28,7 +28,7 @@ #include "bctimer.h" #include "bcwindowbase.h" #include "clip.h" -#include "colors.h" +#include "bccolors.h" #include "cursors.h" #include "fonts.h" #include "vframe.h" @@ -232,15 +232,16 @@ void BC_WindowBase::draw_xft_text(int x, int y, { int dy = -1; const wchar_t *wsp = text, *wep = wsp + length; + int font = top_level->current_font; while( wsp < wep ) { const wchar_t *wcp = wsp; while( wcp < wep && *wcp != '\n' ) ++wcp; int len = wcp - wsp; if( len > 0 ) - draw_wtext(x, y, wsp, len, pixmap); + draw_single_text(1, font, x, y, wsp, len, pixmap); if( wcp >= wep ) break; if( dy < 0 ) - dy = get_text_height(top_level->current_font); + dy = get_text_height(font); y += dy; wsp = wcp + 1; } @@ -280,112 +281,111 @@ void BC_WindowBase::xft_draw_string(XftColor *xft_color, XftFont *xft_font, } } -void BC_WindowBase::draw_wtext(int x, int y, - const wchar_t *text, int length, BC_Pixmap *pixmap) +int BC_WindowBase::get_single_text_width(int font, const wchar_t *text, int length) { + return draw_single_text(0, font, 0,0, text, length); +} + +int BC_WindowBase::draw_single_text(int draw, int font, + int x, int y, const wchar_t *text, int length, BC_Pixmap *pixmap) +{ + if( length < 0 ) + length = wcslen(text); + if( !length ) return 0; + if( !get_resources()->use_xft ) { - if( !get_font_struct(current_font) ) return; + if( !get_font_struct(font) ) return 0; XChar2b xtext[length], *xp = xtext; for( int i=0; ibyte1 = (unsigned char) (text[i] >> 8); xp->byte2 = (unsigned char) (text[i] & 0xff); } - XDrawString16(top_level->display, - pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, x, y, xtext, length); - return; + if( draw ) { + XDrawString16(top_level->display, + pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, + top_level->gc, x, y, xtext, length); + } + return XTextWidth16(get_font_struct(font), xtext, length); } - XRenderColor color; - XftColor xft_color; - const wchar_t *up, *ubp; - int l; - FcPattern *newpat; - XftFont *curfont, *nextfont, *altfont, *basefont; - if(length < 0) - length = wcslen(text); - - if(!length) - return; - - color.red = (top_level->current_color & 0xff0000) >> 16; - color.red |= color.red << 8; - color.green = (top_level->current_color & 0xff00) >> 8; - color.green |= color.green << 8; - color.blue = (top_level->current_color & 0xff); - color.blue |= color.blue << 8; - color.alpha = 0xffff; - - XftColorAllocValue(top_level->display, - top_level->vis, - top_level->cmap, - &color, - &xft_color); - - basefont = top_level->get_xft_struct(top_level->current_font); - - curfont = nextfont = basefont; - altfont = 0; - ubp = text; - - for(up = text; up < &text[length]; up++) - { - if(XftCharExists(top_level->display, basefont, *up)) - nextfont = basefont; - else if(altfont && XftCharExists(top_level->display, altfont, *up)) - nextfont = altfont; - else - { - if(altfont) +#ifdef HAVE_XFT + XftColor xft_color; + if( draw ) { + XRenderColor color; + color.red = (top_level->current_color & 0xff0000) >> 16; + color.red |= color.red << 8; + color.green = (top_level->current_color & 0xff00) >> 8; + color.green |= color.green << 8; + color.blue = (top_level->current_color & 0xff); + color.blue |= color.blue << 8; + color.alpha = 0xffff; + + XftColorAllocValue(top_level->display, top_level->vis, top_level->cmap, + &color, &xft_color); + } + + int x0 = x; + XftFont *basefont = top_level->get_xft_struct(font); + XftFont *curfont = 0, *altfont = 0; + const wchar_t *up = text, *ubp = up, *uep = ubp + length; + + while( up < uep ) { + XftFont *xft_font = 0; + if( XftCharExists(top_level->display, basefont, *up) ) + xft_font = basefont; + else if( altfont ) { + if( XftCharExists(top_level->display, altfont, *up)) + xft_font = altfont; + else { XftFontClose(top_level->display, altfont); - - if( (newpat = BC_Resources::find_similar_font(*up, basefont->pattern)) != 0 ) { - double psize; - - FcPatternGetDouble(basefont->pattern, FC_PIXEL_SIZE, - 0, &psize); - FcPatternAddDouble(newpat, FC_PIXEL_SIZE, psize); - FcPatternDel(newpat, FC_SCALABLE); - altfont = XftFontOpenPattern(top_level->display, - newpat); - if(altfont) - nextfont = altfont; - } - else - { altfont = 0; - nextfont = basefont; } } - if(nextfont != curfont) - { - l = up - ubp; - xft_draw_string(&xft_color, curfont, x, y, - (const FcChar32*)ubp, l, pixmap); - - XGlyphInfo extents; - XftTextExtents32(top_level->display, curfont, - (const FcChar32*)ubp, l, &extents); - x += extents.xOff; - - ubp = up; - curfont = nextfont; + if( !xft_font ) { + FcPattern *pattern = BC_Resources::find_similar_font(*up, basefont->pattern); + if( pattern != 0 ) { + double psize = 0; + FcPatternGetDouble(basefont->pattern, FC_PIXEL_SIZE, 0, &psize); + FcPatternAddDouble(pattern, FC_PIXEL_SIZE, psize); + FcPatternDel(pattern, FC_SCALABLE); + xft_font = altfont = XftFontOpenPattern(top_level->display, pattern); + } + } + if( !xft_font ) + xft_font = basefont; + if( xft_font != curfont ) { + if( curfont && up > ubp ) { + if( draw ) { + xft_draw_string(&xft_color, curfont, x, y, + (const FcChar32*)ubp, up-ubp, pixmap); + } + XGlyphInfo extents; + XftTextExtents32(top_level->display, curfont, + (const FcChar32*)ubp, up-ubp, &extents); + x += extents.xOff; + } + ubp = up; curfont = xft_font; } + ++up; } - if(up > ubp) - { - xft_draw_string(&xft_color, curfont, x, y, - (const FcChar32*)ubp, up - ubp, pixmap); + if( curfont && up > ubp ) { + if( draw ) { + xft_draw_string(&xft_color, curfont, x, y, + (const FcChar32*)ubp, up-ubp, pixmap); + } + XGlyphInfo extents; + XftTextExtents32(top_level->display, curfont, + (const FcChar32*)ubp, up-ubp, &extents); + x += extents.xOff; } - if(altfont) + if( altfont ) XftFontClose(top_level->display, altfont); - XftColorFree(top_level->display, - top_level->vis, - top_level->cmap, - &xft_color); + XftColorFree(top_level->display, top_level->vis, top_level->cmap, &xft_color); +#endif + return x - x0; } void BC_WindowBase::truncate_text(char *result, const char *text, int w) @@ -947,7 +947,7 @@ void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, // Hide cursor if video enabled update_video_cursor(); -//printf("BC_WindowBase::draw_bitmap 1\n"); +//printf("BC_WindowBase::draw_bitmap %d dest_y=%d\n", __LINE__, dest_y); if(dest_w <= 0 || dest_h <= 0) { // Use hardware scaling to canvas dimensions if proper color model.