Stores the standard PDF fonts registered in a document.
Each font is registered only once. Repeated uses of the same font reuse both its internal resource name and its indirect object reference.
Resource names are generated sequentially:
F1
F2
F3
Summary
Functions
Returns all registered fonts sorted by their resource identifier.
Fetches a registered font.
Fetches a registered font and raises when it does not exist.
Returns all registered font keys.
Creates an empty font registry.
Returns the resource name that will be assigned to the next new font.
Registers a built-in PDF font.
Returns whether a font has already been registered.
Creates a PDF /Font resource dictionary for selected fonts.
Types
@type t() :: %PaperForge.FontRegistry{ fonts: %{optional(atom()) => PaperForge.Font.t()}, next_resource_id: pos_integer() }
Functions
@spec all(t()) :: [PaperForge.Font.t()]
Returns all registered fonts sorted by their resource identifier.
@spec fetch(t(), atom()) :: {:ok, PaperForge.Font.t()} | :error
Fetches a registered font.
Returns {:ok, font} or :error.
@spec fetch!(t(), atom()) :: PaperForge.Font.t()
Fetches a registered font and raises when it does not exist.
Returns all registered font keys.
@spec new() :: t()
Creates an empty font registry.
Returns the resource name that will be assigned to the next new font.
@spec register( t(), atom(), PaperForge.Reference.t() ) :: {t(), PaperForge.Font.t()}
Registers a built-in PDF font.
The reference must point to the font dictionary previously added to the PDF document.
When the font already exists, the registry and existing font are returned unchanged.
Example
{registry, font} =
PaperForge.FontRegistry.register(
registry,
:helvetica_bold,
reference
)
font.resource_name
#=> "F1"
Returns whether a font has already been registered.
Creates a PDF /Font resource dictionary for selected fonts.
Example result
%{
"F1" => %PaperForge.Reference{
object_id: 3,
generation: 0
},
"F2" => %PaperForge.Reference{
object_id: 7,
generation: 0
}
}Duplicate font keys are ignored.