Search code examples
apache-flexflashactionscript-3

Flex Embedding Hindi Fonts Problem


For the attached code, I get the following compile time error : exception during transcoding: Font for alias 'myFontFamily' with bold weight and italic style was not found by family name 'Kundli Hindi Normal'

I have installed other Hindi fonts, and I get the same error for them as well.

Though I don't get any error for standard fonts such as Arial, Helvetica and even "Microsoft Himalaya"

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Button x="96" y="102" label="Button"/>
        <mx:Style>
     @font-face {
    src:local("Kundli Hindi Normal");
    fontFamily: myFontFamily;
    advancedAntiAliasing: false;
    font-weight:bold;
    font-style:italic;
}

     Button {
        fontFamily: myFontFamily; 
        fontSize: 18pt;
     }
     HBox {
        fontFamily: Times; 
        fontSize: 18pt;
     }

  </mx:Style>


</mx:Application>

Solution

  • I just downloaded the Kundli Hindi font and all I got was a 'normal' font face - no bold or italic. Obviously, we may have gotten the font from different places, and you may have additional font faces, but you have to have separate bold and italic font faces in order to embed a font with bold and italic properties.

    Also, the font I downloaded is named 'Kundli Hindi NormalA'.... don't know why it was named 'NormalA', rather than just 'Normal', or 'Regular'. You might double-check to make sure yours is in fact named 'Kundli Hindi Normal', if you haven't already. That doesn't seem to be the problem, but it never hurts to re-check that kind of stuff. At least for me :).

    If you can't get ahold of a bold font face for this font - from my own searching on Google, it looks like it's not available - you can use ActionScript's advanced font features to create bold and semi-bold versions of a font. I don't have any helpful advice for faking italicization, though.

    The following is an example of using an embedded font (Myriad Pro), and modifying its weight via the subpixel style:

    .roomViewTitleRoomType
    {
        color: "0x8AA1A8"; 
        font-size: 20;
        fontFamily: "Myriad Pro";
        fontAntiAliasType: "advanced";
        fontThickness: 200;
        fontGridFitType: "subpixel";
    }
    

    You might want to declare a font face with the advanced font manipulation (fontAntiAliasType, fontThickness, fontGridFitType) in it, like the following, but the additional info will just be ignored.

    @font-face
    {
        src: url("/assets/fonts/kundli.ttf");
        fontFamily: "Kundli Hindi Heavy";
        fontWeight: "normal";
        fontAntiAliasType: "advanced";
        fontThickness: 800;
        fontGridFitType: "subpixel";
    }
    

    Hope that's helpful.