X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Ftitler%2Ftitler.C;h=940462b144ee0363fb52b02da52258b6a90d7c22;hb=0e00daab15d8b871ec7f76c2713b75d5f3fb237d;hp=dde50aa37bc9a0b7c98f572d31891a831d69059d;hpb=3badd817d6f012b5e882940db0c5d7e61cec15d7;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C index dde50aa3..940462b1 100644 --- a/cinelerra-5.1/plugins/titler/titler.C +++ b/cinelerra-5.1/plugins/titler/titler.C @@ -25,7 +25,6 @@ // Additional support for UTF-8 by // Paolo Rampino aka Akirad - #include "asset.h" #include "bccmodels.h" #include "bcsignals.h" @@ -91,7 +90,7 @@ TitleConfig::TitleConfig() outline_color = WHITE; outline_alpha = 0xff; color_stroke = 0xff0000; - stroke_width = 1.0; + stroke_width = 0.0; motion_strategy = NO_MOTION; line_pitch = 0; loop = 0; @@ -294,6 +293,10 @@ void GlyphUnit::process_package(LoadPackage *package) { GlyphPackage *pkg = (GlyphPackage*)package; TitleGlyph *glyph = pkg->glyph; + BC_Resources *resources = BC_WindowBase::get_resources(); + if( resources->font_debug ) + printf("GlyphUnit load glyph (%s) %04x, '%c'\n", glyph->font->displayname, + (unsigned)glyph->char_code, (unsigned)glyph->char_code); int result = 0; char new_path[BCTEXTLEN]; if( plugin->load_freetype_face(freetype_library, freetype_face, glyph->font->path) ) { @@ -311,7 +314,6 @@ void GlyphUnit::process_package(LoadPackage *package) if( gindex == 0 ) { printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n", glyph->font->displayname, (unsigned)glyph->char_code, (unsigned)glyph->char_code); - BC_Resources *resources = BC_WindowBase::get_resources(); // Search replacement font if( resources->find_font_by_char(glyph->char_code, new_path, freetype_face) ) { plugin->load_freetype_face(freetype_library, @@ -541,7 +543,7 @@ TitleUnit::TitleUnit(TitleMain *plugin, TitleEngine *server) static void get_mask_colors(int rgb, int color_model, int &rr, int &gg, int &bb) { int r = 0xff & (rgb>>16), g = 0xff & (rgb>>8), b = 0xff & (rgb>>0); - if( BC_CModels::is_yuv(color_model) ) bc_rgb2yuv(r,g,b, r,g,b); + if( BC_CModels::is_yuv(color_model) ) YUV::yuv.rgb_to_yuv_8(r,g,b); rr = r; gg = g; bb = b; } @@ -1142,7 +1144,7 @@ TitleMain::~TitleMain() delete outline_engine; } -const char* TitleMain::plugin_title() { return _("Title"); } +const char* TitleMain::plugin_title() { return N_("Title"); } int TitleMain::is_realtime() { return 1; } int TitleMain::is_synthesis() { return 1; } @@ -1151,7 +1153,8 @@ NEW_WINDOW_MACRO(TitleMain, TitleWindow); void TitleMain::build_previews(TitleWindow *gui) { - ArrayList&fonts = *gui->get_resources()->fontlist; + BC_Resources *resources = BC_WindowBase::get_resources(); + ArrayList&fonts = *resources->fontlist; for( int font_number=0; font_numberget_text_height(LARGEFONT); int max_height = 3*text_height/2, max_width = 2 * max_height; - int text_color = BC_WindowBase::get_resources()->default_text_color; + int text_color = resources->default_text_color; int r = (text_color >> 16) & 0xff; int g = (text_color >> 8) & 0xff; int b = text_color & 0xff; @@ -1179,6 +1182,8 @@ void TitleMain::build_previews(TitleWindow *gui) int total_w = 0; int total_h = 0; for( int pass=0; pass<2; ++pass ) { + if( resources->font_debug ) + printf("Titler: build previews pass %d\n",pass); //printf("TitleMain::build_previews %d %d %d\n", //__LINE__, text_height, total_h); for( int font_number=0; font_numberdisplayname, font->displayname) ) { if( pass == 1 ) { - font->image = fonts[i]->image; + font->image = new VFrame(*fonts[i]->image); } skip = 1; break; @@ -1196,6 +1201,8 @@ void TitleMain::build_previews(TitleWindow *gui) } if( skip ) continue; + if( resources->font_debug ) + printf("Titler: preview %s = %s\n",font->displayname, font->path); if( pass > 0 ) { font->image = new VFrame; font->image->set_use_shm(0); @@ -1353,7 +1360,7 @@ int TitleMain::load_freetype_face(FT_Library &freetype_library, int TitleMain::load_font(BC_FontEntry *font) { - if( load_freetype_face(freetype_library,freetype_face, font->path) ) return 1; + if( !font || load_freetype_face(freetype_library,freetype_face, font->path) ) return 1; strcpy(text_font, font->displayname); return 0; } @@ -1457,7 +1464,7 @@ void TitleMain::draw_background() delete bg_frame; bg_frame = 0; } if( !bg_frame ) - bg_frame = new VFrame(0, -1, bw, bh, output_model, -1); + bg_frame = new VFrame(bw, bh, output_model); int64_t position = get_source_position() - get_source_start(); if( !read_background(bg_frame, position, output_model) ) { if( !overlay_frame ) @@ -1600,7 +1607,8 @@ VFrame *TitleMain::add_image(const char *path) VFrame *vframe = get_image(path); if( !vframe && (vframe=VFramePng::vframe_png(path)) != 0 ) { if( vframe->get_color_model() != text_model ) { - VFrame *frame = new VFrame(vframe->get_w(), vframe->get_h(), text_model); + VFrame *frame = new VFrame(vframe->get_w(), vframe->get_h(), + text_model, 0); frame->transfer_from(vframe); delete vframe; vframe = frame; } @@ -2329,7 +2337,8 @@ void TitleMain::draw_overlay() if( !translate ) translate = new TitleTranslate(this, cpus); - if( text_x+mask_w > 0 && text_x < title_w ) { + int tx = text_x - text_x1 + mask_x1; + if( tx < title_w && tx+mask_w > 0 ) { translate->xlat_mask = text_mask; translate->run_packages(); if( config.stroke_width >= SMALL && (config.style & BC_FONT_OUTLINE) ) { @@ -2604,11 +2613,19 @@ void TitleMain::save_data(KeyFrame *keyframe) output.tag.set_property("LOOP_PLAYBACK", config.loop_playback); output.append_tag(); output.append_newline(); - char text[BCTEXTLEN]; + char text[2*sizeof(config.wtext)]; int text_len = BC_Resources::encode( BC_Resources::wide_encoding, DEFAULT_ENCODING, (char*)config.wtext, config.wlen*sizeof(wchar_t), text, sizeof(text)); + int len = output.length(), avail = MESSAGESIZE-16 - len; + if( text_len >= avail ) { // back off last utf8 char + text_len = avail; + while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 ) + text[--text_len] = 0; + if( text_len > 0 ) + text[--text_len] = 0; + } output.append_text(text, text_len); output.tag.set_title("/TITLE"); output.append_tag();