belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
FontsContractCompat
  public
  
  
  
  class
  FontsContractCompat
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.v4.provider.FontsContractCompat | 
Utility class to deal with Font ContentProviders.
Summary
Nested classes | |
|---|---|
        
        
        
        
        class | 
      
        FontsContractCompat.Columns
        Defines the constants used in a response from a Font Provider.  | 
    
        
        
        
        
        class | 
      
        FontsContractCompat.FontFamilyResult
        Object returned from   | 
    
        
        
        
        
        class | 
      
        FontsContractCompat.FontInfo
        Object represent a font entry in the family returned from   | 
    
        
        
        
        
        class | 
      
        FontsContractCompat.FontRequestCallback
        Interface used to receive asynchronously fetched typefaces.  | 
    
Public methods | |
|---|---|
        
        
        static
        
        
        Typeface
     | 
  
    
      
      buildTypeface(Context context, CancellationSignal cancellationSignal, FontInfo[] fonts)
      
      
        Build a Typeface from an array of   | 
  
        
        
        static
        
        
        FontsContractCompat.FontFamilyResult
     | 
  
    
      
      fetchFonts(Context context, CancellationSignal cancellationSignal, FontRequest request)
      
      
        Fetch fonts given a font request.  | 
  
        
        
        static
        
        
        void
     | 
  
    
      
      requestFont(Context context, FontRequest request, FontsContractCompat.FontRequestCallback callback, Handler handler)
      
      
        Create a typeface object given a font request.  | 
  
Inherited methods | |
|---|---|
  
    
  
    java.lang.Object
  
 | |
Public methods
buildTypeface
Typeface buildTypeface (Context context, CancellationSignal cancellationSignal, FontInfo[] fonts)
Build a Typeface from an array of FontsContractCompat.FontInfo
 Results that are marked as not ready will be skipped.
| Parameters | |
|---|---|
context | 
        
          Context: A Context that will be used to fetch the font contents. | 
      
cancellationSignal | 
        
          CancellationSignal: A signal to cancel the operation in progress, or null if none. If
                           the operation is canceled, then OperationCanceledException will be thrown. | 
      
fonts | 
        
          FontInfo: An array of FontsContractCompat.FontInfo to be used to create a Typeface. | 
      
| Returns | |
|---|---|
Typeface | 
        A Typeface object. Returns null if typeface creation fails. | 
fetchFonts
FontsContractCompat.FontFamilyResult fetchFonts (Context context, CancellationSignal cancellationSignal, FontRequest request)
Fetch fonts given a font request.
| Parameters | |
|---|---|
context | 
        
          Context: A Context to be used for fetching fonts. | 
      
cancellationSignal | 
        
          CancellationSignal: A signal to cancel the operation in progress, or null if none. If
                           the operation is canceled, then OperationCanceledException will be thrown when the
                           query is executed. | 
      
request | 
        
          FontRequest: A FontRequest object that identifies the provider and query for the
                request. | 
      
| Returns | |
|---|---|
FontsContractCompat.FontFamilyResult | 
        FontsContractCompat.FontFamilyResult | 
      
| Throws | |
|---|---|
 | 
          If requested package or authority was not found in the system. | 
PackageManager.NameNotFoundException | 
          |
requestFont
void requestFont (Context context, FontRequest request, FontsContractCompat.FontRequestCallback callback, Handler handler)
Create a typeface object given a font request. The font will be asynchronously fetched,
 therefore the result is delivered to the given callback. See FontRequest.
 Only one of the methods in callback will be invoked, depending on whether the request
 succeeds or fails. These calls will happen on the caller thread.
| Parameters | |
|---|---|
context | 
        
          Context: A context to be used for fetching from font provider. | 
      
request | 
        
          FontRequest: A FontRequest object that identifies the provider and query for the
                request. May not be null. | 
      
callback | 
        
          FontsContractCompat.FontRequestCallback: A callback that will be triggered when results are obtained. May not be null. | 
      
handler | 
        
          Handler: A handler to be processed the font fetching.
 | 
      
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.