## Utility Functions

Utility Functions — General purpose utility functions

## Functions

void | font_manager_setup_i18n ()
void | font_manager_print_os_info ()
void | font_manager_print_library_versions ()
gint | font_manager_get_file_owner ()
gint | font_manager_natural_sort ()
gint | font_manager_timecmp ()
gboolean | font_manager_exists ()
gboolean | font_manager_is_dir ()
gboolean | font_manager_install_file ()
gchar * | font_manager_get_file_extension ()
gchar * | font_manager_get_local_time ()
gchar * | font_manager_get_user_font_directory ()
gchar * | font_manager_get_package_cache_directory ()
gchar * | font_manager_get_package_config_directory ()
gchar * | font_manager_get_user_fontconfig_directory ()
gchar * | font_manager_str_replace ()
gchar * | font_manager_to_filename ()
GSettings * | font_manager_get_gsettings ()
void | font_manager_free_gsettings ()
FontManagerStringSet * | font_manager_get_command_line_files ()

## Types and Values

#define | FONT_MANAGER_TMP_TMPL

## Includes

    #include <font-manager-utils.h>

## Description

## Functions

### font_manager_setup_i18n ()

    void
    font_manager_setup_i18n (void);

Initializes gettext translations

### font_manager_print_os_info ()

    void
    font_manager_print_os_info (void);

Print OS name and version.

### font_manager_print_library_versions ()

    void
    font_manager_print_library_versions (void);

Logs the versions of libraries in use for debugging purposes.

### font_manager_get_file_owner ()

    gint
    font_manager_get_file_owner (const gchar *filepath);

#### Parameters

filepath | full path to file |

#### Returns

0 if current user has read/write permissions, -1 otherwise

### font_manager_natural_sort ()

    gint
    font_manager_natural_sort (const gchar *str1,
                               const gchar *str2);

#### Parameters

str1 | a nul-terminated string |
str2 | a nul-terminated string |

#### Returns

An integer less than, equal to, or greater than zero, if str1 is <, == or > than str2 .

### font_manager_timecmp ()

    gint
    font_manager_timecmp (GFile *file_a,
                          GFile *file_b);

Compare the modification time of two different files.

#### Parameters

file_a | GFile |
file_b | GFile |

#### Returns

An integer less than, equal to, or greater than zero, if a is <, == or > than b.

### font_manager_exists ()

    gboolean
    font_manager_exists (const gchar *filepath);

#### Parameters

filepath | full path to file |

#### Returns

`TRUE` if `filepath` exists

### font_manager_is_dir ()

    gboolean
    font_manager_is_dir (const gchar *filepath);

#### Parameters

filepath | full path to file |

#### Returns

`TRUE` if `filepath` is a directory

### font_manager_install_file ()

    gboolean
    font_manager_install_file (GFile *file,
                               GFile *directory,
                               GError **error);

#### Parameters

file | GFile |
directory | GFile |
error | GError or `NULL` to ignore errors |

#### Returns

`TRUE` if installation was successful.

### font_manager_get_file_extension ()

    gchar *
    font_manager_get_file_extension (const gchar *filepath);

#### Parameters

filepath | full path to file |

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_get_local_time ()

    gchar *
    font_manager_get_local_time (void);

#### Returns

A newly allocated string formatted to the requested format or `NULL` if there was an error. The returned string must be freed using ``g_free()``.

[transfer full][nullable]

### font_manager_get_user_font_directory ()

    gchar *
    font_manager_get_user_font_directory (void);

This function attempts to create the directory if it doesn't already exist and returns the filepath as a string if successful.

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_get_package_cache_directory ()

    gchar *
    font_manager_get_package_cache_directory
                                   (void);

This function attempts to create the directory if it doesn't already exist and returns the filepath as a string if successful.

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_get_package_config_directory ()

    gchar *
    font_manager_get_package_config_directory
                                   (void);

This function attempts to create the directory if it doesn't already exist and returns the filepath as a string if successful.

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_get_user_fontconfig_directory ()

    gchar *
    font_manager_get_user_fontconfig_directory
                                   (void);

This function attempts to create the directory if it doesn't already exist and returns the filepath as a string if successful.

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_str_replace ()

    gchar *
    font_manager_str_replace (const gchar *str,
                              const gchar *target,
                              const gchar *replacement);

[skip]

#### Parameters

str | a nul-terminated string |
target | the nul-terminated string to search for |
replacement | the nul-terminated string to replace target with |

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_to_filename ()

    gchar *
    font_manager_to_filename (const gchar *str);

Replaces spaces and dashes with an underscore.

#### Parameters

str | a nul-terminated string |

#### Returns

A newly allocated string that must be freed with g_free or `NULL`.

[transfer full][nullable]

### font_manager_get_gsettings ()

    GSettings *
    font_manager_get_gsettings (const gchar *schema_id);

#### Parameters

schema_id | the id of the schema |

#### Returns

A newly created GSettings instance or `NULL` if schema_id could not be found.

[transfer full][nullable]

### font_manager_free_gsettings ()

    void
    font_manager_free_gsettings ();

Free stored gsettings

### font_manager_get_command_line_files ()

    FontManagerStringSet *
    font_manager_get_command_line_files (GApplicationCommandLine *cmdline);

#### Parameters

cmdline | GApplicationCommandLine |

#### Returns

FontManagerStringSet containing filepaths for each file specified in `cmdline` or `NULL` if no files were specified.

[transfer full]

## Types and Values

### FONT_MANAGER_TMP_TMPL

    #define FONT_MANAGER_TMP_TMPL "font-manager_XXXXXX"