PostScriptSurface

The PostScript surface is used to render cairo graphics to Adobe PostScript files and is a multi-page vector surface backend.

Constructors

this
this(cairo_surface_t* cairo_surface)

Sets our main struct and passes it to the parent class

Members

Functions

dscBeginPageSetup
void dscBeginPageSetup()

This function indicates that subsequent calls to cairo_ps_surface_dsc_comment() should direct comments to the PageSetup section of the PostScript output. This function call is only needed for the first page of a surface. It should be called after any call to cairo_ps_surface_dsc_begin_setup() and before any drawing is performed to the surface. See cairo_ps_surface_dsc_comment() for more details. Since 1.2

dscBeginSetup
void dscBeginSetup()

This function indicates that subsequent calls to cairo_ps_surface_dsc_comment() should direct comments to the Setup section of the PostScript output. This function should be called at most once per surface, and must be called before any call to cairo_ps_surface_dsc_begin_page_setup() and before any drawing is performed to the surface. See cairo_ps_surface_dsc_comment() for more details. Since 1.2

dscComment
void dscComment(string comment)

Emit a comment into the PostScript output for the given surface. The comment is expected to conform to the PostScript Language Document Structuring Conventions (DSC). Please see that manual for details on the available comments and their meanings. In particular, the %%IncludeFeature comment allows a device-independent means of controlling printer device features. So the PostScript Printer Description Files Specification will also be a useful reference. The comment string must begin with a percent character (%) and the total length of the string (including any initial percent characters) must not exceed 255 characters. Violating either of these conditions will place surface into an error state. But beyond these two conditions, this function will not enforce conformance of the comment with any particular specification. The comment string should not have a trailing newline. The DSC specifies different sections in which particular comments can appear. This function provides for comments to be emitted within three sections: the header, the Setup section, and the PageSetup section. Comments appearing in the first two sections apply to the entire document while comments in the BeginPageSetup section apply only to a single page. For comments to appear in the header section, this function should be called after the surface is created, but before a call to cairo_ps_surface_dsc_begin_setup(). For comments to appear in the Setup section, this function should be called after a call to cairo_ps_surface_dsc_begin_setup() but before a call to cairo_ps_surface_dsc_begin_page_setup(). For comments to appear in the PageSetup section, this function should be called after a call to cairo_ps_surface_dsc_begin_page_setup(). Note that it is only necessary to call cairo_ps_surface_dsc_begin_page_setup() for the first page of any surface. After a call to cairo_show_page() or cairo_copy_page() comments are unambiguously directed to the PageSetup section of the current page. But it doesn't hurt to call this function at the beginning of every page as that consistency may make the calling code simpler. As a final note, cairo automatically generates several comments on its own. As such, applications must not manually generate any of Since 1.2

getEps
cairo_bool_t getEps()

Check whether the PostScript surface will output Encapsulated PostScript. Since 1.6

getPostScriptSurfaceStruct
cairo_surface_t* getPostScriptSurfaceStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

restrictToLevel
void restrictToLevel(cairo_ps_level_t level)

Restricts the generated PostSript file to level. See cairo_ps_get_levels() for a list of available level values that can be used here. This function should only be called before any drawing operations have been performed on the given surface. The simplest way to do this is to call this function immediately after creating the surface. Since 1.6

setEps
void setEps(cairo_bool_t eps)

If eps is TRUE, the PostScript surface will output Encapsulated PostScript. This function should only be called before any drawing operations have been performed on the current page. The simplest way to do this is to call this function immediately after creating the surface. An Encapsulated PostScript file should never contain more than one page. Since 1.6

setSize
void setSize(double widthInPoints, double heightInPoints)

Changes the size of a PostScript surface for the current (and subsequent) pages. This function should only be called before any drawing operations have been performed on the current page. The simplest way to do this is to call this function immediately after creating the surface or immediately after completing a page with either cairo_show_page() or cairo_copy_page(). Since 1.2

Static functions

create
PostScriptSurface create(string filename, double widthInPoints, double heightInPoints)

Creates a PostScript surface of the specified size in points to be written to filename. See cairo_ps_surface_create_for_stream() for a more flexible mechanism for handling the PostScript output than simply writing it to a named file. Note that the size of individual pages of the PostScript output can vary. See cairo_ps_surface_set_size(). Since 1.2

createForStream
PostScriptSurface createForStream(cairo_write_func_t writeFunc, void* closure, double widthInPoints, double heightInPoints)

Creates a PostScript surface of the specified size in points to be written incrementally to the stream represented by write_func and closure. See cairo_ps_surface_create() for a more convenient way to simply direct the PostScript output to a named file. Note that the size of individual pages of the PostScript output can vary. See cairo_ps_surface_set_size(). Since 1.2

getLevels
void getLevels(cairo_ps_level_t[] levels)

Used to retrieve the list of supported levels. See cairo_ps_surface_restrict_to_level(). Since 1.6

levelToString
string levelToString(cairo_ps_level_t level)

Get the string representation of the given level id. This function will return NULL if level id isn't valid. See cairo_ps_get_levels() for a way to get the list of valid level ids. Since 1.6

Variables

cairo_surface
cairo_surface_t* cairo_surface;

the main Gtk struct

Inherited Members

From Surface

cairo_surface
cairo_surface_t* cairo_surface;

the main Gtk struct

getSurfaceStruct
cairo_surface_t* getSurfaceStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

getMimeData
void getMimeData(string mimeType, ubyte[] data)

Return mime data previously attached to surface using the specified mime type. If no data has been attached with the given mime type, data is set NULL. Since 1.10

createSimilar
Surface createSimilar(cairo_content_t content, int width, int height)

Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same fallback resolution and font options as other. Generally, the new surface will also use the same backend as other, unless that is not possible for some reason. The type of the returned surface may be examined with cairo_surface_get_type(). Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.) Use cairo_surface_create_similar_image() if you need an image surface which can be painted quickly to the target surface. Since 1.0

createSimilarImage
Surface createSimilarImage(cairo_format_t format, int width, int height)

Create a new image surface that is as compatible as possible for uploading to and the use in conjunction with an existing surface. However, this surface can still be used like any normal image surface. Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.) Use cairo_surface_create_similar() if you don't need an image surface. Since 1.12

createForRectangle
Surface createForRectangle(double x, double y, double width, double height)

Create a new surface that is a rectangle within the target surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is drawn onto the target surface, making this a useful method for passing constrained child surfaces to library routines that draw directly onto the parent surface, i.e. with no further backend allocations, double buffering or copies. Note The semantics of subsurfaces have not been finalized yet unless the rectangle is in full device units, is contained within the extents of the target surface, and the target or subsurface's device transforms are not changed. Since 1.10

reference
Surface reference()

Increases the reference count on surface by one. This prevents surface from being destroyed until a matching call to cairo_surface_destroy() is made. The number of references to a cairo_surface_t can be get using cairo_surface_get_reference_count(). Since 1.0

destroy
void destroy()

Decreases the reference count on surface by one. If the result is zero, then surface and all associated resources are freed. See cairo_surface_reference(). Since 1.0

status
cairo_status_t status()

Checks whether an error has previously occurred for this surface. Since 1.0

finish
void finish()

This function finishes the surface and drops all references to external resources. For example, for the Xlib backend it means that cairo will no longer access the drawable, which can be freed. After calling cairo_surface_finish() the only valid operations on a surface are getting and setting user, referencing and destroying, and flushing and finishing it. Further drawing to the surface will not affect the surface but will instead trigger a CAIRO_STATUS_SURFACE_FINISHED error. When the last call to cairo_surface_destroy() decreases the reference count to zero, cairo will call cairo_surface_finish() if it hasn't been called already, before freeing the resources associated with the surface. Since 1.0

flush
void flush()

Do any pending drawing for the surface and also restore any temporary modifications cairo has made to the surface's state. This function must be called before switching from drawing on the surface with cairo to drawing on it directly with native APIs. If the surface doesn't support direct access, then this function does nothing. Since 1.0

getDevice
Device getDevice()

This function returns the device for a surface. See cairo_device_t. Since 1.10

getFontOptions
void getFontOptions(FontOption options)

Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with cairo_scaled_font_create(). Since 1.0

getContent
cairo_content_t getContent()

This function returns the content type of surface which indicates whether the surface contains color and/or alpha information. See cairo_content_t. Since 1.2

markDirty
void markDirty()

Tells cairo that drawing has been done to surface using means other than cairo, and that cairo should reread any cached areas. Note that you must call cairo_surface_flush() before doing such drawing. Since 1.0

markDirtyRectangle
void markDirtyRectangle(int x, int y, int width, int height)

Like cairo_surface_mark_dirty(), but drawing has been done only to the specified rectangle, so that cairo can retain cached contents for other parts of the surface. Any cached clip set on the surface will be reset by this function, to make sure that future cairo calls have the clip set that they expect. Since 1.0

setDeviceOffset
void setDeviceOffset(double xOffset, double yOffset)

Sets an offset that is added to the device coordinates determined by the CTM when drawing to surface. One use case for this function is when we want to create a cairo_surface_t that redirects drawing for a portion of an onscreen surface to an offscreen surface in a way that is completely invisible to the user of the cairo API. Setting a transformation via cairo_translate() isn't sufficient to do this, since functions like cairo_device_to_user() will expose the hidden offset. Note that the offset affects drawing to the surface as well as using the surface in a source pattern. Since 1.0

getDeviceOffset
void getDeviceOffset(double xOffset, double yOffset)

This function returns the previous device offset set by cairo_surface_set_device_offset(). Since 1.2

setFallbackResolution
void setFallbackResolution(double xPixelsPerInch, double yPixelsPerInch)

Set the horizontal and vertical resolution for image fallbacks. When certain operations aren't supported natively by a backend, cairo will fallback by rendering operations to an image and then overlaying that image onto the output. For backends that are natively vector-oriented, this function can be used to set the resolution used for these image fallbacks, (larger values will result in more detailed images, but also larger file sizes). Some examples of natively vector-oriented backends are the ps, pdf, and svg backends. For backends that are natively raster-oriented, image fallbacks are still possible, but they are always performed at the native device resolution. So this function has no effect on those backends. Note: The fallback resolution only takes effect at the time of completing a page (with cairo_show_page() or cairo_copy_page()) so there is currently no way to have more than one fallback resolution in effect on a single page. The default fallback resoultion is 300 pixels per inch in both dimensions. Since 1.2

getFallbackResolution
void getFallbackResolution(double xPixelsPerInch, double yPixelsPerInch)

This function returns the previous fallback resolution set by cairo_surface_set_fallback_resolution(), or default fallback resolution if never set. Since 1.8

getType
cairo_surface_type_t getType()

This function returns the type of the backend used to create a surface. See cairo_surface_type_t for available types. Since 1.2

getReferenceCount
uint getReferenceCount()

Returns the current reference count of surface. Since 1.4

setUserData
cairo_status_t setUserData(cairo_user_data_key_t* key, void* userData, cairo_destroy_func_t destroy)

Attach user data to surface. To remove user data from a surface, call this function with the key that was used to set it and NULL for data. Since 1.0

getUserData
void* getUserData(cairo_user_data_key_t* key)

Return user data previously attached to surface using the specified key. If no user data has been attached with the given key this function returns NULL. Since 1.0

copyPage
void copyPage()

Emits the current page for backends that support multiple pages, but doesn't clear it, so that the contents of the current page will be retained for the next page. Use cairo_surface_show_page() if you want to get an empty page after the emission. There is a convenience function for this that takes a cairo_t, namely cairo_copy_page(). Since 1.6

showPage
void showPage()

Emits and clears the current page for backends that support multiple pages. Use cairo_surface_copy_page() if you don't want to clear the page. There is a convenience function for this that takes a cairo_t, namely cairo_show_page(). Since 1.6

hasShowTextGlyphs
cairo_bool_t hasShowTextGlyphs()

Returns whether the surface supports sophisticated cairo_show_text_glyphs() operations. That is, whether it actually uses the provided text and cluster data to a cairo_show_text_glyphs() call. Note: Even if this function returns FALSE, a cairo_show_text_glyphs() operation targeted at surface will still succeed. It just will act like a cairo_show_glyphs() operation. Users can use this function to avoid computing UTF-8 text and cluster mapping if the target surface does not use it. Since 1.8

setMimeData
cairo_status_t setMimeData(string mimeType, ubyte[] data, cairo_destroy_func_t destroy, void* closure)

Attach an image in the format mime_type to surface. To remove the data from a surface, call this function with same mime type and NULL for data. The attached image (or filename) data can later be used by backends which support it (currently: PDF, PS, SVG and Win32 Printing surfaces) to emit this data instead of making a snapshot of the surface. This approach tends to be faster and requires less memory and disk space. The recognized MIME types are the following: CAIRO_MIME_TYPE_JPEG, CAIRO_MIME_TYPE_PNG, CAIRO_MIME_TYPE_JP2, CAIRO_MIME_TYPE_URI. See corresponding backend surface docs for details about which MIME types it can handle. Caution: the associated MIME data will be discarded if you draw on the surface afterwards. Use this function with care. Since 1.10

supportsMimeType
cairo_bool_t supportsMimeType(string mimeType)

Return whether surface supports mime_type. Since 1.12

mapToImage
Surface mapToImage(cairo_rectangle_int_t extents)

Returns an image surface that is the most efficient mechanism for modifying the backing store of the target surface. The region retrieved may be limited to the extents or NULL for the whole surface Note, the use of the original surface as a target or source whilst it is mapped is undefined. The result of mapping the surface multiple times is undefined. Calling cairo_surface_destroy() or cairo_surface_finish() on the resulting image surface results in undefined behavior. Since 1.12

unmapImage
void unmapImage(Surface image)

Unmaps the image surface as returned from #cairo_surface_map_to_image(). The content of the image will be uploaded to the target surface. Afterwards, the image is destroyed. Using an image surface which wasn't returned by cairo_surface_map_to_image() results in undefined behavior. Since 1.12

Meta