You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some Luxor testing I found a problem with the Pro text API, and here's the same problem reproduced in Cairo:
The blue area has been applied to the second "Hamburgefons" string, looks like it's inherited from the previous text with markup. I'm hoping this is a bug -- but of course I may have misunderstood how it's supposed to work.
## header to provide surface and context
using Cairo
c = CairoRGBSurface(256,256)
cr = CairoContext(c)
Cairo.save(cr)
set_source_rgb(cr,0.8,0.8,0.8) # light gray
rectangle(cr,0.0,0.0,256.0,256.0) # background
Cairo.fill(cr)
restore(cr)
Cairo.save(cr)
set_font_face(cr, "Sans 16")
Cairo.text(cr,16.0,40.0,"Hamburgefons")
Cairo.text(cr,16.0,72.0,"sp⁰¹²³,min⁻²,αΑβΒφϕΦγΓ")
Cairo.text(cr,16.0,104.0,"Text<b>Bold</b><i>Italic</i><sup>super-2</sup>",markup=true)
Cairo.text(cr,40.0,224.0,"Es geht <span foreground=\"white\" background=\"blue\">aufwärts</span> !",markup=true,angle=30.0)
# But this doesn't have markup...:
Cairo.text(cr,16.0,223.0,"Hamburgefons again")
#using textwidth and height
set_font_face(cr, "Sans 12")
a = "A"
aheight = textheight(cr,a)
awidth = textwidth(cr,a)
atext = @sprintf("%s wd=%2.2f,ht=%2.2f",a,awidth,aheight)
Cairo.text(cr,16.0,240.0,atext,markup=true)
## mark picture with current date
Cairo.restore(cr)
move_to(cr,0.0,12.0)
set_source_rgb(cr, 0,0,0)
show_text(cr,Libc.strftime(time()))
write_to_png(c,"/tmp/sample_pango_text.png")
You can also get other aspects of the markup leaking into other strings (eg bold, superscript).
I have recognized similar problems when writing the demo code. I'm not a pango expert, but i think the main problem is reusing the pango-context in multiple lines. You could try to create a new Cairo.context which creates a new pango context implicitly.
In the long-run, a new text API and doing a clean split of cairo and pango seems to be needed,
In some Luxor testing I found a problem with the Pro text API, and here's the same problem reproduced in Cairo:
The blue area has been applied to the second "Hamburgefons" string, looks like it's inherited from the previous text with markup. I'm hoping this is a bug -- but of course I may have misunderstood how it's supposed to work.
You can also get other aspects of the markup leaking into other strings (eg bold, superscript).
The text was updated successfully, but these errors were encountered: