|
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
|