Bring back floating images in font renderer
Bug #1751620 reported by
GunChleoc
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
We had the capability of having text float around images in the old font renderer. The new renderer can't do that yet. Would be nice e.g. for campaign dialogs with character images. A second use case are long lore strings in the building help.
Related branches
lp:~widelands-dev/widelands/bug-1751620-floating-images
- GunChleoc: Approve
-
Diff: 431 lines (+174/-75)3 files modifieddata/scripting/richtext.lua (+2/-3)
src/graphic/text/rt_parse.cc (+4/-2)
src/graphic/text/rt_render.cc (+168/-70)
description: | updated |
Changed in widelands: | |
milestone: | none → build20-rc1 |
status: | Confirmed → Fix Committed |
To post a comment you must log in.
I tried to implement it, see the attachment for the current state.
However, I had to change the definition of li_image() to make it work. The current (trunk) definition is:
function li_image(imagepath, text) "width= 100%",
div(p( vspace( 6) .. img(imagepath) .. space(6))) ..
div(p( space(6) )) ..
div(" width=* ", p(vspace(6) .. text .. vspace(12)))
return
div(
)
end
I changed it to:
div( "width= 100%",
div(" float=left width=134", p(img(imagepath, "width=128"))) ..
p(text)
)
The primary change is to add the floating div inside the div containing the text. Due to the hierarchical layouting done in the code, I needed them to be on the same "div-level" to interact correctly. Otherwise, the div around the text creates a rectangular box that is placed next to the image but does not flow around it. It could probably be made to work, but would break the hierarchical structure of the code.
The space() calls around image and text doesn't really seem to do anything useful, so I dropped them. The fixed width of the image and the div is a (bad) hack to gain some horizontal space between image and text. Unfortunately I wasn't able to do this with space() calls, they seem to be ignored.