Skip to content

Ported AndroidSilica to Silica's Renderer - #51

Merged
colemancda merged 7 commits into
masterfrom
feature/silica-renderer
Nov 25, 2026
Merged

colemancda merged 7 commits into
masterfrom
feature/silica-renderer

Conversation

@colemancda

Copy link
Copy Markdown
Member

Silica's master (PureSwift/Silica#27) replaced its CoreGraphics-style CGContext protocol with an idiomatic API, drawn through a Renderer protocol. AndroidSilica stopped building against it; this ports it.

  • AndroidCanvasContext becomes AndroidCanvasRenderer: Renderer, with init(pdf:size:), init(bitmap:scale:) and init(canvas:size:scale:).
    • The transform and the clip stay on the canvas's own save stack. The colors, stroke style, alpha, blend mode and shadow are applied to each paint.
    • Images now draw upright.
    • The text matrix's scale and rotation now apply to glyphs.
    • New: gradients (linear, and radial with one center), blend modes (as PorterDuff modes, so on any API level), clearing a rect, and bitmaps at a scale.
  • AndroidFontHandle is a FontFace. AndroidBackend gains makeBitmapRenderer(size:scale:).
  • The tests draw TestStyleKit through a GraphicsContext.
  • The Silica dependency turns off Silica's Cairo and Web traits, so this package no longer fetches Cairo, FontConfig or JavaScriptKit.
  • The README documents the renderer. AndroidGraphics has its own Path, Rect, Point, Color, Font and BlendMode, so a file that imports both modules must write Silica's with the module name.

Limits, documented on the renderer

  • Shadows aren't blurred.
  • Blend modes PorterDuff lacks draw as normal.
  • A transparency layer casts no shadow.
  • A radial gradient between circles with different centers draws around the end circle's center.

Testing

  • AndroidSilica builds on the macOS host against Silica's master, with no warnings in its files.
  • Not yet built for Android, and the on-device tests haven't run: this pull request's CI is the first time.

@colemancda
colemancda merged commit 214e0c8 into master Nov 25, 2026
14 of 16 checks passed
@colemancda
colemancda deleted the feature/silica-renderer branch November 25, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant