View Source Idmlx.StyleCreator.CharacterStyleCreator (idmlx v0.2.1)

Module responsible for creating Character Style XML blocks for InDesign IDML documents.

This module provides functions to create and customize character styles with attributes such as font, size, color, and various text decorations.

Summary

Functions

Applies the style options to the base attributes map.

Creates a new character style with the given name and options.

Creates an inner Properties element containing font and other complex properties.

Formats a character style element with potential inner Properties element.

Functions

apply_style_options(attrs, options)

Applies the style options to the base attributes map.

create(name, options \\ %{})

Creates a new character style with the given name and options.

Options

  • :font - Font name to use (string)
  • :font_style - Font style such as "Regular", "Bold", "Italic", etc. (string)
  • :point_size - Text size in points (number)
  • :fill_color - Text color name or RGB/CMYK values
  • :tracking - Letter spacing (number)
  • :capitalization - Text case transformation, e.g., "Normal", "AllCaps", "SmallCaps" (string)
  • :underline - Whether text is underlined (boolean)
  • :strike_thru - Whether text has strikethrough (boolean)
  • :position - Text position, e.g., "Normal", "Superscript", "Subscript" (string)
  • :imported - Whether the style is imported (boolean)
  • :style_unique_id - Unique ID for the style (string, generated if not provided)
  • Any other attributes defined in the CharacterStyle attributes schema

Examples

iex> Idmlx.StyleCreator.CharacterStyleCreator.create("Heading", %{
...>   font: "Minion Pro",
...>   font_style: "Bold",
...>   point_size: 24,
...>   fill_color: "Black"
...> })

create_properties_element(options)

Creates an inner Properties element containing font and other complex properties.

This is needed for some attributes that can't be represented as simple string attributes.

format_style_with_properties(style_element, options)

Formats a character style element with potential inner Properties element.