lglBarcode

lglBarcode — Barcode structure

Functions

Types and Values

Includes

#include <libglbarcode/lgl-barcode.h>

Description

This section describes the lglBarcode structure and the lglBarcodeShape family of simple drawing primitives. These structures form the basic intermediate barcode representation used by libglbarcode. The section also defines a set of functions for constructing an lglBarcode structure and populating it with drawing primitives.

Functions

lgl_barcode_new ()

lglBarcode *
lgl_barcode_new (void);

Allocate a new lglBarcode structure.

This function allocates a new lglBarcode structure.

This function is intended to be used internally by barcode implementations. Typically an end-user would use lgl_barcode_create() instead.

Returns

A newly allocated lglBarcode structure. Use lgl_barcode_free() to free it.


lgl_barcode_free ()

void
lgl_barcode_free (lglBarcode *bc);

Free a previously allocated lglBarcode structure.

Parameters

bc

The lglBarcode structure to free

 

lgl_barcode_add_line ()

void
lgl_barcode_add_line (lglBarcode *bc,
                      gdouble x,
                      gdouble y,
                      gdouble length,
                      gdouble width);

Add a vertical line to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of top of line

 

y

y coordinate of top of line

 

length

Length of line

 

width

Width of line

 

lgl_barcode_add_box ()

void
lgl_barcode_add_box (lglBarcode *bc,
                     gdouble x,
                     gdouble y,
                     gdouble width,
                     gdouble height);

Add a box to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of top left corner of box

 

y

y coordinate of top left corner of box

 

width

Width of box

 

height

Height of box

 

lgl_barcode_add_char ()

void
lgl_barcode_add_char (lglBarcode *bc,
                      gdouble x,
                      gdouble y,
                      gdouble fsize,
                      gchar c);

Add an ASCII character to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of left baseline of character

 

y

y coordinate of left baseline of character

 

fsize

Font size

 

c

Character to add

 

lgl_barcode_add_string ()

void
lgl_barcode_add_string (lglBarcode *bc,
                        gdouble x,
                        gdouble y,
                        gdouble fsize,
                        gchar *string,
                        gsize length);

Add a character string to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of horizontal center of baseline of string

 

y

y coordinate of horizontal center of baseline of string

 

fsize

Font size

 

string

String to add

 

length

Number of bytes in string

 

lgl_barcode_add_ring ()

void
lgl_barcode_add_ring (lglBarcode *bc,
                      gdouble x,
                      gdouble y,
                      gdouble radius,
                      gdouble line_width);

Add a ring to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of center of circle

 

y

y coordinate of center of circle

 

radius

Radius of ring (center of line)

 

line_width

Width of line

 

lgl_barcode_add_hexagon ()

void
lgl_barcode_add_hexagon (lglBarcode *bc,
                         gdouble x,
                         gdouble y,
                         gdouble height);

Add a regular hexagon (oriented with vertexes at top and bottom) to barcode. Coordinates are relative to top left corner of barcode. All units are in points ( 1 point = 1/72 inch ).

This function is intended to be used internally by barcode implementations.

Parameters

bc

An lglBarcode structure

 

x

x coordinate of top point of hexagon

 

y

y coordinate of top point of hexagon

 

height

Height of hexagon

 

Types and Values

lglBarcode

typedef struct {
        gdouble  width;
        gdouble  height;

        GList   *shapes;    /* List of lglBarcodeShape drawing primitives */
} lglBarcode;

This structure contains the libglbarcode intermediate barcode format. This structure contains a simple vectorized representation of the barcode. This vectorized representation is easy to interpret by a rendering backend for either vector or raster formats. A simple API is provided for constructing barcodes in this format.

Members

gdouble width;

Width of barcode bounding box (points)

 

gdouble height;

Height of barcode bounding box (points)

 

GList *shapes;

List of lglBarcodeShape drawing primitives

 

enum lglBarcodeShapeType

Members

LGL_BARCODE_SHAPE_LINE

   

LGL_BARCODE_SHAPE_BOX

   

LGL_BARCODE_SHAPE_CHAR

   

LGL_BARCODE_SHAPE_STRING

   

LGL_BARCODE_SHAPE_RING

   

LGL_BARCODE_SHAPE_HEXAGON

   

lglBarcodeShape


lglBarcodeShapeAny

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type;
        gdouble              x;
        gdouble              y;
        /* End Common Fields */
} lglBarcodeShapeAny;


lglBarcodeShapeLine

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_LINE. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              length;
        gdouble              width;
} lglBarcodeShapeLine;

A vertical line drawing primitive.


@ =  origin (x,y) from top left corner of barcode

             +--@--+
             |     |
             |     |
             |     |
             |     | length
             |     |
             |     |
             |     |
             +-----+
              width

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_LINE

 

gdouble x;

x coordinate of top of line

 

gdouble y;

y coordinate of top of line

 

gdouble length;

Length of line

 

gdouble width;

Width of line

 

lglBarcodeShapeBox

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_BOX. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              width;
        gdouble              height;
} lglBarcodeShapeBox;

A solid box drawing primitive.


@ =  origin (x,y) from top left corner of barcode

             @---------+
             |         |
             |         |
             |         |
             |         | height
             |         |
             |         |
             |         |
             +---------+
                width

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_BOX

 

gdouble x;

x coordinate of top left corner of box

 

gdouble y;

y coordinate of top left corner of box

 

gdouble width;

Width of box

 

gdouble height;

Height of box

 

lglBarcodeShapeChar

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_CHAR. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              fsize;
        gchar                c;
} lglBarcodeShapeChar;

An single byte character drawing primitive.


@ =  origin (x,y) from top left corner of barcode

             ____ ------------
            /    \           ^
           /  /\  \          |
          /  /__\  \         |
         /  ______  \        | ~fsize
        /  /      \  \       |
       /__/        \__\      |
                             v
      @ ----------------------

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_CHAR

 

gdouble x;

x coordinate of left baseline of character

 

gdouble y;

y coordinate of left baseline of character

 

gdouble fsize;

Font size

 

gchar c;

Character to add

 

lglBarcodeShapeString

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_STRING. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              fsize;
        gchar               *string;
} lglBarcodeShapeString;

A character string drawing primitive.


@ =  origin (x,y) from top left corner of barcode

             ____        _  ------------------
            /    \      | |                  ^
           /  /\  \     | |                  |
          /  /__\  \    | |___     ____      |
         /  ______  \   | ._  \   /  __|     | ~fsize
        /  /      \  \  | |_)  | |  (__      |
       /__/        \__\ |_.___/   \____|     |
                                             v
                          @ ------------------
                          x = horizontal center

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_STRING

 

gdouble x;

x coordinate of horizontal center of baseline of string

 

gdouble y;

y coordinate of horizontal center of baseline of string

 

gdouble fsize;

Font size

 

gchar *string;

String to add

 

lglBarcodeShapeRing

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_RING. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              radius;
        gdouble              line_width;
} lglBarcodeShapeRing;

A ring (an open circle) drawing primitive.


@ = origin (x,y) is centre of circle

               v  line_width
          _.-""""-._
        .'   ____   `.
       /   .'  ^ `.   \
      |   /        \   |
      |   |    @---|---|------
      |   \        /   |     ^
       \   `.____.'   /      | radius
        `._    ...._.'.......|
           `-....-'

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_RING

 

gdouble x;

x coordinate of center of circle

 

gdouble y;

y coordinate of center of circle

 

gdouble radius;

Radius of ring (center of line)

 

gdouble line_width;

Width of line

 

lglBarcodeShapeHexagon

typedef struct {
        /* Begin Common Fields */
        lglBarcodeShapeType  type; /* Always LGL_BARCODE_SHAPE_HEXAGON. */
        gdouble              x;
        gdouble              y;
        /* End Common Fields */

        gdouble              height;
} lglBarcodeShapeHexagon;

A solid regular hexagon (oriented with vertexes at top and bottom) drawing primitive.


@ = origin (x,y) is top of hexagon

                 @ ------------------
             _-"   "-_              ^
         _-"           "-_          |
      +"                   "+       |
      |                     |       |
      |                     |       |
      |                     |       | height
      |                     |       |
      |                     |       |
      +_                   _+       |
        "-_             _-"         |
           "-_       _-"            |
              "-_ _-"               v
                 " ------------------

All units are in points ( 1 point = 1/72 inch ).

Members

lglBarcodeShapeType type;

Always LGL_BARCODE_SHAPE_HEXAGON

 

gdouble x;

x coordinate of top point of hexagon

 

gdouble y;

y coordinate of top point of hexagon

 

gdouble height;

Height of hexagon