VSE: Add bold and italic option for text strip

Bold and italic fonts can be switched quickly by presing corresponding
button.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D10542
This commit is contained in:
Peter Fog 2021-03-20 00:29:22 +01:00 committed by Richard Antalik
parent 7bf977e9f0
commit 913b71bb8b
Notes: blender-bot 2023-04-19 22:54:54 +02:00
Referenced by commit 32301a0700, Fix sequencer text leaving bold & italic flags enabled
4 changed files with 27 additions and 2 deletions

View File

@ -1271,7 +1271,13 @@ class SEQUENCER_PT_effect_text_style(SequencerButtonsPanel, Panel):
layout = self.layout
layout.use_property_split = True
col = layout.column()
col.template_ID(strip, "font", open="font.open", unlink="font.unlink")
row = col.row(align=True)
row.use_property_decorate = False
row.template_ID(strip, "font", open="font.open", unlink="font.unlink")
row.prop(strip, "use_bold", text="", icon="BOLD")
row.prop(strip, "use_italic", text="", icon="ITALIC")
col.prop(strip, "font_size")
col.prop(strip, "color")
@ -1294,7 +1300,6 @@ class SEQUENCER_PT_effect_text_style(SequencerButtonsPanel, Panel):
row.prop_decorator(strip, "box_color")
row = layout.row(align=True, heading="Box Margin")
row.use_property_decorate = False
sub = row.row(align=True)
sub.prop(strip, "box_margin")
sub.active = strip.use_box and (not strip.mute)

View File

@ -354,6 +354,8 @@ typedef struct TextVars {
enum {
SEQ_TEXT_SHADOW = (1 << 0),
SEQ_TEXT_BOX = (1 << 1),
SEQ_TEXT_BOLD = (1 << 2),
SEQ_TEXT_ITALIC = (1 << 3),
};
/* TextVars.align */

View File

@ -2932,6 +2932,16 @@ static void rna_def_text(StructRNA *srna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_BOX);
RNA_def_property_ui_text(prop, "Shadow", "Display colored box behind text");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
prop = RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_BOLD);
RNA_def_property_ui_text(prop, "Bold", "Display text as bold");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
prop = RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_ITALIC);
RNA_def_property_ui_text(prop, "Italic", "Display text as italic");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update");
}
static void rna_def_color_mix(StructRNA *srna)

View File

@ -3938,6 +3938,14 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
proxy_size_comp = SEQ_rendersize_to_scale_factor(context->preview_render_size);
}
BLF_disable(font, BLF_ITALIC | BLF_BOLD);
if (data->flag & SEQ_TEXT_BOLD) {
BLF_enable(font, BLF_BOLD);
}
if (data->flag & SEQ_TEXT_ITALIC) {
BLF_enable(font, BLF_ITALIC);
}
/* set before return */
BLF_size(font, proxy_size_comp * data->text_size, 72);