brown.interface.app_interface

classes

The primary interface to the application state.

This holds much of the global state for interacting with the API, and must be created (and create_document() must be called) before working with the API.

Remove all fonts registered with register_font().

This is primarily useful for testing purposes.

__init__ (document) permalink view source

overriden from Interface

arguments:

document (Document):

methods

show () permalink view source

Open a window showing a preview of the document.

render_pdf (pages, path) permalink view source

Render the document to a pdf file.

arguments:

pages (iter[int]): The page numbers to render

path (str): An output file path.

warning:

If the file at path already exists, it will be overwritten.

render_image (rect, image_path, dpm, quality, bg_color, autocrop) permalink view source

Render a section of self.scene to an image.

arguments:

rect (Rect): The part of the document to render, in document coordinates.

image_path (str): The path to the output image. This must be a valid path relative to the current working directory.

dpm (int): The pixels per meter of the rendered image.

quality (int): The quality of the output image for compressed image formats. Must be either -1 (default compression) or between 0 (most compressed) and 100 (least compressed).

bg_color (Color): The background color for the image.

autocrop (bool): Whether or not to crop the output image to tightly fit the contents of the frame. If true, the image will be cropped such that all 4 edges have at least one pixel not of bg_color.

returns:

None

It is assumed that all input arguments are valid.

destroy () permalink view source

Destroy the window and all global interface-level data.

register_font (font_file_path) permalink view source

Register a font file with the graphics engine.

arguments:

font_file_path (str): A path to a font file. The path should be relative to the main brown package. Currently only TrueType and OpenType fonts are supported.

returns:

None