Appcelerator Android 自定义字体不工作

Appcelerator Android Custom Fonts not working

我正在为 android 应用程序使用自定义字体。但看起来它在 SDK 5.2.2

的 classicJs 应用程序中不起作用

我尝试制作一个新的测试项目来测试字体,但它在测试项目中也不起作用。我主要使用 GothamBookGothamBold。但它看起来也不适用于其他字体。例如 SpicyRice-Regular

我正在使用 Appcelerator Studiobuild: 4.5.0.201602170821 和最新的 SDK 5.2.2.GA。你可以查看测试应用 here.

显然这是一个微不足道的错误。包含所有字体文件的文件夹名称应命名为 'fonts' 而不是 'font'.

我注意到的另一件事是,如果您使用非 alloy (classicJs) 方法,则包含所有应用程序代码和资产的文件夹名称应命名为 'Resources' 而不是 'resources' .. :)

Custom fonts are a quick and easy way to personalize or brand your application. Titanium Mobile supports TrueType and OpenType fonts on both iOS and Android. There are some differences between how fonts are referenced on iOS and Android that need to be considered.

Android expects fontFamily to be the font's file name without the file extension (.otf or .tff). iOS expects fontFamily to be the font's PostScript name (see Finding a font's PostScript name). This name is embedded in the font file and does not change if you rename the file.

For example, in the following code the file name of the Burnstown Dam font is "burnstown_dam.otf". For an Android application you therefore assign the value burnstown_dam to fontFamily:

"#burnstowndam": { 
  font: {
      fontFamily: 'burnstown_dam'
  }
}

Burnstown Dam 的 PostScript 名称是 BurnstownDam-Regular,因此对于 iOS 应用程序,您将该值分配给 fontFamily:

"#burnstowndam": { 
  font: {
      fontFamily: 'BurnstownDam-Regular'
  }
}

http://docs.appcelerator.com/platform/latest/#!/guide/Custom_Fonts