Aegisub/aegisub/automation/tests/text-extents-test.lua
Amar Takhar a067bd560d SVN Transition Step 3/7
1. cd aegisub/
  2. svn mv *cpp *h src/
  3. svn mv Makefile.am MatroskaParser.c auto4_perldata.inc bitmaps boost \
     changelog.txt config gl include libosxutil libresrc md5.c msvc mythes.cxx \
     mythes.hxx res.rc src/
  4. cd ..
  5. svn mv FFmpegSource2/ INSTALL Makefile.am README  acinclude.m4 \
     autogen.sh automation/ bin build configure.in desktop dummy.txt lib \
     libass/ m4macros/ packages/ po/ scripts/ universalchardet/ aegisub/
  6. mkdir -p docs/wiki_convert
  7. svn add docs/wiki_convert
  8. cd docs
  9. svn mv aegisub_convert_docs.pl convert.bat output wiki_convert/

* See r2749 for full description.

Originally committed to SVN as r2752.
2009-03-08 08:30:39 +00:00

40 lines
1 KiB
Lua

-- Automation 4 test file
-- Create a Macro feature, that displays some text
script_name = "Automation 4 test 5"
script_description = "Test include and text_extents"
script_author = "Niels Martin Hansen"
script_version = "1"
include("utils.lua")
function test5(subtitles, selected_lines, active_line)
local styles = {}
for i = 1, #subtitles do
local l = subtitles[i]
if l.class == "dialogue" then
break
end
if l.class == "style" then
styles[l.name] = l
end
end
for i = #selected_lines, 1, -1 do
local ri = selected_lines[i]
local l = subtitles[ri]
local k = aegisub.parse_karaoke_data(l)
local left = 0
for j = 1, #k do
local nl = table.copy(l)
l.text = string.format("{\\t(%d,%d,\\fscx50)\\pos(%d,20)}%s", k[j].start_time, k[j].end_time, left, k[j].text_stripped)
left = left + (aegisub.text_extents(styles[l.style], k[j].text_stripped))
subtitles.insert(ri+j, l)
end
end
aegisub.set_undo_point("karaoke-like stuff")
end
aegisub.register_macro("More karaoke fun", "Makes some more karaoke-like stuff", test5, nil)