public Object loadNativeFont(String lookup){
  try {
    lookup=lookup.split(";")[0];
    int typeface=Typeface.NORMAL;
    String familyName=lookup.substring(0,lookup.indexOf("-"));
    String style=lookup.substring(lookup.indexOf("-") + 1,lookup.lastIndexOf("-"));
    String size=lookup.substring(lookup.lastIndexOf("-") + 1,lookup.length());
    if (style.equals("bolditalic")) {
      typeface=Typeface.BOLD_ITALIC;
    }
 else     if (style.equals("italic")) {
      typeface=Typeface.ITALIC;
    }
 else     if (style.equals("bold")) {
      typeface=Typeface.BOLD;
    }
    Paint font=new CodenameOneTextPaint(Typeface.create(familyName,typeface));
    font.setAntiAlias(true);
    font.setTextSize(Integer.parseInt(size));
    return new NativeFont(0,0,0,font);
  }
 catch (  Exception err) {
    return null;
  }
}

public Object loadNativeFont ( String lookup ) { try { lookup = lookup . split ( ";" ) [ 0 ] ; int typeface = Typeface . NORMAL ; String familyName = lookup . substring ( 0 , lookup . indexOf ( "-" ) ) ; String style = lookup . substring ( lookup . indexOf ( "-" ) + 1 , lookup . lastIndexOf ( "-" ) ) ; String size = lookup . substring ( lookup . lastIndexOf ( "-" ) + 1 , lookup . length ( ) ) ; if ( style . equals ( "bolditalic" ) ) { typeface = Typeface . BOLD_ITALIC ; } else if ( style . equals ( "italic" ) ) { typeface = Typeface . ITALIC ; } else if ( style . equals ( "bold" ) ) { typeface = Typeface . BOLD ; } Paint font = new CodenameOneTextPaint ( Typeface . create ( familyName , typeface ) ) ; font . setAntiAlias ( true ) ; font . setTextSize ( Integer . parseInt ( size ) ) ; return new NativeFont ( 0 , 0 , 0 , font ) ; } catch ( Exception err ) { return null ; } }
loads a native font based on a lookup for a font name and attributes . font lookup values can be separated by commas and thus allow fallback if the primary font isn ' t supported by the platform .
