cssunit

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cssunit tokenizes CSS/SVG length values into a numeric value and a unit suffix. It has no opinion on unit conversion — the html package converts to PDF points with its own policy, and the svg package treats every unit as an SVG user unit — so callers apply their own conversion after tokenizing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string) (value float64, unit string, ok bool)

Parse splits a CSS/SVG length into numeric value and unit. Recognized units: "px", "pt", "rem", "em", "mm", "cm", "in", "%". A bare number returns unit "". Exactly one unit suffix is consumed; leftover characters make the parse fail (ok=false).

func PointsPerUnit

func PointsPerUnit(unit string, fontSize float64) (factor float64, ok bool)

PointsPerUnit returns the multiplier converting one <unit> to PDF points at 96dpi CSS pixel density. fontSize is used for "em". Returns ok=false for "%" and "" (caller-specific policies).

Types

This section is empty.

Jump to

Keyboard shortcuts

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