title: Android font assets vs font resources (API 26)
body: <p>In order to use custom fonts in an android app there seem to be two approaches:</p>
  
  <ol>
  <li><strong>Classic way</strong>: place TTF or OTF files in the <code>/assets/fonts</code> directory and then build a <a href="https://developer.android.com/reference/android/graphics/Typeface" rel="noreferrer"><code>Typeface</code></a> with <a href="https://developer.android.com/reference/android/graphics/Typeface.html#createFromAsset(android.content.res.AssetManager,%20java.lang.String)" rel="noreferrer"><code>Typeface.createFromAsset(getAssets(), "fonts/custom.ttf")</code></a>.</li>
  <li><strong>Natively since API 26, or with AppCompat since API 16</strong>: <a href="https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml" rel="noreferrer">create an XML font family</a> by placing lowercased TTF/OTF files in <code>res/font</code> folder and then reference them directly in XML layouts with <code>android:fontFamily="@font/custom"</code>, or access them programatically with <a href="https://developer.android.com/reference/android/support/v4/content/res/ResourcesCompat.html#getFont(android.content.Context,%20int)" rel="noreferrer"><code>ResourcesCompat.getFont(this, R.font.custom)</code></a>.</li>
  </ol>
  
  <p>What are the key differences to keep in mind between font resources and assets? </p>
  
  <p>Specifically, are they rendered in the same way, and is any of them faster or more efficient in terms of performance?</p>
  
  <p>Can it be assumed that font resources are only suitable for fonts that come pre-packaged in the APK, while font assets are more flexible since you can create a Typeface from an arbitrary file inside or outside the APK?</p>
  
  <p><em>Update:</em>
  After a bit of experimentation it looks like font resources are the only way to set custom fonts in AppWidget <code>TextView</code>s without having to manually paint them as bitmaps but that requires the device to actually run API 26 (using the Support Library does not help in this specific case).</p>