bug in textrendering using "pt" size

16 views
Skip to first unread message

Christophe VG

unread,
Oct 15, 2009, 3:54:24 PM10/15/09
to google-...@googlegroups.com
Hi,

first up, great work! :-) but I think I stumbled upon a bug, or I'm
missing the point and I'm going to learn something out of this.

In attachement I have a small test case which basically draws 2 texts
on a canvas, one in a 10px font and one in a 10pt font. I've also
added pure HTML versions of them for reference. The result was not
what I expected:

excanvas-text.html
excanvas.js.diff
Screen shot 2009-10-15 at 21.43.38.png
Screen shot 2009-10-15 at 21.44.01.png

Fabien Ménager

unread,
Oct 18, 2009, 2:02:36 PM10/18/09
to google-excanvas
You are right, this seems to be a bad copy/paste.
I suggest you to change your patch to be even better with this :

computedStyle.size = fontSize / 0.75;

to avoid an operation.

Cheers
>  Screen shot 2009-10-15 at 21.43.38.png
> 18KAfficherTélécharger
>
>
>
> When I look into the code I find on line 534 (current trunk):
>
>      } else if (style.size.indexOf('pt') != -1) {
>        computedStyle.size = canvasFontSize * (4/3) * fontSize;
>
> If I dump canvasFontSize and fontSize at that point I get
>
> canvasFontSize =  12
> fontSize = 10
>
> which results in
>
> 12 * (4/3) * 10 = 160
>
> Removing canvasFontSize from the formula, seem to produce about the  
> same result as the HTML reference:
>
>  Screen shot 2009-10-15 at 21.44.01.png
> 12KAfficherTélécharger
>
>
>
> When I google around for conversion between pt and px I find e.g.:http://www.mobilefish.com/tutorials/css/css_quickguide_px_pt.html:
>
>         Formula
>         px = pt / 0.75
>
> So I would say that my "guess" (fontSize * 4/3) would be correct  
> according to this source and maybe the canvasFontSize is a type/paste-
> error/something.
>
> For what it's worth, I have also attached this in a small diff.
>
> regards,
> Christophe VG
>
>  excanvas-text.html
> < 1 000AfficherTélécharger
>
>  excanvas.js.diff
> < 1 000AfficherTélécharger

Christophe VG

unread,
Oct 18, 2009, 3:15:41 PM10/18/09
to google-...@googlegroups.com
off course ;-)

C

excanvas.diff

Erik Arvidsson

unread,
Oct 21, 2009, 1:45:06 AM10/21/09
to google-...@googlegroups.com
Fixed

Thanks

On Sun, Oct 18, 2009 at 12:15, Christophe VG <christ...@gmail.com> wrote:
> off course ;-)
>
> C
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the Google
>> Groups "google-excanvas" group.
>> To post to this group, send email to google-...@googlegroups.com
>> To unsubscribe from this group, send email to google-excanv...@googlegroups.com
>> For more options, visit this group at http://groups.google.com/group/google-excanvas?hl=en
>> -~----------~----~----~----~------~----~------~--~---
>>
>
>
>



--
erik
Reply all
Reply to author
Forward
0 new messages