Some document types (such as EPUB) require the contents to be laid out before they can be rendered. This is done by calling fz_layout_document:
Any non-reflowable document types (such as PDF) will ignore this layout request.
The results of the layout will depend both upon a target width and height, a given font size, and the CSS styles in effect. MuPDF has an inbuilt set of default CSS styles that will be used if a document does not provide its own. In addition, the user can provide a final set that will override any rules found in the default sets. In this way, the appearance of the rendered document can be changed (perhaps by changing document colours or font styles/sizes).
Documents can be laid out multiple times to allow changes in these properties to take effect.
MuPDF provides its own default CSS style sheet, but this can be overridden by the user CSS style sheet in the context:
The user CSS style sheet is supplied as a null terminated C string.
When the CSS or the screen size is changed, and the document relaid out, content moves. In order for applications to be able to not lose the readers place, MuPDF offers a mechanism for making a bookmark and then looking it up again after the content has been laid out to a new position.