familyName = Font.DIALOG_INPUT;
return FontFamily.get_GenericSansSerif();
}
try{
if(false) throw new cli.System.ArgumentException();
return new FontFamily(name);
}catch(cli.System.ArgumentException ex){
// continue
}
//now we want map specific Name to a shorter Family Name like "Arial Bold" --> "Arial"
String shortName = name;
int spaceIdx = shortName.lastIndexOf(' ');
while(spaceIdx > 0){
shortName = shortName.substring(0, spaceIdx).trim();
try{
if(false) throw new cli.System.ArgumentException();
return new FontFamily(shortName);
}catch(cli.System.ArgumentException ex){
// continue
}
spaceIdx = shortName.lastIndexOf(' ');
}
//now we want map generic names to specific families like "courier" --> "Courier New"
FontFamily[] fontFanilies = FontFamily.get_Families();
name = name.toLowerCase();
for (int i = 0; i < fontFanilies.length; i++) {
FontFamily fontFamily = fontFanilies[i];
if(fontFamily.get_Name().toLowerCase().startsWith(name)){
return fontFamily;
}
}
//we have not find a valid font, we use the default font