mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
Fix widths of time columns for fonts with proportional figures
This still breaks when the 0 digit is narrower than some other digit, but that's unlikely and the current behavior now matches the original behavior when all times are < 10h. Fixes arch1t3cht/Aegisub#111 .
This commit is contained in:
parent
eaf09b2850
commit
1515c77438
@ -159,9 +159,14 @@ struct GridColumnStartTime final : GridColumnTime {
|
||||
|
||||
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
||||
agi::Time max_time = max_value(&AssDialogue::Start, c->ass->Events);
|
||||
if (!by_frame)
|
||||
return helper(max_time.GetAssFormatted());
|
||||
return helper(std::to_wstring(c->videoController->FrameAtTime(max_time, agi::vfr::START)));
|
||||
std::string value = by_frame ? std::to_string(c->videoController->FrameAtTime(max_time, agi::vfr::START)) : max_time.GetAssFormatted();
|
||||
|
||||
for (char &c : value) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c = '0';
|
||||
}
|
||||
|
||||
return helper(value);
|
||||
}
|
||||
};
|
||||
|
||||
@ -177,9 +182,14 @@ struct GridColumnEndTime final : GridColumnTime {
|
||||
|
||||
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
||||
agi::Time max_time = max_value(&AssDialogue::End, c->ass->Events);
|
||||
if (!by_frame)
|
||||
return helper(max_time.GetAssFormatted());
|
||||
return helper(std::to_wstring(c->videoController->FrameAtTime(max_time, agi::vfr::END)));
|
||||
std::string value = by_frame ? std::to_string(c->videoController->FrameAtTime(max_time, agi::vfr::END)) : max_time.GetAssFormatted();
|
||||
|
||||
for (char &c : value) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c = '0';
|
||||
}
|
||||
|
||||
return helper(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user