Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsSVGLibartFreetype Namespace Reference

Functions

PRBool Init ()
 Initializes global ft2 and fontcatalog instances.
void Shutdown ()
 Releases global ft2 and fontcatalog instances.
PRBool HasSuitableFonts ()

Variables

nsCOMPtr< nsIFreeType2ft2
 Global freetype2 instance.
nsCOMPtr< nsIFontCatalogServicefontCatalog
 Global fontcatalog instance.

Function Documentation

Returns:
PR_TRUE if there are suitable fonts on the system, PR_FALSE otherwise

Definition at line 70 of file nsSVGLibartFreetype.cpp.

{
  NS_ASSERTION(fontCatalog, "freetype not initialized");
  
  nsCOMPtr<nsIArray> arr;
  nsCAutoString empty;
  fontCatalog->GetFontCatalogEntries(empty, empty,
                                     nsIFontCatalogService::kFCWeightAny,
                                     nsIFontCatalogService::kFCWidthAny,
                                     nsIFontCatalogService::kFCSlantAny,
                                     nsIFontCatalogService::kFCSpacingAny,
                                     getter_AddRefs(arr));
  PRUint32 count;
  arr->GetLength(&count);
#ifdef DEBUG
  {
    printf("Freetype Families available:\n");
    for (PRUint32 i=0;i<count;++i) {
      nsCOMPtr<nsITrueTypeFontCatalogEntry> font = do_QueryElementAt(arr, i);
      nsCAutoString family, style, vendor;
      font->GetFamilyName(family);
      font->GetStyleName(style);
      font->GetVendorID(vendor);
      printf("* %s, %s, %s\n", family.get(), style.get(), vendor.get());
    }    
  }
#endif
  return (count!=0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Initializes global ft2 and fontcatalog instances.

Returns:
PR_TRUE if the initialization succeeded, PR_FALSE otherwise.

Definition at line 47 of file nsSVGLibartFreetype.cpp.

{
  NS_ASSERTION(!ft2, "ft2 already initialized");
  ft2 = do_GetService(NS_FREETYPE2_CONTRACTID);
  if (!ft2) return PR_FALSE;
  
  fontCatalog = do_GetService("@mozilla.org/gfx/xfontcatalogservice;1");
  if (!fontCatalog) {
    NS_ERROR("Font catalog initialization failure");
    ft2 = nsnull;
    return PR_FALSE;
  }
  
  return PR_TRUE;
}

Here is the call graph for this function:

Releases global ft2 and fontcatalog instances.

Definition at line 63 of file nsSVGLibartFreetype.cpp.

{
  NS_ASSERTION(ft2, "ft2 never initialized");
  ft2 = nsnull;
  fontCatalog = nsnull;
}

Here is the caller graph for this function:


Variable Documentation

Global fontcatalog instance.

Definition at line 45 of file nsSVGLibartFreetype.cpp.

Global freetype2 instance.

Definition at line 44 of file nsSVGLibartFreetype.cpp.