## FoDoc

FoDoc — Abstract output document type

## Synopsis

                        FoDoc;
                        FoDocClass;
    #define             FO_DOC_ERROR
    GQuark              fo_doc_error_quark                  (void);
    enum                FoDocError;
    enum                FoDocLineCap;
    enum                FoDocLineJoin;

    FoDoc*              fo_doc_new                          (void);
    FoDoc*              fo_doc_new_from_type                (const gchar *type);
    FoFlagsFormat       fo_doc_formats_from_name            (const gchar *name);

    void                fo_doc_open_file                    (FoDoc *fo_doc,
                                                             const gchar *filename,
                                                             FoLibfoContext *libfo_context,
                                                             GError **error);
    FoLayout*           fo_doc_get_new_layout               (FoDoc *fo_doc);
    const gchar*        fo_doc_get_language                 (FoDoc *fo_doc);
    void                fo_doc_set_language                 (FoDoc *fo_doc,
                                                             const gchar *language);
    FoEnumAreaDirection fo_doc_get_base_dir                 (FoDoc *fo_doc);
    void                fo_doc_set_base_dir                 (FoDoc *fo_doc,
                                                             FoEnumAreaDirection base_dir);

## Description

FoDoc provides the primitives for writing text, lines, rectangles, etc., to the output.

It is generalised so that libfo can support multiple backend implementations (and add and remove backend implementations) without having to restructure the rest of libfo.

## Details

### FoDoc

    typedef struct _FoDoc FoDoc;

### FoDocClass

    typedef struct _FoDocClass FoDocClass;

### FO_DOC_ERROR

    #define FO_DOC_ERROR fo_doc_error_quark ()

### fo_doc_error_quark ()

    GQuark              fo_doc_error_quark                  (void);

Get the error quark for FoDoc.

If the quark does not yet exist, create it.

Returns : | Quark associated with FoDoc errors.

### enum FoDocError

    typedef enum
    {
      FO_DOC_ERROR_FAILED,
      FO_DOC_ERROR_OPEN_FAILED,	     /* Cannot open output document */
      FO_DOC_ERROR_UNSUPPORTED_FORMAT,   /* Unsupported document format */
      FO_DOC_ERROR_LAST
    } FoDocError;

### enum FoDocLineCap

    typedef enum
    {
      FO_DOC_LINE_CAP_INVALID,
      FO_DOC_LINE_CAP_BUTT,
      FO_DOC_LINE_CAP_ROUND,
      FO_DOC_LINE_CAP_SQUARE,
      FO_DOC_LINE_CAP_LIMIT
    } FoDocLineCap;

### enum FoDocLineJoin

    typedef enum
    {
      FO_DOC_LINE_JOIN_INVALID,
      FO_DOC_LINE_JOIN_MITER,
      FO_DOC_LINE_JOIN_ROUND,
      FO_DOC_LINE_JOIN_BEVEL,
      FO_DOC_LINE_JOIN_LIMIT
    } FoDocLineJoin;

### fo_doc_new ()

    FoDoc*              fo_doc_new                          (void);

Creates a new FoDoc.

Returns : | the newly created FoDoc.

### fo_doc_new_from_type ()

    FoDoc*              fo_doc_new_from_type                (const gchar *type);

Creates a new FoDoc.

`type` : | Type of the new FoDoc.
Returns : | the newly created FoDoc.

### fo_doc_formats_from_name ()

    FoFlagsFormat       fo_doc_formats_from_name            (const gchar *name);

Gets the output formats supported by `name` class.

`name` should not be NULL.

If `name` does not implement any formats, returns FO_FLAG_FORMAT_UNKNOWN.

`name` : | Registered FoObject type name, e.g., "FoDocCairo"
Returns : | FoFlagsFormat with zero or more bits set for the supported formats.

### fo_doc_open_file ()

    void                fo_doc_open_file                    (FoDoc *fo_doc,
                                                             const gchar *filename,
                                                             FoLibfoContext *libfo_context,
                                                             GError **error);

No reference to `libfo_context` is kept.

`fo_doc` : | FoDoc for which to open an output file.
`filename` : | Name of output file.
`libfo_context` : | FoLibfoContext containing extra info.
`error` : | Information about any error that occurred.

### fo_doc_get_new_layout ()

    FoLayout*           fo_doc_get_new_layout               (FoDoc *fo_doc);

Get a new FoLayout for use with `fo_doc`.

`fo_doc` : | FoDoc.
Returns : | New FoLayout.

### fo_doc_get_language ()

    const gchar*        fo_doc_get_language                 (FoDoc *fo_doc);

Get the language in `fo_doc`.

`fo_doc` : | FoDoc
Returns : | Language of file parsed to make `fo_doc`.

### fo_doc_set_language ()

    void                fo_doc_set_language                 (FoDoc *fo_doc,
                                                             const gchar *language);

Set the language in `fo_doc`.

`fo_doc` : | FoDoc.
`language` : | Language.

### fo_doc_get_base_dir ()

    FoEnumAreaDirection fo_doc_get_base_dir                 (FoDoc *fo_doc);

Get the FoEnumAreaDirection used as input to `fo_doc`.

`fo_doc` : | FoDoc.
Returns : | FoEnumAreaDirection used as input to `fo_doc`.

### fo_doc_set_base_dir ()

    void                fo_doc_set_base_dir                 (FoDoc *fo_doc,
                                                             FoEnumAreaDirection base_dir);

Set the FoEnumAreaDirection in `fo_doc`.

`fo_doc` : | FoDoc.
`base_dir` : | FoEnumAreaDirection value for new base direction.