Another success – Problem with using embedded font fixed

As reported in this post, I was having problems with using embedded font in the <mx:Linkbar> object. Have a look at the code below to see what I had to change to get it to work (changes are in bold).

Here is the snippet for font embedding from as file -

[Bindable]
[Embed(source='include/fonts/Speedline.ttf',
       fontName='GalleryFont',
       fontStyle='normal',
       fontWeight='normal',
       mimeType='application/x-font')]
// You do not use this variable directly. It exists so that
// the compiler will link in the font.
public var embeddedFont:Class;

Here is the snippet of the style sheet -

.headerLinkBar {
    fontFamily:         GalleryFont;
    fontSize:           18;
    fontWeight:         normal;
    fontStyle:          normal;
    fontThickness:      0;

    colour:             #808080;
    textRollOverColor:  #FFFFFF;
    rollOverColor:      #262626;
    selectionColor:     #262626;
    separatorColor:     #FFFFFF;
}

.headerLinkBarButton {
	fontFamily: 	GalleryFont;
	fontWeight:	normal;
	fontStyle:	normal;
}

And here is the snippet from the MXML file -

<mx:LinkBar id="headerLinkBarThumbsView"
            styleName="headerLinkBar"
            linkButtonStyleName="headerLinkBarButton">
    <mx:dataProvider>
        <mx:Array>
            <mx:String>Arrange</mx:String>
            <mx:String>Stack</mx:String>
            <mx:String>Randomise</mx:String>
            <mx:String>Back</mx:String>
        </mx:Array>
    </mx:dataProvider>
</mx:LinkBar>

It looks like specifying the style in ‘styleName’ attribute of <mx:Linkbar> element is not enough in Flex 3.2 (it used to work in Flex 2). Specifying the style for the link bar button in ‘linkButtonStyleName’ does the trick. Hopefully someone will find this useful.

Without wax,
yOOrek

Tags: , ,

Tuesday, November 25th, 2008 Flex SDK, Flex2, Flex3

8 Comments to Another success – Problem with using embedded font fixed

  1. It’s nearly 4am on a Saturday night, and I’ve been going utterly insane with this issue for hours.

    THANK YOU THANK YOU!!!! :- ) — very helpful!

  2. ty on December 6th, 2008
  3. I’m glad that my blog was of some help to you. Thanks for kind comment.

  4. yOOrek on December 8th, 2008
  5. ah yes, I spent more than 3 hours on this.
    Changing and customising… linkbar was the only element to display other text than the embedded font

    regarding the css solution, specifying just
    font-weight: normal;
    seems to be enough. (for both the linkbar and linkbuttons)

    i kept on specifying the normal font weight but the linkbar was displaying in bold, and with standard text.

    thanks for the solution. this was a real bugger…

  6. radu on April 15th, 2009
  7. Hi !! Is it possible for you to share the code of Prototype Photo gallery?

    That would be very helpful to me.. :)

    Thanks in advance..

  8. Sai Prasad on June 9th, 2009
  9. @Sai Prasad: I’m glad that you see some value in the gallery that I developed. Unfortunately I am somewhat reluctant to share this code as I want to turn this gallery into a product that I might eventually sell. At the moment I’am occupied with something else but plan on returning to developing this further in not so distant future.

    yOOrek

  10. yOOrek on June 9th, 2009
  11. @Yoorek : I agree that this could turn into a good product. All the best for your product.

    Just in case you have changed your mind, please let me know. :)

  12. Sai Prasad on June 11th, 2009
  13. Thank you man! I know that’s the old problem, but i’ve spent 6 hours in order to solve it.

  14. Igor Russo on August 19th, 2010
  15. This trick does not work for me :(

  16. George Garcha on April 5th, 2011

Leave a comment