ComposeCanvas

class ComposeCanvas(drawScope: DrawScope, textMeasurer: TextMeasurer, hairlineWidthPx: Float = 1.0f, skipSystemFontText: Boolean = false) : KiteCanvas

KiteCanvas backed by a Compose Multiplatform DrawScope.

Three rendering paths:

  • Embedded outlines: when hasOutlines is true, each byte/CID becomes a Compose Path filled at the right position.

  • System-font fallback: when no outlines are available, decode to text and hand to Compose's TextMeasurer.

  • Transparency groups: open a saveLayer on the underlying Canvas when the renderer requests one; later restore composites the layer back with the requested blend mode + alpha.

Clipping uses Compose's clipPath inside a recursive scope; transparency groups use the lower-level Canvas.saveLayer so they can span multiple DrawScope operations.

Constructors

Link copied to clipboard
constructor(drawScope: DrawScope, textMeasurer: TextMeasurer, hairlineWidthPx: Float = 1.0f, skipSystemFontText: Boolean = false)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: Rectangle, maskCtm: Matrix, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)

Soft-mask compositing (ISO 32000-1 §11.6.5). We open a saveLayer for the content, render it, then over-paint the mask group with ComposeBlendMode.DstIn so the mask's alpha clips the content.

Link copied to clipboard
open override fun beginPage(widthPt: Double, heightPt: Double, deviceCtm: Matrix)
Link copied to clipboard
open override fun beginTransparencyGroup(bbox: Rectangle, ctm: Matrix, isolated: Boolean, knockout: Boolean, alpha: Double, blendMode: BlendMode)

Transparency groups: open a Compose saveLayer on the active Canvas with a Paint that carries the requested alpha + blend mode. Subsequent draws accumulate into the offscreen layer; matching endTransparencyGroup calls restore, which composites the layer onto the parent.

Link copied to clipboard
open override fun drawGlyphs(glyphs: List<TextGlyph>, fontSize: Double, unitsPerEm: Int, hasOutlines: Boolean, fontSpec: FontSpec, textToDevice: Matrix, color: RgbColor, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun drawImage(image: ImageXObject, ctm: Matrix, alpha: Double)
Link copied to clipboard
open override fun endPage()
Link copied to clipboard
open override fun endTransparencyGroup()
Link copied to clipboard
open override fun fillPath(path: KitePath, ctm: Matrix, color: RgbColor, evenOdd: Boolean, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun fillShading(shading: KiteShading, ctm: Matrix, clipPath: KitePath?, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun popClip()
Link copied to clipboard
open override fun pushClip(path: KitePath, ctm: Matrix, evenOdd: Boolean)
Link copied to clipboard
open override fun strokePath(path: KitePath, ctm: Matrix, color: RgbColor, lineWidth: Double, alpha: Double, blendMode: BlendMode, dashArray: List<Double>?, dashPhase: Double, lineCap: Int, lineJoin: Int, miterLimit: Double)