Some discoveries about multilingual .swf's with ming 0.3a

David Marceau <[email protected]> Fri, 16 Jan 2004 17:03:54 -0500
Newsgroups gmane.comp.web.ming.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------5013F75382CA82F07EC76E38
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Ok,

I managed to isolate what stuff I think works and what doesn't.

BTW to test this stuff I used 
gflashplayer "Flash Player 6 for Linux" v.6.0.69.0.
using mdk linux 8.2.

SWFText
-------
version 0.3a
I can't use the default web browser fonts with the SWFText object...period.
I can use any ttf2fft/makefdb generated .fdb file, 
BUT only with English Text/Japanese Text(using addUTF8String).
not with french accented characters since they seem to be badly character mapped
I think. 
Sometimes wrong chars appear or there are no characters that appear when typing
in french strings.
With SWFText I can't manage to display any french characters using addString or
addUTF8String.  
I am guessing it has to do with char maps somehow.

Actionscript doesn't seem to work with SWFText.  I set a name to the display
item associated with the SWFText instantiation, but it didn't seem to execute
the wanted changes in English or French.

SWFTextField
-----------
1)I can't use any ttf2fft/makefdb generated .fdb files with this.  They don't
appear...period.
2)I can however use the default web browser fonts such as _sans, _serif,
_typewriter, ...
3)the French characters display correctly when using addUTF8String but not
addString.
4)the Japanese characters don't display at all since I can't seem to find the
right name for the "Mincho" font.  In my mind, this should work, since all
Japanese fonts are installed on my machine.

Actionscript works with SWFTextField.  I set a name for the SWFTextField and it
worked for English and French.  Being that I couldn't use the japanese font, I
couldn't get to see this working with japanese strings yet.

Conclusion:
-----------
To display stuff and animate stuff though, ming is definitely there.
For inputting typed data with either japanese/french/english at the same time
through ming/.swf however, IMHO it's not there yet on my machine.

I think we should be able to achieve this considering there are built-in web
browser fonts that we should be able to access but I haven't succeeded yet for
jp mincho.  Any suggestions or ideas for this?  The Flash format spec v7.0
clearly shows the mincho font as one of the default web browser fonts available.

I have attached a test2.c file demonstrating some of my observations.

Tangent...I noticed in the v7.0 spec that the actionscript stack doesn't use
boundaries when describing an action.  I also noticed that some of the string
objects are still using null-terminated strings instead of providing boundaries
i.e. begin and end with a string length.  Something tells me it would be safer. 
It's not a ming issue as such but a Flash Player issue I think.

Cheers,
David Marceau
--------------5013F75382CA82F07EC76E38
Content-Type: text/plain; charset=iso-8859-1;
 name="test2.c"
Content-Disposition: inline;
 filename="test2.c"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by opaque.net id i0GN91rl022009

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#include "../ming.h"

#define WIDTH 500
#define HEIGHT 200


void testEnglishSWFText(SWFMovie movie)
{
  SWFFont f;

	//works for english text no problem
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
 =20
  //works for english text no problem
  f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT.f=
db","rb"));
  SWFText t =3D newSWFText();
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  SWFText_setFont(t, f);
  SWFText_setHeight(t, 14);
  SWFText_setColor(t, 0, 0, 0, 0xff);
  SWFText_setSpacing(t, 0);
  SWFText_addString(t, "EnglishSWFText <<I love you Sayo;)>>", NULL);

  d =3D SWFMovie_add(movie, (SWFCharacter)t);
  SWFDisplayItem_move(d, 0, 14);
}

void testJapaneseSWFText(SWFMovie movie)
{
  SWFFont f;

	f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming-ex=
amples/common/Kochi Mincho.fdb","rb"));
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
 =20
  //works for english text no problem
  //f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT=
.fdb","rb"));
  SWFText t =3D newSWFText();
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  SWFText_setFont(t, f);
  SWFText_setHeight(t, 14);
  SWFText_setColor(t, 0, 0, 0, 0xff);
  SWFText_setSpacing(t, 0);
  //SWFText_setBounds(t, 700, 14);
  SWFText_addUTF8String(t, "JapaneseUTF8 SWFText <<=E3?*=E3,^=EF=BC? =E3,=
?=E3?Y=E3?-=E3?=AF =E3?,=E3?=AA=E3?Y=E3,? =E3?,=E3??=E3?-=E3?=A6=E3??=E3?=
=BE=E3??=E3?,>>", NULL);

  d =3D SWFMovie_add(movie, (SWFCharacter)t);
  SWFDisplayItem_move(d, 0, 28);
}



void testFrenchSWFText(SWFMovie movie)
{
  //I haven't been successful here with a straight addstring
  SWFFont f;

  //cannot use browser font for SWFText
  //f =3D newSWFBrowserFont("_sans");

  //this one displays characters but the wrong accented characters
  //could it be the character map in the .fdb file that's wrong?
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
  f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT.f=
db","rb"));
  SWFText t =3D newSWFText();
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  SWFText_setFont(t, f);
  SWFText_setHeight(t, 12);
  SWFText_setColor(t, 0, 0, 0, 0xff);
  SWFText_setSpacing(t, 0);
  //this one doesn't display the characters correctly
  //so I am trying with this service instead
  SWFText_addString(t, "<<FrenchSWFText =C3=A9=C3=A0i=C3=B4=C3=B6=C3=A7>>=
", NULL);

  //this one still gave me the wrong accented characters
  //I suspect the character maps aren't working maybe...
  //SWFText_addUTF8String(t, "<<FrenchSWFText =C3=A9=C3=A0i=C3=B4=C3=B6=C3=
=A7>>", NULL);

  d =3D SWFMovie_add(movie, (SWFCharacter)t);
  SWFDisplayItem_move(d, 0, 100);
  SWFDisplayItem_setName(d, "message2");
  char myOnlyFrameAction[4000];
  sprintf(myOnlyFrameAction, "message2 =3D \"<<FrenchSWFText =C3=A9=C3=A0=
i=C3=B4=C3=B6=C3=A7>>\"; ");
  SWFMovie_add(movie, compileSWFActionCode(myOnlyFrameAction));
}

void testEnglishSWFTextField(SWFMovie movie)
{
  SWFTextField t;
  SWFFont f;

  //no longer seems to work in 0.3a, this only works in 0.2a for me=20
  //for either english text or french text for that matter
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
 =20
  //no longer seems to work in 0.3a, this only works in 0.2a for me=20
  //for either english text or french text for that matter
  //f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT=
.fdb","rb"));
 =20
  //this works in 0.3a
  //it seems only the default browser fonts work=20
  //with SWFTextField at the moment.
  f =3D newSWFBrowserFont("_sans");
  t =3D newSWFTextField();
  SWFTextField_setFont(t, f);
  SWFTextField_setColor(t, 255, 0, 0, 255);
  SWFTextField_setHeight(t, 12);
  SWFTextField_setBounds(t, 300, 50);
  SWFTextField_setAlignment(t, SWFTEXTFIELD_ALIGN_LEFT);
  SWFTextField_setVariableName(t, "message");

  //SWFTextField t =3D newSWFTextField();
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  d =3D SWFMovie_add(movie, (SWFTextField)t);
  SWFDisplayItem_move(d, 0, 100);

  char myOnlyFrameAction[4000];
  sprintf(myOnlyFrameAction, "message =3D \"EnglishSWFTextField\"; ");
  SWFMovie_add(movie, compileSWFActionCode(myOnlyFrameAction));
  SWFMovie_nextFrame(movie);
}



void testFrenchSWFTextField(SWFMovie movie)
{
  SWFTextField t;
  SWFFont f;

  //font no longer displays in 0.3a, this only works in 0.2a for me=20
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
 =20
  //font no longer displays in 0.3a, this only works in 0.2a for me=20
  //f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT=
.fdb","rb"));

  //shows nothing like mincho since they are for japanese characters.
  //f =3D newSWFBrowserFont("Tohaba(Gothic Mono)");

  //works with AddUTF8String to display french chars
  //f =3D newSWFBrowserFont("_serif");

  //displays characters but french accented ones only visible with=20
  //AddUTFString or within actionscript which assumes utf8=20
  //f =3D newSWFBrowserFont("_typewriter");

 =20
  //doesn't work. no characters visible accented or not accented.
  //f =3D newSWFBrowserFont("Mincho");
 =20
  //this works in 0.3a
  f =3D newSWFBrowserFont("_sans");

  t =3D newSWFTextField();
  SWFTextField_setFont(t, f);
  SWFTextField_setColor(t, 255, 0, 0, 255);
  SWFTextField_setHeight(t, 14);
  SWFTextField_setBounds(t, 700, 14);
  SWFTextField_setAlignment(t, SWFTEXTFIELD_ALIGN_LEFT);
  SWFTextField_setVariableName(t, "message");
  SWFTextField_addUTF8String(t, "FrenchUTF8 SWFTextField <<Sayo je t'aime=
 en fran=C3=A7ais ;)=C3=A9=C3=A0i=C3=B6=C3=B4=C3?>>");
 =20
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  d =3D SWFMovie_add(movie, (SWFTextField)t);
  SWFDisplayItem_move(d, 0, 28);

  //this works for SWFTextField only(not SWFText)
  //char myOnlyFrameAction[4000];
  //sprintf(myOnlyFrameAction, "message =3D \"<<FrenchUTF8 SWFTextField =C3=
=A9=C3=A0i=C3=B4=C3=B6=C3=A7>>\"; ");
  //SWFMovie_add(movie, compileSWFActionCode(myOnlyFrameAction));
  //SWFMovie_nextFrame(movie);
}

void testJapaneseSWFTextField(SWFMovie movie)
{
  SWFTextField t;
  SWFFont f;


  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/Kochi Mincho.fdb","rb"));

  //font no longer displays in 0.3a, this only works in 0.2a for me=20
  //f =3D loadSWFFontFromFile(fopen("/home/david/devstuff/flashstuff/ming=
-examples/common/test.fdb","rb"));
 =20
  //font no longer displays in 0.3a, this only works in 0.2a for me=20
  //f =3D loadSWFFontFromFile(fopen("/home/david/fdbfonts/fdb/CarminaLtBT=
.fdb","rb"));

  //shows nothing like mincho since they are for japanese characters.
  //f =3D newSWFBrowserFont("Tohaba(Gothic Mono)");

  //works with AddUTF8String to display french chars
  //f =3D newSWFBrowserFont("_serif");

  //displays characters but french accented ones only visible with=20
  //AddUTFString or within actionscript which assumes utf8=20
  //f =3D newSWFBrowserFont("_typewriter");

 =20
  //doesn't work. no characters visible accented or not accented.
  f =3D newSWFBrowserFont("Mincho");
 =20
  //this works in 0.3a
  //f =3D newSWFBrowserFont("_sans");

  t =3D newSWFTextField();
  SWFTextField_setFont(t, f);
  SWFTextField_setColor(t, 255, 0, 0, 255);
  SWFTextField_setHeight(t, 12);
  SWFTextField_setBounds(t, 400, 50);
  SWFTextField_setAlignment(t, SWFTEXTFIELD_ALIGN_LEFT);
  SWFTextField_setVariableName(t, "message");
  SWFTextField_addUTF8String(t, "<<=E3??=E3??=E3??=E3??=E3??=E3?=AF=E3?=BD=
=E3?,>>");
 =20
  SWFDisplayItem d;

  if(f =3D=3D NULL)
  {
    printf("font def file not found!\n");
    exit(1);
  }

  d =3D SWFMovie_add(movie, (SWFTextField)t);
  SWFDisplayItem_move(d, 0, 100);

  //this works for SWFTextField only(not SWFText)
  //char myOnlyFrameAction[4000];
  //sprintf(myOnlyFrameAction, "message =3D \"<<FrenchSWFTextField =C3=A9=
=C3=A0i=C3=B4=C3=B6=C3=A7>>\"; ");
  //SWFMovie_add(movie, compileSWFActionCode(myOnlyFrameAction));
  //SWFMovie_nextFrame(movie);
}



  //SWFDisplayItem_setName(d, "frmsg");
  //SWFTextField_setFont(t, f);
  //SWFTextField_setHeight(t, 24);
  //SWFTextField_setColor(t, 0xff, 0, 0, 0xff);
  // SWFTextField_setSpacing(t, 0);
  //SWFTextField_setVariableName(t, "message");
  //SWFTextField_addUTF8String(t, "<<FrenchSWFTextField =C3=A9=C3=A0i=C3=B4=
=C3=B6=C3=A7>>");


int main(int argc, char *argv[])
{
  FILE *f;
  SWFMovie m =3D newSWFMovieWithVersion(6);
  int length;

  Ming_init();

  srand(time(NULL));

  f =3D fopen("test.swf", "wb");

  SWFMovie_setRate(m, 15.0);
  SWFMovie_setDimension(m, WIDTH, HEIGHT);
  SWFMovie_setNumberOfFrames(m, 40);

  testEnglishSWFText(m);
  //testEnglishSWFTextField(m);
  //testFrenchSWFText(m);
  testFrenchSWFTextField(m);
  testJapaneseSWFText(m);
  //testJapaneseSWFTextField(m);

  length =3D SWFMovie_output(m, fileOutputMethod, f, -1);
  destroySWFMovie(m);

  printf("%i bytes written\n", length);

  exit(0);
}

--------------5013F75382CA82F07EC76E38
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

_______________________________________________
ming-fun mailing list
[email protected]
http://www.opaque.net/mailman/listinfo/ming-fun

--------------5013F75382CA82F07EC76E38--