|
From: Justin C. <ju...@po...> - 2008-01-20 05:44:26
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
Have just discovered that with SWFText_moveTo() (which maps to
SWFText_scaledMoveTo()), trying to set either x or y to 0 leads to that
value being skipped.
Guessing it was originally intended to allow just one of the
co-ordinates to be effective, but it seems more like a bug.
It's stopping text pen position from actually being set to zero (on
purpose) in either dimension, which I need.
*****************
void
SWFText_scaledMoveTo(SWFText text, int x, int y)
{
SWFTextRecord textRecord = text->currentRecord;
if ( textRecord == NULL || textRecord->string != NULL )
textRecord = SWFText_addTextRecord(text);
/* If SWFText_addTextRecord() failed, return early */
if (NULL == textRecord)
return;
if ( x != 0 )
{
textRecord->flags |= SWF_TEXT_HAS_X;
textRecord->x = x;
}
if ( y != 0 )
{
textRecord->flags |= SWF_TEXT_HAS_Y;
textRecord->y = y;
}
}
*****************
My thinking is we should update the function to honour the 0 value,
document the change, and create two functions allowing people to set
just one of the X or Y values.
Something like (mostly a cut-n-paste of above):
*****************
int
SWFText_scaledMoveXTo(SWFText text, int x)
{
SWFTextRecord textRecord = text->currentRecord;
if ( textRecord == NULL || textRecord->string != NULL )
textRecord = SWFText_addTextRecord(text);
// If SWFText_addTextRecord() failed, return -1 to indicate this
if (NULL == textRecord)
return -1;
textRecord->flags |= SWF_TEXT_HAS_X;
textRecord->x = x;
}
int
SWFText_scaledMoveYTo(SWFText text, int y)
{
SWFTextRecord textRecord = text->currentRecord;
if ( textRecord == NULL || textRecord->string != NULL )
textRecord = SWFText_addTextRecord(text);
// If SWFText_addTextRecord() failed, return -1 to indicate this
if (NULL == textRecord)
return -1;
textRecord->flags |= SWF_TEXT_HAS_Y;
textRecord->y = y;
}
*****************
Good idea, bad idea, general thoughts?
Regards and best wishes,
Justin Clift
- --
The Flame Project - Open Source GUI for animated SVG & Flash
http://www.flameproject.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHkt+wFAuZn5lS2IMRAnOxAKCJ/xvBSDkQWCx6kN0P9mwyWTbA9ACgqw1i
FG5UfleetbX6S5I2/u7UI4k=
=j3XX
-----END PGP SIGNATURE-----
|
|
From: Justin C. <ju...@po...> - 2008-01-21 16:13:48
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Justin Clift wrote: <snip> > My thinking is we should update the function to honour the 0 value, > document the change, and create two functions allowing people to set > just one of the X or Y values. Haven't heard any objections, so I'll put something in place over the next day or so. :) Regards and best wishes, Justin Clift - -- The Flame Project - Open Source GUI for animated SVG & Flash http://www.flameproject.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHlMS2FAuZn5lS2IMRAnP+AJ0T9Ri9APQ5kvuXwdgr/B1IbFfuBwCgyFMq 7UUbPULZ6kfH9WShjE/H7MI= =HMDo -----END PGP SIGNATURE----- |
|
From: Klaus R. <kla...@rz...> - 2008-01-21 16:27:31
|
Hi Justin,
sorry for the late answer.
The current code is alright. SWF is trying to efficiently encode information.
In the Textrecord example:
SWF_TEXT_HAS_X/Y flag NOT set means an offset of zero and saves 2 bytes per
field.
Klaus
Am Sonntag 20 Januar 2008 06:44:16 schrieb Justin Clift:
> Hi all,
>
> Have just discovered that with SWFText_moveTo() (which maps to
> SWFText_scaledMoveTo()), trying to set either x or y to 0 leads to that
> value being skipped.
>
> Guessing it was originally intended to allow just one of the
> co-ordinates to be effective, but it seems more like a bug.
>
> It's stopping text pen position from actually being set to zero (on
> purpose) in either dimension, which I need.
>
> *****************
>
> void
> SWFText_scaledMoveTo(SWFText text, int x, int y)
> {
> SWFTextRecord textRecord = text->currentRecord;
>
> if ( textRecord == NULL || textRecord->string != NULL )
> textRecord = SWFText_addTextRecord(text);
>
> /* If SWFText_addTextRecord() failed, return early */
> if (NULL == textRecord)
> return;
>
> if ( x != 0 )
> {
> textRecord->flags |= SWF_TEXT_HAS_X;
> textRecord->x = x;
> }
>
> if ( y != 0 )
> {
> textRecord->flags |= SWF_TEXT_HAS_Y;
> textRecord->y = y;
> }
> }
>
> *****************
>
> My thinking is we should update the function to honour the 0 value,
> document the change, and create two functions allowing people to set
> just one of the X or Y values.
>
> Something like (mostly a cut-n-paste of above):
>
> *****************
>
> int
> SWFText_scaledMoveXTo(SWFText text, int x)
> {
> SWFTextRecord textRecord = text->currentRecord;
>
> if ( textRecord == NULL || textRecord->string != NULL )
> textRecord = SWFText_addTextRecord(text);
>
> // If SWFText_addTextRecord() failed, return -1 to indicate this
> if (NULL == textRecord)
> return -1;
>
> textRecord->flags |= SWF_TEXT_HAS_X;
> textRecord->x = x;
> }
>
>
> int
> SWFText_scaledMoveYTo(SWFText text, int y)
> {
> SWFTextRecord textRecord = text->currentRecord;
>
> if ( textRecord == NULL || textRecord->string != NULL )
> textRecord = SWFText_addTextRecord(text);
>
> // If SWFText_addTextRecord() failed, return -1 to indicate this
> if (NULL == textRecord)
> return -1;
>
> textRecord->flags |= SWF_TEXT_HAS_Y;
> textRecord->y = y;
> }
>
> *****************
>
> Good idea, bad idea, general thoughts?
>
> Regards and best wishes,
>
> Justin Clift
|
|
From: Justin C. <ju...@po...> - 2008-01-21 21:28:09
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Klaus Rechert wrote:
> Hi Justin,
>
> sorry for the late answer.
>
> The current code is alright. SWF is trying to efficiently encode information.
> In the Textrecord example:
>
> SWF_TEXT_HAS_X/Y flag NOT set means an offset of zero and saves 2 bytes per
> field.
Hmmm, I see what you're saying, but I think it's not working for (at
least) a simple use case. (i.e. when you WANT to move the pen position
to x = 0).
Quick example, let's say I want to create a text object with two lines
of text:
First line
Second line
So, I create the font object, then create the text object and assign it
properties (i.e. the font to use, height, color, etc).
Then I add the string "First line" to it.
Now I want to move the pen position down one line and back to the x
origin, so I can add the second string "Second line".
// Move to the appropriate Y position
SWFText_moveTo(text_object, 0, scaled_font_size);
But no, SWFText_moveTo() checks for the presence of 0 and then ignores
it, so the text ends up like:
First line
Second line
How do I move the pen position back to x of 0?
Not seeing how to do it with the present code base. :(
Can provide exact code having the above problem if you need, as it's a
Real World problem I hit recently. Heh.
Regards and best wishes,
Justin Clift
> Klaus
- --
The Flame Project - Open Source GUI for animated SVG & Flash
http://www.flameproject.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHlQ5nFAuZn5lS2IMRAs2KAJ4pHFveAlBiOg89cp6M/I0vUxGWPQCgyd20
czaTCSSaOhriZE3mCTg1huk=
=vKlB
-----END PGP SIGNATURE-----
|
|
From: Klaus R. <kl...@re...> - 2008-01-21 21:39:22
|
Hi, > But no, SWFText_moveTo() checks for the presence of 0 and then ignores > it, so the text ends up like: > > First line > Second line > Have you tried that? If thats the case specs are wrong (which is not a suprise btw...). Specs say: "If there is no XOffset specified, the offset is assumed to be zero." Klaus |
|
From: strk <st...@ke...> - 2008-01-21 23:09:46
|
On Mon, Jan 21, 2008 at 10:39:43PM +0100, Klaus Rechert wrote: > Hi, > > > But no, SWFText_moveTo() checks for the presence of 0 and then ignores > > it, so the text ends up like: > > > > First line > > Second line > > > > Have you tried that? If thats the case specs are wrong (which is not a suprise > btw...). > Specs say: "If there is no XOffset specified, the offset is assumed to be > zero." What about the offset needs to be a negative number in Justin case, with zero being exactly what he's getting ? --strk; |
|
From: Justin C. <ju...@po...> - 2008-01-22 00:45:53
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Klaus Rechert wrote: > Hi, > >> But no, SWFText_moveTo() checks for the presence of 0 and then ignores >> it, so the text ends up like: >> >> First line >> Second line >> > > Have you tried that? If thats the case specs are wrong (which is not a suprise > btw...). Yeah. Only noticed the problem because it goes wonky like that. :( Just now went and retested to be sure, and yep, both the official Adobe flash player (9.0.115.0) and Gnash (0.8.1 - AGG renderer) go wonky. > Specs say: "If there is no XOffset specified, the offset is assumed to be > zero." Perhaps it's an "interpretation" thing? They could be meaning the "assumed to be zero" as (badly worded) "assumed to have no change", but somehow it got into the spec as you have it. My workaround at the moment is to do this: current_ming_scale = Ming_getScale(); Ming_setScale(1); SWFText_moveTo(text_object, 1, 0); Ming_setScale(current_ming_scale); So it moves the pen to one twip of 0. But it's pretty non-optimal to not be able to get back to 0 itself. *sigh* Regards and best wishes, Justin Clift > Klaus > - -- The Flame Project - Open Source GUI for animated SVG & Flash http://www.flameproject.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHlTyxFAuZn5lS2IMRAvp1AKCfvbF0O2qaKs30liwRMMiL9oGqcgCgqzvk JjeIL+xiGRYq1Ll/hCmw3X8= =cKWf -----END PGP SIGNATURE----- |
|
From: Klaus R. <kla...@rz...> - 2008-01-22 10:52:08
|
> Perhaps it's an "interpretation" thing? > > They could be meaning the "assumed to be zero" as (badly worded) > "assumed to have no change", but somehow it got into the spec as you > have it. Code it, and if it does the trick it is fine for me... could you also add a testcase please ? Klaus |
|
From: Justin C. <ju...@po...> - 2008-01-22 12:44:12
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Klaus Rechert wrote: >> Perhaps it's an "interpretation" thing? >> >> They could be meaning the "assumed to be zero" as (badly worded) >> "assumed to have no change", but somehow it got into the spec as you >> have it. > > Code it, and if it does the trick it is fine for me... could you also add a > testcase please ? No worries. Haven't done a test case for Ming before, so guess it's time to learn. There seem to be plenty of examples in the "test" subdirectory, so it shouldn't be too hard. Regards and best wishes, Justin Clift > Klaus - -- The Flame Project - Open Source GUI for animated SVG & Flash http://www.flameproject.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHleUNFAuZn5lS2IMRAmQSAKC4YCgw5TQlI3GVhWgkQeCzxmVS4QCg0IDx aHfRtyWxf4duZqGuidIPxZo= =RnLG -----END PGP SIGNATURE----- |