Automation karaskel should now take kerning into account when calculating text positioning.

Furigana line-width calculation hopefully fixed (so centering should work.)

Originally committed to SVN as r138.
This commit is contained in:
Niels Martin Hansen 2006-02-23 23:26:32 +00:00
parent 1521268773
commit b5388c3bf9

View file

@ -96,7 +96,7 @@ function karaskel.precalc_syllable_data(meta, styles, lines)
karaskel.split_furigana_data(line) karaskel.split_furigana_data(line)
line.text_stripped = "" line.text_stripped = ""
for k = 0, line.karaoke.n-1 do for k = 0, line.karaoke.n-1 do
line.text_stripped = line.text_stripped .. line.karaoke[k].text line.text_stripped = line.text_stripped .. line.karaoke[k].text_stripped
end end
end end
if karaskel.engage_positioning then if karaskel.engage_positioning then
@ -113,7 +113,8 @@ function karaskel.precalc_syllable_data(meta, styles, lines)
line.styleref = style line.styleref = style
karaskel.trace("precalc_syllable_data:6:") karaskel.trace("precalc_syllable_data:6:")
-- Process the syllables -- Process the syllables
local curx, curtime = 0, 0 local curtime = 0
local sumtext = ""
local inline_fx = karaskel.inline_fx_default local inline_fx = karaskel.inline_fx_default
for j = 0, line.karaoke.n-1 do for j = 0, line.karaoke.n-1 do
karaskel.trace("precalc_syllable_data:7::"..j) karaskel.trace("precalc_syllable_data:7::"..j)
@ -129,15 +130,17 @@ function karaskel.precalc_syllable_data(meta, styles, lines)
end end
syl.inline_fx = inline_fx syl.inline_fx = inline_fx
-- Do positioning calculations, if applicable -- Do positioning calculations, if applicable
sumtext = sumtext .. syl.text_stripped
if karaskel.engage_positioning then if karaskel.engage_positioning then
-- Summed text dimensions
local sumwidth = aegisub.text_extents(style, sumtext)
-- Syllable dimensions -- Syllable dimensions
syl.width, syl.height, syl.ascent, syl.extlead = aegisub.text_extents(style, syl.text_stripped) syl.width, syl.height, syl.ascent, syl.extlead = aegisub.text_extents(style, syl.text_stripped)
karaskel.trace("precalc_syllable_data:8::") karaskel.trace("precalc_syllable_data:8::")
-- Syllable positioning -- Syllable positioning
syl.left = curx syl.right = sumwidth
syl.center = math.floor(curx + syl.width/2) syl.left = sumwidth - syl.width
syl.right = curx + syl.width syl.center = math.floor(sumwidth - syl.width/2)
curx = syl.right
if syl.furigana then if syl.furigana then
karaskel.calc_furigana_sizes(line, syl) karaskel.calc_furigana_sizes(line, syl)
end end