20 Replies Latest reply on Jun 14, 2006 8:04 AM by panell

    Dynamicly loaded fonts

    panell Level 1
      Hi
      Is there any way to dynamicly (font is loaded when needed) load fonts to flash?
        • 1. Re: Dynamicly loaded fonts
          neil manuell Level 1
          yep...

          basically you can make a library of swf that have embeded fonts
          make sure that their link names are the name of the swf.

          then you can load up the swf and add content into it.
          any textField inside that swf can access the font
          • 2. Dynamicly loaded fonts
            panell Level 1
            I also thought so...but I was trying to do this in last 3 days without success :(
            Embeded fonts works, but only when they are in the same SWF.

            I would be very gratefull if you could send me working FLA's example.
            panel_at_o2.pl
            • 3. Dynamicly loaded fonts
              neil manuell Level 1
              ok,

              1) create a fla, call it myFont and embed a font in the normal way, giving it a linkage id of "myFont".
              2) export to myFont.swf and place in a folder called fonts.
              3) create another fla and call it what you will, put a button (any button) on the stage (1st frame) and call it myButton.
              4) place attached code on 1st frame.
              5) export to the folder above fonts folder
              6) run and see what happens

              I have added the button as I couldn't be bothered to use an event handler to check that the swf has loaded

              that should work. ( i know this method works I use regularly)
              ps, I haven't tested this, any errors that you find were placed there on purpose to help with your debugging skills ;-}
              • 4. Re: Dynamicly loaded fonts
                2m Level 2
                I think I have a solution for what you want, but I can't give it to you as our team is playing agains my team in the worldcup tonight!

                ;-)

                Just kidding.

                One thing is, that loading any other swf with an embeded font wont make that font avilable to the loading movie, the only way to do that is the use of shared libraries. But the path to shared libraries has to be conpiled into the loading movie.

                (Consult the docs for more info)

                The trick to make it work even better is as simple as unknown (at least it took me weeks to figure it out) an font(-symbol) that is loaded via a shared lib is available to any other movie (at laest in the same level). So you can load a swf that in turn loads the font via shared lib, and here you go.

                Happy soccer!
                • 5. Re: Dynamicly loaded fonts
                  neil manuell Level 1
                  sorry 2m, but anything in a loaded swf's library is available, but only within that swf and any of its childern.
                  I had discarded shared library's, because, say you want a choice of twenty fonts dynamically, with the shared library, the swf has to load up the entire library before any are available (and I've found some anomilies where shared items just arn't available).
                  //
                  but I was working on a project last mounth which having a huge font library was essential, and I had this brain wave. if you want to create a text field with a certain embeded font, what you do is you load up a swf with that font embeded, then once it has loaded you create a text field inside it and apply a textformant citing that font. and hey presto, you only need to load in the font you need at the time. ( and it will be cashed if you need it again)

                  I hope some day to get a huge prize for this discovery, except I am sure that i am not the first (drat). I do expect a firm slap on the back though)

                  ps. its not soccer - its football!
                  football football football
                  and we invented it first!!
                  ;-}

                  • 6. Re: Dynamicly loaded fonts
                    panell Level 1
                    quote:

                    Originally posted by: 2m
                    I think I have a solution for what you want, but I can't give it to you as our team is playing agains my team in the worldcup tonight!

                    ;-)

                    Just kidding.


                    hahaha great joke :]

                    Tryied booth solutions without luck - still don't work :(
                    I don't know why, but propably I make some stupid mistake....
                    Please send me working fla file panel at o2.pl

                    • 7. Re: Dynamicly loaded fonts
                      2m Level 2
                      @fleece:

                      You are right, it is footbal, to all of us that are on the right side of the ocean, but most of those here aren't - so I thought I'd make myself clear. And as far as I know it is called football when Germany wins (spare russian lines-men) in the end, and I didn't want to sound too overconfident ;-)

                      Your methode is great, [slap, slap!] but when I was in need of somthing like that i hat to lay-out too much to to use it.
                      The methode I propose does work, it is tricky I admit it and I had to make a container and a font-clip for each font to overcome the issues you mentioned (but you would also need at least one clip for each font).

                      An other issue I had was thet I didn't want aybody with that font to be force to download it. I can be done with you method too I guess, but it is an bit more complicated I guess.

                      In deed I do thing your method is great, I might come to use in further cases, but mine has its advantages too (so I admit that I#m a bit jealous that I didn't come up with your solution ;-) ).
                      I would probably chge the way you use it a bit: I would place a Textfield on stage and embed the font in the IDE, this way I could gain more controll over the charakters embede, but probably you aren't aware of those intricacies as you didn'r invent umlauts.

                      ;-)



                      • 8. Re: Dynamicly loaded fonts
                        neil manuell Level 1
                        yes I have also thought about your additions, but haven't implimented them yet (I foresee the need to create a text effect engine shortly).
                        //
                        We only call in football when we loose...8-{
                        • 9. Re: Dynamicly loaded fonts
                          2m Level 2
                          I'm tempted to say, that if you have tried both so fast, it's no wonder - but I won't.

                          For which solution do you otp?

                          To be honest (but don't let Tommy hear it - we will have to penalty-shoot them out at some point in the cup) I like the solution ot fleece better, as it has the advantage that you can contol prealoding a bit better, but you have to place the textfiels via actionscript which is not something for the visual person.
                          • 10. Re: Dynamicly loaded fonts
                            2m Level 2
                            @ fleece
                            You do have brain-waves and forsee things - that trouble me a bit, but as long as you do such great work - who cares.

                            And I'm sure you don't have to loose it to call it football, I just figure, that there is some secrect agreement between her majesty and your players that they arent allowed to win the cup becaouse of fear that all those friendly english üpeople will mutate at once and will leave our county in a state worse than romans, wikings and frenc togather ever had calling it celebrations instead of war. Without the secret agreement I'm sure England would have won the cup each time, and scottland wouldbe free. ;-)

                            The Text-Effects thing sound interessting to me.
                            • 11. Re: Dynamicly loaded fonts
                              neil manuell Level 1
                              sorry panell, as I stated earlier, I placed loads of intentional errors in the code to fox you.
                              this should work - I actually tested it.
                              If it doesn't check linkage names and path names
                              • 12. Re: Dynamicly loaded fonts
                                neil manuell Level 1
                                > and scottland wouldbe free. ;-)
                                and wales too
                                • 13. Re: Dynamicly loaded fonts
                                  panell Level 1
                                  quote:

                                  Originally posted by: 2m
                                  I'm tempted to say, that if you have tried both so fast, it's no wonder - but I won't.

                                  For which solution do you otp?


                                  Please take look at 'the fleece' solution. I did this:
                                  Fla Files
                                  • 14. Re: Dynamicly loaded fonts
                                    neil manuell Level 1
                                    panell, looked at your fla
                                    you need to edit the linkage properties of the font abduction,
                                    it doesn't have any at the moment.
                                    right click on the library font, and choose linkage...
                                    click Export for action script and make sure the Identifier is myFont
                                    • 15. Re: Dynamicly loaded fonts
                                      2m Level 2
                                      And in addition to that take care that you font format properties and or font symbol prpberties are set to bold and italic, as your font has both those attributes. (Could work without, but I'd go for the save way.)
                                      • 16. Re: Dynamicly loaded fonts
                                        neil manuell Level 1
                                        and there was still a mistake in the main code,
                                        I will send you update...
                                        • 17. Dynamicly loaded fonts
                                          neil manuell Level 1
                                          here you go, all working
                                          loadFont.rar

                                          have taken out the bold and italic props as 2m suggested, as unless you have a bould italic vertion of the font it may not work
                                          have a look at the code, and make sure you understand how it works the way it does,
                                          also have a look at the font settings of the embedded font.
                                          remember it must contain a linkage, other wise it is not exported.
                                          • 18. Re: Dynamicly loaded fonts
                                            panell Level 1
                                            quote:

                                            Originally posted by: the fleece
                                            here you go, all working
                                            loadFont.rar


                                            THX but link is broken ;/

                                            • 20. Re: Dynamicly loaded fonts
                                              panell Level 1
                                              quote:

                                              Originally posted by: the fleece
                                              try:
                                              http://www.blue-edge.co.uk/neil/test/LoadFont.rar

                                              Thanks A Lot Man !!!
                                              Jupi :) :) :)