Types & Enums

Value types and enumerations shared across the loom pipeline, plus a few shared, pipeline-agnostic types used everywhere colors/positions appear.

Shared Geometry & Color

docraft::Position is aliased directly as docraft::loom::nodes::Position (see Node Tree — Base & Text) so loom nodes, the cursor, and backend rendering interfaces all share one point type.

struct Position

2D point/position in document space (origin top-left, y grows downward).

Shared across the cursor, backend rendering interfaces, and the loom node tree (loom’s own loom::nodes::Position is an alias to this type).

Public Functions

std::string to_string() const

Returns a string representation of the point.

Returns:

String in a human-readable format.

Public Members

float x = 0.0F
float y = 0.0F

DocraftColor

Color helper supporting named colors, RGB components, hex codes, and template expressions (${variable}/${data("field")}).

class DocraftColor

Color helper that supports named, RGB, and hex representations.

Public Functions

explicit DocraftColor(ColorName name = ColorName::kBlack)

Creates a color from a known name.

Parameters:

name – Named color.

explicit DocraftColor(float r, float g, float b, float a = 1.0F)

Creates a color from RGBA components.

Parameters:
  • r – Red in [0,1].

  • g – Green in [0,1].

  • b – Blue in [0,1].

  • a – Alpha in [0,1].

explicit DocraftColor(const std::string &hex_code)

Creates a color from a hex code (#RRGGBB or #RRGGBBAA).

Parameters:

hex_code – Hex string.

~DocraftColor() = default

Destructor.

RGB toRGB() const

Returns the RGBA representation.

Returns:

RGBA components.

ColorName toColorName() const

Returns the named color (if available).

Returns:

ColorName enum value.

Public Static Functions

static DocraftColor fromColorName(ColorName name)

Creates a DocraftColor from a named color.

Parameters:

name – Named color.

Returns:

DocraftColor instance.

static DocraftColor fromRGB(float r, float g, float b, float a = 1.0F)

Creates a DocraftColor from RGBA components.

Parameters:
  • r – Red in [0,1].

  • g – Green in [0,1].

  • b – Blue in [0,1].

  • a – Alpha in [0,1].

Returns:

DocraftColor instance.

struct RGB

RGBA color with components in the [0,1] range.

Public Functions

inline std::string to_hex() const

Converts the RGBA color to a hex string #RRGGBBAA.

Returns:

Hex string in #RRGGBBAA format.

Public Members

float r = 0.0F
float g = 0.0F
float b = 0.0F
float a = 1.0F
enum class docraft::ColorName

Named colors supported by the library.

Values:

enumerator kBlack
enumerator kWhite
enumerator kRed
enumerator kGreen
enumerator kBlue
enumerator kYellow
enumerator kMagenta
enumerator kCyan
enumerator kPurple

DocraftDocumentMetadata

Metadata container for PDF document info-dict fields (author, title, dates, etc.), applied via DocraftLoomPdfCreator::set_metadata() (see Orchestrator). Includes the nested DateTime struct for creation/ modification dates — richer than what the .craft <Metadata> block currently wires up (see Document Metadata).

class DocraftDocumentMetadata

Metadata container for PDF document information.

Supports all document info fields exposed by libharu (string attributes plus creation and modification dates).

Public Functions

void set_author(const std::string &author)
void set_creator(const std::string &creator)
void set_producer(const std::string &producer)
void set_title(const std::string &title)
void set_subject(const std::string &subject)
void set_keywords(const std::string &keywords)
void set_trapped(const std::string &trapped)
void set_gts_pdfx(const std::string &gts_pdfx)
void set_creation_date(const DateTime &creation_date)
void set_modification_date(const DateTime &modification_date)
void clear_author()
void clear_creator()
void clear_producer()
void clear_title()
void clear_subject()
void clear_keywords()
void clear_trapped()
void clear_gts_pdfx()
void clear_creation_date()
void clear_modification_date()
const std::optional<std::string> &author() const
const std::optional<std::string> &creator() const
const std::optional<std::string> &producer() const
const std::optional<std::string> &title() const
const std::optional<std::string> &subject() const
const std::optional<std::string> &keywords() const
const std::optional<std::string> &trapped() const
const std::optional<std::string> &gts_pdfx() const
const std::optional<DateTime> &creation_date() const
const std::optional<DateTime> &modification_date() const
struct DateTime

Date/time structure compatible with libharu info dates.

Public Members

int year = 0
int month = 0
int day = 0
int hour = 0
int minutes = 0
int seconds = 0
char ind = '+'
int off_hour = 0
int off_minutes = 0

Loom Node Enums

DocraftPositionType is documented alongside DocraftLoomNode in Node Tree — Base & Text (it’s set via position_mode()).

enum class docraft::loom::nodes::TextAlignment

Text alignment options.

Values:

enumerator kLeft
enumerator kCenter
enumerator kRight
enumerator kJustified
enum class docraft::loom::nodes::ImageFormat

Raster image formats loom can draw.

Values:

enumerator kPng
enumerator kJpeg
enumerator kRaw
enum class docraft::loom::nodes::ListKind

Values:

enumerator kOrdered
enumerator kUnordered
enum class docraft::loom::nodes::OrderedListStyle

Values:

enumerator kNumber
enumerator kRoman
enum class docraft::loom::nodes::UnorderedListDot

Values:

enumerator kDash
enumerator kStar
enumerator kCircle
enumerator kBox

Backend/Page Enums

enum class docraft::backend::DocraftPageSize

Supported page sizes.

Values:

enumerator kA3
enumerator kA4
enumerator kA5
enumerator kLetter
enumerator kLegal
enum class docraft::backend::DocraftPageOrientation

Page orientation.

Values:

enumerator kPortrait
enumerator kLandscape