Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 78 additions & 5 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Subsimport",
"description": "Import subtitles into blender",
"author": "doakey3",
"version": (1, 3, 1),
"version": (1, 3, 2),
"blender": (2, 80, 0),
"wiki_url": "https://github.com/doakey3/subsimport",
"tracker_url": "https://github.com/doakey3/subsimport/issues",
Expand Down Expand Up @@ -37,11 +37,32 @@ def draw(self, context):
row.prop(scene, 'subtitle_font',
text='Font')
row = box.row()
row.prop(scene, 'subtitle_font_color',
text="Font Color")
row = box.row()
row.prop(scene, 'subtitle_font_size',
text='Font Size')
row = box.row()
row.prop(scene, 'subtitle_font_height',
text='Font Height')
row.prop(scene, 'subtitle_font_shadow',
text="Shadow",
toggle=False)
row.prop(scene, 'subtitle_font_shadow_color',
text="Shadow Color")
row = box.row()
row.prop(scene, 'subtitle_font_xloc',
text='Font X Location')
row = box.row()
row.prop(scene, 'subtitle_font_yloc',
text='Font Y Location')
row = box.row()
row.prop(scene, 'subtitle_anchor_x',
text='Font Anchor X')
row = box.row()
row.prop(scene, 'subtitle_anchor_y',
text='Font Anchor Y')
row = box.row()
row.prop(scene, 'subtitle_wrap_width',
text='Font Wrap Width')
row = box.row()
row.operator('sequencerextra.refresh_font_data',
icon="FILE_REFRESH")
Expand Down Expand Up @@ -88,13 +109,65 @@ def init_prop():
description="The font of the added text strips after import",
subtype="FILE_PATH")

bpy.types.Scene.subtitle_font_color = bpy.props.FloatVectorProperty(
description="Font Color",
subtype='COLOR',
size=4,
default=(1.0,1.0,1.0,1.0),
min=0.0,
max=1.0,
)

bpy.types.Scene.subtitle_font_size = bpy.props.IntProperty(
description="The font size of the added text strips after import",
default=70,
min=1)

bpy.types.Scene.subtitle_font_height = bpy.props.FloatProperty(
description="The height of the added text strips after import",
bpy.types.Scene.subtitle_font_shadow = bpy.props.BoolProperty(
description="Enable or disable font shadow",
default=False)

bpy.types.Scene.subtitle_font_shadow_color = bpy.props.FloatVectorProperty(
description="Shadow Color",
subtype='COLOR',
size=4,
default=(0.0,0.0,0.0,1.0),
min=0.0,
max=1.0,
)

bpy.types.Scene.subtitle_font_xloc = bpy.props.FloatProperty(
description="The X Location of the added text strips after import",
default=0.5,
min=0.0,
max=1.0)

bpy.types.Scene.subtitle_font_yloc = bpy.props.FloatProperty(
description="The Y Location of the added text strips after import",
default=0.0,
min=0.0,
max=1.0)

bpy.types.Scene.subtitle_anchor_x = bpy.props.EnumProperty(
name='Anchor Alignment X',
description='X Alignment of Text',
items={
('LEFT', 'Left', 'Align text left relative to bounds'),
('CENTER', 'Center', 'Align text center relative to bounds'),
('RIGHT', 'Right', 'Align text right relative to bounds')},
default='CENTER')

bpy.types.Scene.subtitle_anchor_y = bpy.props.EnumProperty(
name='Anchor Alignment Y',
description='Y Alignment of Text',
items={
('TOP', 'Top', 'Align text top relative to bounds'),
('CENTER', 'Center', 'Align text center relative to bounds'),
('BOTTOM', 'Bottom', 'Align text bottom relative to bounds')},
default='BOTTOM')

bpy.types.Scene.subtitle_wrap_width = bpy.props.FloatProperty(
description="The wrap width of the text strips after import",
default=0.0,
min=0.0,
max=1.0)
Expand Down
10 changes: 9 additions & 1 deletion operators/refresh_font_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ def execute(self, context):

for strip in text_strips:
strip.font_size = scene.subtitle_font_size
strip.color = scene.subtitle_font_color
strip.use_shadow = scene.subtitle_font_shadow
strip.shadow_color = scene.subtitle_font_shadow_color
strip.font = get_font(scene.subtitle_font)
strip.location[1] = scene.subtitle_font_height
strip.location[0] = scene.subtitle_font_xloc
strip.location[1] = scene.subtitle_font_yloc
strip.align_x = scene.subtitle_anchor_x
strip.align_y = scene.subtitle_anchor_y
strip.wrap_width = scene.subtitle_wrap_width
# bpy.types.TextSequence.TextSequence(strip).wrap_width = scene.subtitle_wrap_width

return {"FINISHED"}
9 changes: 8 additions & 1 deletion operators/tools/subtitles_to_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ def subtitles_to_sequencer(context, subs):

text_strip.font = get_font(scene.subtitle_font)
text_strip.font_size = scene.subtitle_font_size
text_strip.location[1] = scene.subtitle_font_height
text_strip.color = scene.subtitle_font_color
text_strip.use_shadow = scene.subtitle_font_shadow
text_strip.shadow_color = scene.subtitle_font_shadow_color
text_strip.location[0] = scene.subtitle_font_xloc
text_strip.location[1] = scene.subtitle_font_yloc
text_strip.align_x = scene.subtitle_anchor_x
text_strip.align_y = scene.subtitle_anchor_y
text_strip.wrap_width = scene.subtitle_wrap_width
text_strip.text = subs[i].text
text_strip.use_shadow = True
text_strip.select = True
Expand Down