Opened 9 years ago

Closed 8 years ago

#12158 closed defect (fixed)

[patch][CCLA]gfx canvas renderer does not support text rendering

Reported by: Ed Chatelain Owned by: Eugene Lazutkin
Priority: high Milestone: 1.6
Component: DojoX GFX Version: 1.6.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

Reported by Patrick Ruzand (IBM)

The current implementation of the gfx canvas renderer does not implement text rendering, as this feature was not specified (in the HTML5 spec) at the time the canvas renderer was implemented. Now that the canvas text api has been specified and implemented in all modern browsers, it should be the case for gfx too. see http://old.nabble.com/-gfx--text-and-canvas-renderer-to30649818.html for the corresponding discussion with the gfx dev.

Patch from Patrick (IBM, CCLA) and Ed (IBM, CCLA) to follow.

Attachments (2)

canvas-textsupport.txt (2.3 KB) - added by Ed Chatelain 9 years ago.
canvas_renderText.patch (2.3 KB) - added by Patrick Ruzand 8 years ago.
integrate FF bug fix. Fix coding style.

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Ed Chatelain

Attachment: canvas-textsupport.txt added

comment:1 Changed 9 years ago by Patrick Ruzand

It appears that due to a bug in Firefox 3.6, strokeText() strokes any paths drawn previously. The following code illustrates the bug :

var setup = function() {

surface = dojox.gfx.createSurface(dojo.byId('surface_div'), 1000, 300); surface.whenLoaded(function() {

var t = surface.createRect().setFill('red'); t = surface.createText({text:'A sample text',x:100, y:250})

.setFont({type:'font', size:'28pt', family:'sans-serif'}) .setStroke({ width: 2, color: 'blue' });

will stroke the rect in blue under FF but is ok under Chrome/Safari?.

The fix is to wrap the strokeText() call between a beginPath()/closePath().

if (this.strokeStyle) {

ctx.beginPath(); fix bug in FF3.6. Fixed in FF4b8 ctx.strokeText(s.text, s.x, s.y); ctx.closePath();

}

I think the corresponding br in bugzilla is https://bugzilla.mozilla.org/show_bug.cgi?id=499628

comment:2 Changed 8 years ago by Patrick Ruzand

New patch to integrate FF bug fix above and fix code styling to match dojo CS.

Changed 8 years ago by Patrick Ruzand

Attachment: canvas_renderText.patch added

integrate FF bug fix. Fix coding style.

comment:3 Changed 8 years ago by Chris Mitchell

Summary: gfx canvas renderer does not support text rendering[patch][CCLA]gfx canvas renderer does not support text rendering

comment:4 Changed 8 years ago by Eugene Lazutkin

Milestone: tbd1.6
Status: newassigned

comment:5 Changed 8 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [23682]) gfx: added text to the canvas renderer, thx Patrick Ruzand (IBM, CCLA) and edchat (IBM, CCLA)!, !strict, fixes #12158.

Note: See TracTickets for help on using tickets.