title: Skia Font Styles
body: <p>I am using Skia to draw text on BlackBerry 10 platform.
  I have trouble applying Condensed or Light styles to the font.</p>
  
  <p>In Skia, it only has type enum for <strong><em>kNormal</em></strong>, <strong><em>kBold</em></strong>, <strong><em>kItalic</em></strong>, and <strong><em>kBoldItalic</em></strong> styles.</p>
  
  <p><em>These Styles Works Well</em></p>
  
  <pre><code>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);
  </code></pre>
  
  <p>But I need to use the <strong><em>Condensed</em></strong> or <strong><em>Light</em></strong> styles of the Slate Pro font which is also built in the BB10 device.</p>
  
  <p>I tried all those combination this and it caused a <strong><em>SIGSEGV</em></strong>.</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>Sooooo, I tried another approach by trying to load the system fonts directly. But still, even though the Font file exists, the loadedTypeface is always NULL, can't figure out why.</p>
  
  <pre><code>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);
       }
  }
  </code></pre>
  
  <p>Any thoughts on how to use the <strong><em>Condensed</em></strong> or <strong><em>Light</em></strong> styles of the font? Thank you</p>
  
  <p><em><strong>Notes</em></strong>
  The list of Slate Pro <strong><em>ttf files</em></strong> embeded <strong><em>in BB10 file system</em></strong></p>
  
  <p><em><strong>Located in</em></strong> <code>/usr/fonts/font_repository/monotype/</code></p>
  
  <pre><code>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
  </code></pre>