nhatanhit / flashcanvas

Automatically exported from code.google.com/p/flashcanvas
0 stars 0 forks source link

Pathc for better support for text and various optimizations #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I've been working on this project for a few days, and made a few 
additions :

 - basic support of text drawing (taking font style/size/weight/family 
into account) thanks to code from FxCanvas
 - custom menu with two options : "Save image as" and "Go to project page" 
(FxCanvas)
 - added a few data types as they are in the spec for future use 
(CanvasPixelArray, ImageData and TextMetrics)
 - added a server side script taking as POST parameter a data URI scheme 
for image download
 - added support for JPEG for the toDataUrl method
 - added examples from the canvas-text project
 - minor optimization in the JS file 
 - the JS file doesn't have to be the last one in the document for the 
script to work

I'm aware that some parts on this work may have already been implemented 
in the Pro version, but I wanted to share it, with my personal point of 
view. I of course attached the patch.

Original issue reported on code.google.com by fabien.menager on 9 Feb 2010 at 1:09

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for your contribution. I'll check your patch later.

Original comment by revu...@gmail.com on 9 Feb 2010 at 9:54

GoogleCodeExporter commented 9 years ago
Some comments:

- TextMetrics
Should we implement the attribute "height"? It's not in the specification.

- server side script
It's better to add the following header, isn't it?
header('Content-Disposition: attachment; filename="canvas.png"');

- getScriptUrl()
No need to modify. See http://d.hatena.ne.jp/shogo4405/20070206/1170741017 for
example. The page is written in Japanese, but you'll understand what I want to 
say if
you look at the code.

Original comment by revu...@gmail.com on 10 Feb 2010 at 10:06

GoogleCodeExporter commented 9 years ago
- TextMetrics
I added this because I never understood why this isn't in the specs, but if it 
isn't
in the spec, it isn't in the spec...

- server side script
Yep, it would even be better to add this :

$ext = substr($mime, strrpos($mime, "/")+1);
header('Content-Disposition: attachment; filename="image.'.$ext.'"');

- getScriptUrl()
Very clever ! I didn't know this

I saw that FlashCanvas pro supported text rotation, did you make it work with
rotationZ (but Flash10 only) ? It's really sad the result is so bad compared to
embedded fonts, there must be a way to make it better with another method.

I'll have to add the relative font size with "em" and percents, that's not so 
hard.
Multiple font families support too (only the first one will be used here, and 
if not
found, it will always fall back to a serif font)

Original comment by fabien.menager on 10 Feb 2010 at 10:25

GoogleCodeExporter commented 9 years ago
Committed some patches. The remaining patches will follow.

> - custom menu with two options : "Save image as" and "Go to project page" 
(FxCanvas)
> - added a few data types as they are in the spec for future use 
(CanvasPixelArray,
ImageData and TextMetrics)
> - added a server side script taking as POST parameter a data URI scheme for 
image
download
> - added support for JPEG for the toDataUrl method

I removed the code for height attribute from TextMetrics.as, because it is not
supported also in other browsers.

As for text rotation, I didn't use rotationZ. If you need more information, 
please
E-mail me.

Original comment by revu...@gmail.com on 11 Feb 2010 at 10:13

GoogleCodeExporter commented 9 years ago
Fabien, your patch contains the modification:

> // If the browser does not support HTML5 Canvas (the CanvasRenderingContext2D
global object is 
> // not defined in Safari 3, whereas is supports Canvas)
> if (!window["CanvasRenderingContext2D"] &&
!document.createElement("canvas").getContext) {

I propose an alternative since I don't want to use createElement("canvas") here.
So what do you think?

// If the browser is IE and does not support HTML5 Canvas
if (window.ActiveXObject && !window["CanvasRenderingContext2D"]) {

Original comment by revu...@gmail.com on 12 Feb 2010 at 3:20

GoogleCodeExporter commented 9 years ago
Hello, thank for applying some parts of my match !
I suggest something even better : 

if (false /*@cc_on || !window["CanvasRenderingContext2D"]*/) {

The second part won't even be interpreted by non-IE browsers in the case the 
script tag 
is not between conditionnal comments.

Original comment by fabien.menager on 12 Feb 2010 at 3:37

GoogleCodeExporter commented 9 years ago
Unfortunately, Google Closure Compiler does not (and will not) support 
conditional
comments. It's sad...
http://code.google.com/p/closure-compiler/issues/detail?id=47

Original comment by revu...@gmail.com on 12 Feb 2010 at 4:13

GoogleCodeExporter commented 9 years ago
Committed the remaining patches with little modification.
If you do not have any objection, I'll close this issue in a few days.

Original comment by revu...@gmail.com on 16 Feb 2010 at 10:33

GoogleCodeExporter commented 9 years ago
That's OK for me !
I'll fix the font size ASAP.

Original comment by fabien.menager on 18 Feb 2010 at 3:58

GoogleCodeExporter commented 9 years ago
This issue was closed.
If you make additional patches, please report it as an other issue.

Original comment by revu...@gmail.com on 28 Feb 2010 at 9:51