Yoxem
February 17, 2025, 11:57am
5
Yes. I have read the simplified minimalizing badness line-wrapping algorithm (in Chinese Wikipedia “自動換行#最小破損度” (auto linewrapping # Mininal raggedness)) before implementing it.
The related function is there:
module Arrange
using Match
u = Main.uahgi
total_cost_table = Dict()
# the cost of make ith to jth item a line
function cost(items, i, j, linewidth, last_of_queue=false)
slice = items[i:j]
last = items[j]
if typeof(last) == u.ChBox && last_of_queue === false
return Inf
end
sum_of_cost_list = 0
# add disc (after) if it exists
if i > 2 && typeof(items[i-1]) == u.Disc
module Arrange
using Match
u = Main.uahgi
total_cost_table = Dict()
# the cost of make ith to jth item a line
function cost(items, i, j, linewidth, last_of_queue=false)
slice = items[i:j]
last = items[j]
if typeof(last) == u.ChBox && last_of_queue === false
return Inf
end
sum_of_cost_list = 0
# add disc (after) if it exists
if i > 2 && typeof(items[i-1]) == u.Disc
1 Like