---
name: "Defoma::Font"
section: "3pm"
platform: "linux"
package: "defoma"
version: "0.11.11"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Defoma::Font"
---

# Defoma::Font(3pm)

Defoma module to handle font and font-cache.

## NAME

Defoma::Font - Defoma module to handle font and font-cache.

## SYNOPSIS

use Defoma::Font;

defoma\_font\_register( *category*, *font*, *hints...* );

defoma\_font\_unregister( *category*, *font* );

defoma\_font\_reregister( *category*, *font*, *hints...* );

defoma\_font\_if\_register( *category*, *font* );

@fonts = defoma\_font\_get\_fonts( *category* );

@hints = defoma\_font\_get\_hints( *category*, *font* );

%failedapps = defoma\_font\_get\_failed ( *category*, *font* );

## DESCRIPTION

Defoma::Font is a Defoma module to handle registration/unregistration of fonts and font-caches. It provides functions listed above which are  supposed to be called from Defoma-configuration scripts when the scripts  want to register/unregister a font, and need to retrieve the data recorded  in a font-cache, which holds fonts and their hints.

**defoma\_font\_register** is a function used to register a specified *font* into a specified *category* with specified  *hints*. If the specified font is already registered, it returns non-zero. Otherwise the font and the hints are registered into the font-cache of the specified category, and further Defoma-configuration  scripts get called which accept the specified category with register  command.

**defoma\_font\_unregister** is a function used to unregister a specified *font* from a specified *category*. If the font is not registered in the category, it returns non-zero. Otherwise further Defoma-configuration scripts get called which accept the specified category with unregister command, and the font and the hints are removed from the font-cache of the category.

**defoma\_font\_reregister** is a function which actually calls  *defoma\_font\_unregister* and *defoma\_font\_register* in order. If a specified *font* if not registered in a specified *category*, unregisteration is skipped. If the font is already registered in another category, it returns non-zero.

**defoma\_font\_if\_register** if a function that checks if a specified *font* is registered in a specified *category*. If the font is registered, it returns non-zero. Otherwise it returns zero.

**defoma\_font\_get\_fonts** is a function used to obtain a list of fonts reigstered in the specified *category*. It returns a list of fonts in an array. (font1 font2 font3 ...)

**defoma\_font\_get\_hints** is a function used to obtain hints of the specified *font* registered in the specified *category*. It returns a list of hints in an array.

**defoma\_font\_get\_failed** is a function used to obtain applications for which Defoma failed to  configure the specified *font*. It returns a hash whose keys are applications and whose values are error status.

## EXAMPLES

1\. Register 'Helvetica-Bold' in postscript category with hints.

```
$font = 'Helvetica-Bold';
@hints = ('--Family', 'Helvetica', '--Weight', 'Bold',
          '--Charset', 'ISO8859-1);
defoma_font_register('postscript', $font, @hints);
```

2\. Unregister 'foo.pfa' from type1 category.

```
$font = '/usr/share/fonts/foo.pfa';
defoma_font_unregister('type1', $font);
```

3\. Unregister 'foo.pfa' from type1 category if registered.

```
$font = '/usr/share/fonts/foo.pfa';
if (defoma_font_if_register('type1', $font)) {
  defoma_font_unregister('type1', $font);
}
```

4\. Get a list of fonts and their hints.

```
%hash = ();
@fonts = defoma_font_get_fonts('x-postscript');
foreach $font (@fonts) {
  $hash{$font} = [];
  @{$hash{$font}} = defoma_font_get_hints('x-postscript', $font);
}
```
