pyhanko.pdf_utils.font.basic module
- class pyhanko.pdf_utils.font.basic.SimpleFontEngine(writer, name, avg_width)
Bases:
pyhanko.pdf_utils.font.api.FontEngine
Simplistic font engine that effectively only works with PDF standard fonts, and does not care about font metrics. Best used with monospaced fonts such as Courier.
- property uses_complex_positioning
If
True
, this font engine expects the line matrix to always be equal to the text matrix when exiting and enteringshape()
. In other words, the current text position is where0 0 Td
would move to.If
False
, this method does not use any text positioning operators, and therefore uses the PDF standard’s ‘natural’ positioning rules for text showing operators.The default is
True
unless overridden.
- shape(txt) pyhanko.pdf_utils.font.api.ShapeResult
Render a string to a format suitable for inclusion in a content stream and measure its total cursor advancement vector in em units.
- Parameters
txt – String to shape.
- Returns
A shaping result.
- as_resource()
Convert a
FontEngine
to a PDF object suitable for embedding inside a resource dictionary.Note
If the PDF object is an indirect reference, the caller must not attempt to dereference it. In other words, implementations can use preallocated references to delay subsetting until the last possible moment (this is even encouraged, see
prepare_write()
).- Returns
A PDF dictionary.
- class pyhanko.pdf_utils.font.basic.SimpleFontEngineFactory(name, avg_width)
Bases:
pyhanko.pdf_utils.font.api.FontEngineFactory
- create_font_engine(writer: pyhanko.pdf_utils.writer.BasePdfFileWriter, obj_stream=None)
- static default_factory()
- Returns
A
FontEngineFactory
instance representing the Courier standard font.