我正在使用Skia在BlackBerry 10平台上绘制文字。 我无法将Condensed或Light样式应用于字体。
在Skia中,它只有 kNormal 的类型枚举, kBold , kItalic 和 kBoldItalic 样式。
这些样式运作良好
skTypeface = SkTypeface::CreateFromName("Slate Pro", SkTypeface::kNormal);
skTypeface = SkTypeface::CreateFromName("Slate Pro", SkTypeface::kBold);
skTypeface = SkTypeface::CreateFromName("Slate Pro", SkTypeface::kItalic);
skTypeface = SkTypeface::CreateFromName("Slate Pro", SkTypeface::kBoldItalic);
但我需要使用Slate Pro字体的 Condensed 或 Light 样式在BB10设备中。
我尝试了所有这些组合,它导致 SIGSEGV 。
skTypeface = SkTypeface::CreateFromName("SlateProLight", SkTypeface::kNormal);
skTypeface = SkTypeface::CreateFromName("Slate Pro-Light", SkTypeface::kNormal);
skTypeface = SkTypeface::CreateFromName("Slate Pro - Light", SkTypeface::kNormal);
skTypeface = SkTypeface::CreateFromName("SlatePro Light", SkTypeface::kNormal);
skTypeface = SkTypeface::CreateFromName("Slate Pro Condensed", SkTypeface::kNormal);
Sooooo,我试图通过尝试直接加载系统字体来尝试另一种方法。但是,即使Font文件存在,loadedTypeface仍然是NULL,无法找出原因。
QString loadedFont="/usr/fonts/font_repository/monotype/SlatePro-Light.ttf";
SkTypeface *loadedTypeface = SkTypeface::CreateFromFile(loadedFont.toUtf8().constData());
QFile targetFile(loadedFont);
if(targetFile.exists())
{
if(loadedTypeface!=NULL)
{
skTypeface = SkTypeface::CreateFromTypeface(loadedTypeface , SkTypeface::kNormal);
}
else //Fallback to Arial
{
skTypeface = SkTypeface::CreateFromName("Arial",SkTypeface::kNormal);
}
}
有关如何使用字体的 简明 或 Light 样式的任何想法?谢谢
备注 的 Slate Pro列表 ttf文件 在BB10文件系统中嵌入
位于 /usr/fonts/font_repository/monotype/
SlatePro.ttf
SlatePro-MediumItalic.ttf
SlatePro-MediumCondensed.ttf
SlatePro-Medium.ttf
SlatePro-LightItalic.ttf
SlatePro-Light.ttf
SlatePro-Italic.ttf
SlatePro-Condensed.ttf
SlatePro-BoldItalic.ttf
SlatePro-BoldCondensed.ttf
SlatePro-Bold.ttf