Skip to content

Make karaskel aware of style change when templating syllables #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion automation/include/karaskel-auto4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,23 @@ function karaskel.preproc_line_size(meta, styles, line)
line.width, line.height, line.descent, line.extlead = aegisub.text_extents(line.styleref, line.text_stripped)
line.width = line.width * meta.video_x_correct_factor

local cur_style = line.styleref

-- Calculate syllable sizing
for s = 0, line.kara.n do
local syl = line.kara[s]
syl.style = line.styleref

syl.style = cur_style
-- Detect any reset style tags
local _, reset_end, style_reset_name = syl.text:find("%{.*\\%r([^}\\]+)")
if style_reset_name and styles[style_reset_name] then
cur_style = styles[style_reset_name]
-- match does not include final }
if reset_end + 1 < #syl.text then
syl.style = cur_style
end
end

syl.width, syl.height = aegisub.text_extents(syl.style, syl.text_spacestripped)
syl.width = syl.width * meta.video_x_correct_factor
syl.prespacewidth = aegisub.text_extents(syl.style, syl.prespace) * meta.video_x_correct_factor
Expand All @@ -293,6 +306,9 @@ function karaskel.preproc_line_size(meta, styles, line)
for f = 1, line.furi.n do
local furi = line.furi[f]
furi.style = line.furistyle
if styles[furi.syl.style.name .. "-furigana"] then
furi.style = styles[furi.syl.style.name .. "-furigana"]
end
furi.width, furi.height = aegisub.text_extents(furi.style, furi.text)
furi.width = furi.width * meta.video_x_correct_factor
furi.prespacewidth = 0
Expand Down