From 27a9927cf2131cbf5a1279a2f670c78501f850d7 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Wed, 17 Jan 2007 09:20:17 +0000 Subject: [PATCH] Testcase for text_extents function Originally committed to SVN as r824. --- automation/tests/test-text_extents.lua | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 automation/tests/test-text_extents.lua diff --git a/automation/tests/test-text_extents.lua b/automation/tests/test-text_extents.lua new file mode 100644 index 000000000..c3ba6b735 --- /dev/null +++ b/automation/tests/test-text_extents.lua @@ -0,0 +1,29 @@ +-- Automation 4 test file +-- Test the result of the text_extents function + +script_name = "Test text_extents" +script_description = "Test what the result of text_extents is on a fixed string on all styles in the file" +script_author = "Niels Martin Hansen" +script_version = "1" + + +function test_te(subtitles, selected_lines, active_line) + local teststring = "Test" + + aegisub.debug.out("Test string is '" .. teststring .. "'\n") + + local styles = {} + for i = 1, #subtitles do + local l = subtitles[i] + if l.class == "style" then + aegisub.debug.out(" - - -\n") + aegisub.debug.out("Found style: " .. l.name .. "\n") + local width, height, descent, extlead = aegisub.text_extents(l, teststring) + aegisub.debug.out(string.format("Width: %.2f Height: %.2f Descent: %.2f Ext. lead: %.2f\n", width, height, descent, extlead)) + end + aegisub.progress.set(i/#subtitles*100) + end +end + + +aegisub.register_macro("Test text_extents", "Show the result of the text_extents function for all styles in the file", test_te, nil)