Closed Bug 339553 Opened 18 years ago Closed 17 years ago

drawString enhancement for <canvas>

Categories

(Core :: Graphics: Canvas2D, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha7

People

(Reporter: lars, Assigned: robarnold)

References

()

Details

(Keywords: dev-doc-complete)

Attachments

(5 files, 5 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3 As the canvas tag is not a standard anyway may I suggest the addition of a drawString method with parameters for font type, size and string. In order to achieve usability canvas really requires an equivalent prototype method, however the established prototype functions take immense amounts of clocktime and significantly (and unnessessarily) slow down the canvas. The current lack of standard in canvas makes it possible to include a drawString method before it is too late, thus adding new possibilities to the object. Reproducible: Always
Component: General → Layout: Canvas
OS: Windows XP → All
Product: Firefox → Core
QA Contact: general → layout.canvas
Hardware: PC → All
Version: unspecified → Trunk
Some ideas have been drafted http://wiki.mozilla.org/Canvas:Text but it would be best if this was discussed at whatwg@whatwg.org first. (Note that even if it is a standard it's still possible to extend objects with possibilities following the undrafted rules for extensibility of objects or by proposing additions to such a atandard on the appropriate forums.)
> > As the canvas tag is not a standard anyway > > http://whatwg.org/specs/web-apps/current-work/#scs-dynamic It is a working draft.
Right, proposed extensions to such working drafts go to the document author and or the public mailing list attached to it: see comment 2.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch Implements textStyle, drawText, measureText (obsolete) (deleted) — Splinter Review
Attachment #266815 - Flags: review?(vladimir)
This patch is dependent on bug 382710
Attachment #266824 - Flags: review?(vladimir)
Attachment #266815 - Attachment is obsolete: true
Attachment #266824 - Attachment is obsolete: true
Attachment #266815 - Flags: review?(vladimir)
Attachment #266824 - Flags: review?(vladimir)
Comment on attachment 266941 [details] [diff] [review] TextStyle, DrawText, MeasureText, PathText, TextAlongPath Still dependent on aforementioned bug 382710
Attachment #266941 - Flags: review?(vladimir)
Attachment #266941 - Attachment is obsolete: true
Attachment #267311 - Flags: review?(vladimir)
Attachment #266941 - Flags: review?(vladimir)
Comment on attachment 267311 [details] [diff] [review] Fixes crash when SetTextStyle was not called before the other function calls r+ me with name change to moz-prefixed names (mozTextStyle, etc.). However, please request review from dbaron (or bz?) on the style additions. Thanks!
Attachment #267311 - Flags: review?(vladimir) → review+
(In reply to comment #10) > (From update of attachment 267311 [details] [diff] [review]) > r+ me with name change to moz-prefixed names (mozTextStyle, etc.). According to HTML 5, > drawing text is not supported in this version of the API - http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#the-2d > Vendors may also define experimental contexts using the syntax vendorname-context, for example, moz-3d. - http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#getcontext So, we should create another context (e.g. moz-2dtext) as Opera did (opera-2dgame). http://my.opera.com/WebApplications/blog/show.dml/200788
(In reply to comment #11) > (In reply to comment #10) > > (From update of attachment 267311 [details] [diff] [review] [details]) > > r+ me with name change to moz-prefixed names (mozTextStyle, etc.). > > > According to HTML 5, drawing text is not supported in this version of the API Which is why we are going to prefix our extension with moz so that when such an api is standardized, this implementation will not conflict. > Vendors may also define experimental contexts using the syntax vendorname-context, for example, moz-3d. > - > http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#getcontext I interpret this as stating that it is not required to define another context. Also note that the same document states: > UA must return a reference to an object implementing CanvasRenderingContext2D The object we return does implement this interface. > So, we should create another context (e.g. moz-2dtext) as Opera did > (opera-2dgame). > http://my.opera.com/WebApplications/blog/show.dml/200788 Perhaps, but given that we are prefixing our extension functions to avoid future naming collisions (unlike Opera), there is not as much of a reason to do this.
Attachment #267311 - Attachment is obsolete: true
Attachment #269917 - Flags: review?(vladimir)
Comment on attachment 269917 [details] [diff] [review] Method/Attribute renaming and fixed a bug when the canvas was not attached to the dom Looks good
Attachment #269917 - Flags: review?(vladimir) → review+
Attached patch Fixed builds errors on trunk (deleted) — Splinter Review
gfxGlobalTextRunCache disappeared between when I posted and vlad review. New version uses gfxTextRunCache::AutoTextRun.
Attachment #269917 - Attachment is obsolete: true
Attachment #273496 - Flags: review?(vladimir)
Attached file Text path demo (deleted) —
Attached file Second path demo (deleted) —
Attached file Animated text demo (deleted) —
Thanks.. this is still on my list to check in, my tree's just been full of new cairo, but I should have that wrapped up soon. I'll get this in tonight or tomorrow.
Assignee: nobody → robarnold
Checking in content/canvas/src/nsCanvasRenderingContext2D.cpp; /cvsroot/mozilla/content/canvas/src/nsCanvasRenderingContext2D.cpp,v <-- nsCanvasRenderingContext2D.cpp new revision: 1.90; previous revision: 1.89 done Checking in layout/style/nsStyleSet.cpp; /cvsroot/mozilla/layout/style/nsStyleSet.cpp,v <-- nsStyleSet.cpp new revision: 3.185; previous revision: 3.184 done Checking in layout/style/nsStyleSet.h; /cvsroot/mozilla/layout/style/nsStyleSet.h,v <-- nsStyleSet.h new revision: 3.23; previous revision: 3.22 done Checking in gfx/thebes/src/gfxFont.cpp; /cvsroot/mozilla/gfx/thebes/src/gfxFont.cpp,v <-- gfxFont.cpp new revision: 1.58; previous revision: 1.57 done Checking in dom/public/idl/canvas/nsIDOMCanvasRenderingContext2D.idl; /cvsroot/mozilla/dom/public/idl/canvas/nsIDOMCanvasRenderingContext2D.idl,v <-- nsIDOMCanvasRenderingContext2D.idl new revision: 1.6; previous revision: 1.5 done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Comment on attachment 273496 [details] [diff] [review] Fixed builds errors on trunk (was already reviewed and checked in)
Attachment #273496 - Flags: review?(vladimir) → review+
Depends on: 390476
Comment on attachment 275020 [details] [diff] [review] This fixes an issue in Windows optimized builds with some uninitialized data r+a=me, checked in, thanks!
Attachment #275020 - Flags: review?(vladimir)
Attachment #275020 - Flags: review+
Attachment #275020 - Flags: approval1.9+
Keywords: dev-doc-needed
http://developer.mozilla.org/en/docs/Canvas:Text has some docs (thanks Rob!), but it could use more detail (i.e. formal API documentation), so keeping on the dev-doc-needed radar.
Flags: in-testsuite?
Target Milestone: --- → mozilla1.9 M7
The docs have been overhauled substantially. Basically the same content, just rearranged to match other reference documents more closely. http://developer.mozilla.org/en/docs/Drawing_text_using_a_canvas
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: