我有.otf和.ttf格式的字体。我想在我的Apple News文章中使用它,但我一直收到错误Error: Custom font (postscript name=CustomFontName) not available.
我知道JSON是正确的,因为如果我使用标准字体它会起作用。我已将该字体包含在与article.json相同的文件夹中,但除此之外,我无法找到有关如何执行此操作的任何文档。
答案 0 :(得分:2)
我在Apple新闻格式指南中没有提到自定义字体。它在docs中说明:
fontName:要应用的字体的PostScript名称,例如GillSans-Bold。您 可以按名称引用任何字体。有关可用字体的列表,请参阅iOSfonts.com。
字体新闻支持除旧金山以外的所有iOS系统字体 随iOS 9推出。
最初让我相信隐含自定义字体不起作用,但试验我认为我的假设是错误的格式。
复制字体的PostScript名称(请参阅OS X字体手册中的信息面板)并将字体放在与article.json
文件相同的文件夹中。但请确保您是否要强调包含相关的斜体或粗体变体。
我使用的字体是开放式类型from Google Fonts。您可以从该链接中获取确切的内容。我在我的文件夹中包含了Roman和Italic变体,并通过在Component Text Styles中调用它“IM_FELL_DW_Pica_Roman”(即段落样式)来引用该字体。当我然后应用markdown来识别斜体文本时,它会自动找到斜体变体。我不需要单独引用斜体版本(即在inline text styles内)。
这是我的代码:
{
"version": "1.1",
"identifier": "sketchyTech_Demo",
"title": "My First Article",
"language": "en",
"layout": {},
"components": [{
"role": "title",
"text": "My First Article",
"textStyle": "titleStyle",
"inlineTextStyles": [{
"rangeStart": 3,
"rangeLength": 5,
"textStyle": "redText"
}]
}, {
"role": "body",
"format": "markdown",
"text": "This is just over the minimum amount of _JSON_ required to create a valid article in Apple News Format. If you were to delete the dictionary enclosing this text, you'd be there.",
"textStyle": "bodyStyle"
}],
"componentTextStyles": {
"titleStyle": {
"textAlignment": "center",
"fontName": "HelveticaNeue-Bold",
"fontSize": 64,
"lineHeight": 74,
"textColor": "#000"
},
"bodyStyle": {
"textAlignment": "left",
"fontName": "IM_FELL_DW_Pica_Roman",
"fontSize": 18,
"lineHeight": 26,
"textColor": "#000"
}
},
"textStyles": {
"redText": {
"textColor": "#FF00007F"
}
}
}
(注意:尝试以无声方式添加粗体,因为相关字体不可用,因此会以斜体显示。)
我要说的最后一点是,自定义字体的使用似乎没有记录,尽管它有效。因此,不一定是这种情况(除非您在其他地方看到确认)Apple会在您上传时接受使用自定义字体。