printer

package
v0.3.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

package printer provides standard printer settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PageSizes

type PageSizes int32 //enums:enum

Sizes are standard physical drawing sizes

const (
	// Custom =  nonstandard
	Custom PageSizes = iota

	// Image 1280x720 Px = 720p
	Img1280x720

	// Image 1920x1080 Px = 1080p HD
	Img1920x1080

	// Image 3840x2160 Px = 4K
	Img3840x2160

	// Image 7680x4320 Px = 8K
	Img7680x4320

	// Image 1024x768 Px = XGA
	Img1024x768

	// Image 720x480 Px = DVD
	Img720x480

	// Image 640x480 Px = VGA
	Img640x480

	// Image 320x240 Px = old CRT
	Img320x240

	// A4 = 210 x 297 mm
	A4

	// USLetter = 8.5 x 11 in = 612 x 792 pt
	USLetter

	// USLegal = 8.5 x 14 in = 612 x 1008 pt
	USLegal

	// A0 = 841 x 1189 mm
	A0

	// A1 = 594 x 841 mm
	A1

	// A2 = 420 x 594 mm
	A2

	// A3 = 297 x 420 mm
	A3

	// A5 = 148 x 210 mm
	A5

	// A6 = 105 x 148 mm
	A6

	// A7 = 74 x 105
	A7

	// A8 = 52 x 74 mm
	A8

	// A9 = 37 x 52
	A9

	// A10 = 26 x 37
	A10
)
const PageSizesN PageSizes = 22

PageSizesN is the highest valid value for type PageSizes, plus one.

func DefaultPageSizeForRegion

func DefaultPageSizeForRegion(region string) PageSizes

DefaultPageSizeForRegion returns the default page size based on locale region value, per the https://www.rfc-editor.org/rfc/bcp/bcp47.txt standard. See system.Locale and system.App for how to get this.

func Match

func Match(un units.Units, wd, ht float32) PageSizes

Match returns a matching standard size for given units and dimension.

func PageSizesValues

func PageSizesValues() []PageSizes

PageSizesValues returns all possible values for the type PageSizes.

func (PageSizes) Desc

func (i PageSizes) Desc() string

Desc returns the description of the PageSizes value.

func (PageSizes) Int64

func (i PageSizes) Int64() int64

Int64 returns the PageSizes value as an int64.

func (PageSizes) MarshalText

func (i PageSizes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PageSizes) SetInt64

func (i *PageSizes) SetInt64(in int64)

SetInt64 sets the PageSizes value from an int64.

func (*PageSizes) SetString

func (i *PageSizes) SetString(s string) error

SetString sets the PageSizes value from its string representation, and returns an error if the string is invalid.

func (PageSizes) Size

func (s PageSizes) Size() (un units.Units, size math32.Vector2)

Size returns the corresponding size values and units.

func (PageSizes) String

func (i PageSizes) String() string

String returns the string representation of this PageSizes value.

func (*PageSizes) UnmarshalText

func (i *PageSizes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (PageSizes) Values

func (i PageSizes) Values() []enums.Enum

Values returns all possible values for the type PageSizes.

type SettingsData

type SettingsData struct {
	// PageSize specifies a standard page size, or Custom.
	PageSize PageSizes

	// Units are the units in which the page size is specified.
	// Will automatically be set if PageSize != Custom.
	Units units.Units

	// Size is the page size in given units.
	// Will automatically be set if PageSize != Custom.
	Size math32.Vector2

	// Margins specify the page margins in the size units.
	Margins sides.Floats `display:"inline"`

	// FontFamily specifies the font family to use for printing.
	// The default SansSerif font used on screen may not be desired
	// for printouts, where Serif is more typically used.
	FontFamily rich.Family

	// FontSize specifies the base font size to use for scaling printed
	// text output (i.e., the default Text font will be this size, with
	// larger elements scaled appropriately).
	FontSize units.Value

	// LineHeight is the default line height for standard text elements,
	// in proportion to the font size (e.g., 1.25), which determines the
	// spacing between lines.
	LineHeight float32
}

Settings has standard printer settings.

var Settings SettingsData

Settings provides the default printer settings. This is initialized by the system.App because it depends on the locale for initialization.

func (*SettingsData) Apply

func (ps *SettingsData) Apply()

func (*SettingsData) Defaults

func (ps *SettingsData) Defaults()

func (*SettingsData) Filename

func (ps *SettingsData) Filename() string

func (*SettingsData) FontScale

func (ps *SettingsData) FontScale() float32

FontScale returns the scaling factor based on FontSize, relative to the core default font size of 16 Dp.

func (*SettingsData) Label

func (ps *SettingsData) Label() string

func (*SettingsData) MakeToolbar

func (ps *SettingsData) MakeToolbar(p *tree.Plan)

func (*SettingsData) ToDots

func (ps *SettingsData) ToDots(un *units.Context) (size, body math32.Vector2, margins sides.Floats)

ToDots returns the measurement values in rendering dots (actual pixels) based on the given units context. size = page size; body = content area inside margins

func (*SettingsData) Update

func (ps *SettingsData) Update()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL