## Fontconfig Utility Functions

Fontconfig Utility Functions — Fontconfig related utility functions

## Functions

GQuark | font_manager_fontconfig_error_quark ()
void | font_manager_clear_application_fonts ()
gboolean | font_manager_add_application_font ()
gboolean | font_manager_add_application_font_directory ()
gboolean | font_manager_update_font_configuration ()
GList * | font_manager_list_available_font_files ()
FontManagerStringSet * | font_manager_list_available_font_families ()
GList * | font_manager_get_langs_from_fontconfig_pattern ()
JsonObject * | font_manager_get_attributes_from_filepath ()
JsonObject * | font_manager_get_attributes_from_fontconfig_pattern ()
JsonObject * | font_manager_get_available_fonts ()
JsonObject * | font_manager_get_available_fonts_for_chars ()
JsonArray * | font_manager_sort_json_font_listing ()
const gchar * | font_manager_weight_to_string ()
gboolean | font_manager_weight_defined ()
const gchar * | font_manager_slant_to_string ()
const gchar * | font_manager_width_to_string ()
gboolean | font_manager_width_defined ()
const gchar * | font_manager_spacing_to_string ()
const gchar * | font_manager_subpixel_order_to_string ()
const gchar * | font_manager_hint_style_to_string ()
const gchar * | font_manager_lcd_filter_to_string ()

## Types and Values

enum | FontManagerFontconfigError
#define | FONT_MANAGER_FONTCONFIG_ERROR
enum | FontManagerWeight
#define | FONT_MANAGER_TYPE_WEIGHT
enum | FontManagerSlant
#define | FONT_MANAGER_TYPE_SLANT
enum | FontManagerWidth
#define | FONT_MANAGER_TYPE_WIDTH
enum | FontManagerSpacing
#define | FONT_MANAGER_TYPE_SPACING
enum | FontManagerSubpixelOrder
#define | FONT_MANAGER_TYPE_SUBPIXEL_ORDER
enum | FontManagerHintStyle
#define | FONT_MANAGER_TYPE_HINT_STYLE
enum | FontManagerLCDFilter
#define | FONT_MANAGER_TYPE_LCD_FILTER

## Object Hierarchy

        GEnum
        ├── FontManagerHintStyle
        ├── FontManagerLCDFilter
        ├── FontManagerSlant
        ├── FontManagerSpacing
        ├── FontManagerSubpixelOrder
        ├── FontManagerWeight
        ╰── FontManagerWidth

## Includes

    #include <font-manager-fontconfig.h>

## Description

## Functions

### font_manager_fontconfig_error_quark ()

    GQuark
    font_manager_fontconfig_error_quark ();

### font_manager_clear_application_fonts ()

    void
    font_manager_clear_application_fonts (void);

Equivalent to FcConfigAppFontClear

### font_manager_add_application_font ()

    gboolean
    font_manager_add_application_font (const gchar *filepath);

Equivalent to FcConfigAppFontAddFile

#### Parameters

filepath | full path to font file to add to configuration |

#### Returns

`TRUE` on success

### font_manager_add_application_font_directory ()

    gboolean
    font_manager_add_application_font_directory
                                   (const gchar *dir);

Equivalent to FcConfigAppFontAddDir

#### Parameters

dir | full path to directory to add to application specific configuration |

#### Returns

`TRUE` on success

### font_manager_update_font_configuration ()

    gboolean
    font_manager_update_font_configuration
                                   (void);

#### Returns

`TRUE` on success

### font_manager_list_available_font_files ()

    GList *
    font_manager_list_available_font_files
                                   (void);

#### Returns

a newly created GSList containing filepaths or `NULL`. Free the returned list using g_slist_free_full(list, g_free).

[element-type utf8][transfer full][nullable]

### font_manager_list_available_font_families ()

    FontManagerStringSet *
    font_manager_list_available_font_families
                                   (void);

#### Returns

a newly created FontManagerStringSet containing filepaths or `NULL`. Free the returned object using g_object_unref.

[transfer full][nullable]

### font_manager_get_langs_from_fontconfig_pattern ()

    GList *
    font_manager_get_langs_from_fontconfig_pattern
                                   (FcPattern *pattern);

Supplied FcPattern must contain an FcLangSet.

[skip]

#### Parameters

pattern | FcPattern to examine |

#### Returns

a newly created GSList or `NULL` The returned list contains dynamically allocated strings and should be freed using g_slist_free_full(slist, g_free) when no longer needed.

[element-type utf8][transfer full][nullable]

### font_manager_get_attributes_from_filepath ()

    JsonObject *
    font_manager_get_attributes_from_filepath
                                   (const gchar *filepath,
                                    GError **error);

See FontManagerFamily for a description of the JsonObject returned by this function.

#### Parameters

filepath | full path to font file to query |
error | GError or `NULL` to ignore errors |

#### Returns

A newly created JsonObject which should be freed using ``json_object_unref()`` when no longer needed or `NULL` if there was an error.

[transfer full]

### font_manager_get_attributes_from_fontconfig_pattern ()

    JsonObject *
    font_manager_get_attributes_from_fontconfig_pattern
                                   (FcPattern *pattern);

The supplied FcPattern must supply file and family information, otherwise this function will fail. It is also expected to contain index, style, slant, weight, width, language, character set and spacing information, however default values will be used if those fields are missing. All other fields are ignored.

See FontManagerFont for a description of the JsonObject returned by this function.

[skip]

#### Parameters

pattern | FcPattern to examine |

#### Returns

A newly created JsonObject which should be freed using ``json_object_unref()`` when no longer needed.

[transfer full]

### font_manager_get_available_fonts ()

    JsonObject *
    font_manager_get_available_fonts (const gchar *family_name);

If `family_name` is not `NULL`, only information for fonts belonging to specified family will be returned.

The returned JsonObject will have the following structure:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    {
      "family" : {
        "variation" : {
        "filepath" : string,
        "findex" : int,
        "family" : string,
        "style" : string,
        "spacing" : int,
        "slant" : int,
        "weight" : int,
        "width" : int,
        "description" : string,
        },
        ...
      },
      ...
    }

#### Parameters

family_name | family name or `NULL`. | [nullable]

#### Returns

A newly created JsonObject which should be freed using ``json_object_unref()`` when no longer needed.

[transfer full]

### font_manager_get_available_fonts_for_chars ()

    JsonObject *
    font_manager_get_available_fonts_for_chars
                                   (const gchar *chars);

See font_manager_get_available_fonts for a description of the JsonObject returned by this function.

The returned object will only contain those fonts which contain all the characters in `chars` .

#### Parameters

chars | string of characters to search for |

#### Returns

A newly created JsonObject which should be freed using ``json_object_unref()`` when no longer needed.

[transfer full]

### font_manager_sort_json_font_listing ()

    JsonArray *
    font_manager_sort_json_font_listing (JsonObject *json_obj);

The returned JsonArray has the following structure:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23

    [
      {
        "family" : string,
        "n_variations" : int,
        "variations" : [
          {
            "filepath" : string,
            "findex" : int,
            "family" : string,
            "style" : string,
            "spacing" : int,
            "slant" : int,
            "weight" : int,
            "width" : int,
            "description" : string,
          },
          ...
        ],
        "active" :   bool,
        "description" : string,
      },
      ...
    ]

#### Parameters

json_obj | JsonObject returned from font_manager_get_available_fonts* |

#### Returns

JsonArray.

[transfer full]

### font_manager_weight_to_string ()

    const gchar *
    font_manager_weight_to_string (FontManagerWeight weight);

#### Parameters

weight | FontManagerWeight |

#### Returns

`weight` as a string.

[transfer none][nullable]

### font_manager_weight_defined ()

    gboolean
    font_manager_weight_defined (FontManagerWeight weight);

#### Parameters

weight | FontManagerWeight |

#### Returns

`TRUE` if `weight` is valid.

### font_manager_slant_to_string ()

    const gchar *
    font_manager_slant_to_string (FontManagerSlant slant);

#### Parameters

slant | FontManagerSlant |

#### Returns

`slant` as a string.

[transfer none][nullable]

### font_manager_width_to_string ()

    const gchar *
    font_manager_width_to_string (FontManagerWidth width);

#### Parameters

width | FontManagerWidth |

#### Returns

`width` as a string.

[transfer none][nullable]

### font_manager_width_defined ()

    gboolean
    font_manager_width_defined (FontManagerWidth width);

#### Parameters

width | FontManagerWidth |

#### Returns

`TRUE` if `weight` is valid.

### font_manager_spacing_to_string ()

    const gchar *
    font_manager_spacing_to_string (FontManagerSpacing spacing);

#### Parameters

spacing | FontManagerSpacing |

#### Returns

`spacing` as a string.

[transfer none][nullable]

### font_manager_subpixel_order_to_string ()

    const gchar *
    font_manager_subpixel_order_to_string (FontManagerSubpixelOrder rgba);

#### Parameters

rgba | FontManagerSubpixelOrder |

#### Returns

`rgba` as a string.

[transfer none][nullable]

### font_manager_hint_style_to_string ()

    const gchar *
    font_manager_hint_style_to_string (FontManagerHintStyle hinting);

#### Parameters

hinting | FontManagerHintStyle |

#### Returns

`hinting` as a string.

[transfer none][nullable]

### font_manager_lcd_filter_to_string ()

    const gchar *
    font_manager_lcd_filter_to_string (FontManagerLCDFilter filter);

#### Parameters

filter | FontManagerLCDFilter |

#### Returns

`filter` as a string.

[transfer none][nullable]

## Types and Values

### enum FontManagerFontconfigError

#### Members

FONT_MANAGER_FONTCONFIG_ERROR_FAILED | Call to Fontconfig library failed |

### FONT_MANAGER_FONTCONFIG_ERROR

    #define FONT_MANAGER_FONTCONFIG_ERROR font_manager_fontconfig_error_quark()

### enum FontManagerWeight

These weight values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_WEIGHT_THIN | FC_WEIGHT_THIN |
FONT_MANAGER_WEIGHT_ULTRALIGHT | FC_WEIGHT_ULTRALIGHT |
FONT_MANAGER_WEIGHT_LIGHT | FC_WEIGHT_LIGHT |
FONT_MANAGER_WEIGHT_SEMILIGHT | FC_WEIGHT_SEMILIGHT |
FONT_MANAGER_WEIGHT_BOOK | FC_WEIGHT_BOOK |
FONT_MANAGER_WEIGHT_REGULAR | FC_WEIGHT_REGULAR |
FONT_MANAGER_WEIGHT_MEDIUM | FC_WEIGHT_MEDIUM |
FONT_MANAGER_WEIGHT_SEMIBOLD | FC_WEIGHT_SEMIBOLD |
FONT_MANAGER_WEIGHT_BOLD | FC_WEIGHT_BOLD |
FONT_MANAGER_WEIGHT_ULTRABOLD | FC_WEIGHT_ULTRABOLD |
FONT_MANAGER_WEIGHT_HEAVY | FC_WEIGHT_HEAVY |
FONT_MANAGER_WEIGHT_ULTRABLACK | FC_WEIGHT_ULTRABLACK |

### FONT_MANAGER_TYPE_WEIGHT

    #define FONT_MANAGER_TYPE_WEIGHT (font_manager_weight_get_type ())

### enum FontManagerSlant

These slant values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_SLANT_ROMAN | FC_SLANT_ROMAN |
FONT_MANAGER_SLANT_ITALIC | FC_SLANT_ITALIC |
FONT_MANAGER_SLANT_OBLIQUE | FC_SLANT_OBLIQUE |

### FONT_MANAGER_TYPE_SLANT

    #define FONT_MANAGER_TYPE_SLANT (font_manager_slant_get_type ())

### enum FontManagerWidth

These widths map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_WIDTH_ULTRACONDENSED | FC_WIDTH_ULTRACONDENSED |
FONT_MANAGER_WIDTH_EXTRACONDENSED | FC_WIDTH_EXTRACONDENSED |
FONT_MANAGER_WIDTH_CONDENSED | FC_WIDTH_CONDENSED |
FONT_MANAGER_WIDTH_SEMICONDENSED | FC_WIDTH_SEMICONDENSED |
FONT_MANAGER_WIDTH_NORMAL | FC_WIDTH_NORMAL |
FONT_MANAGER_WIDTH_SEMIEXPANDED | FC_WIDTH_SEMIEXPANDED |
FONT_MANAGER_WIDTH_EXPANDED | FC_WIDTH_EXPANDED |
FONT_MANAGER_WIDTH_EXTRAEXPANDED | FC_WIDTH_EXTRAEXPANDED |
FONT_MANAGER_WIDTH_ULTRAEXPANDED | FC_WIDTH_ULTRAEXPANDED |

### FONT_MANAGER_TYPE_WIDTH

    #define FONT_MANAGER_TYPE_WIDTH (font_manager_width_get_type ())

### enum FontManagerSpacing

These spacing values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_SPACING_PROPORTIONAL | FC_PROPORTIONAL |
FONT_MANAGER_SPACING_DUAL | FC_DUAL |
FONT_MANAGER_SPACING_MONO | FC_MONO |
FONT_MANAGER_SPACING_CHARCELL | FC_CHARCELL |

### FONT_MANAGER_TYPE_SPACING

    #define FONT_MANAGER_TYPE_SPACING (font_manager_spacing_get_type ())

### enum FontManagerSubpixelOrder

These rgba values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_SUBPIXEL_ORDER_UNKNOWN | FC_RGBA_UNKNOWN |
FONT_MANAGER_SUBPIXEL_ORDER_RGB | FC_RGBA_RGB |
FONT_MANAGER_SUBPIXEL_ORDER_BGR | FC_RGBA_BGR |
FONT_MANAGER_SUBPIXEL_ORDER_VRGB | FC_RGBA_VRGB |
FONT_MANAGER_SUBPIXEL_ORDER_VBGR | FC_RGBA_VBGR |
FONT_MANAGER_SUBPIXEL_ORDER_NONE | FC_RGBA_NONE |

### FONT_MANAGER_TYPE_SUBPIXEL_ORDER

    #define FONT_MANAGER_TYPE_SUBPIXEL_ORDER (font_manager_subpixel_order_get_type ())

### enum FontManagerHintStyle

These hinting values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_HINT_STYLE_NONE | FC_HINT_NONE |
FONT_MANAGER_HINT_STYLE_SLIGHT | FC_HINT_SLIGHT |
FONT_MANAGER_HINT_STYLE_MEDIUM | FC_HINT_MEDIUM |
FONT_MANAGER_HINT_STYLE_FULL | FC_HINT_FULL |

### FONT_MANAGER_TYPE_HINT_STYLE

    #define FONT_MANAGER_TYPE_HINT_STYLE (font_manager_hint_style_get_type ())

### enum FontManagerLCDFilter

These filter values map directly to those defined by Fontconfig.

#### Members

FONT_MANAGER_LCD_FILTER_NONE | FC_LCD_NONE |
FONT_MANAGER_LCD_FILTER_DEFAULT | FC_LCD_DEFAULT |
FONT_MANAGER_LCD_FILTER_LIGHT | FC_LCD_LIGHT |
FONT_MANAGER_LCD_FILTER_LEGACY | FC_LCD_LEGACY |

### FONT_MANAGER_TYPE_LCD_FILTER

    #define FONT_MANAGER_TYPE_LCD_FILTER (font_manager_lcd_filter_get_type ())

## See Also

FontManagerFont FontManagerFamily https://www.freedesktop.org/software/fontconfig/fontconfig-devel/