Skip to main content

resforge

A type-safe Python DSL for generating native Android and iOS resources from design tokens.

Features

  • Fluent, Pythonic API
  • Jetpack Compose theme generation for colors and dimensions
  • Supports all Android res/values/ types
  • Native Apple Asset Catalog (.xcassets) support
  • Wide Gamut support with automatic sRGB fallbacks
  • Built-in validation for resource names and color formats

Installation

pip install resforge

Quick Example

Android (Jetpack Compose)

from resforge.android import ComposeWriter

with ComposeWriter("Color.kt", "com.example.myapplication.ui.theme") as compose:
    compose.color(
        Purple80="#D0BCFF",
        PurpleGrey80="#CCC2DC",
        Pink80="#EFB8C8",
        Purple40="#6650a4",
        PurpleGrey40="#625b71",
        Pink40="#7D5260",
    )
package com.example.myapplication.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80: Color = Color(0xFFD0BCFF)
val PurpleGrey80: Color = Color(0xFFCCC2DC)
val Pink80: Color = Color(0xFFEFB8C8)
val Purple40: Color = Color(0xFF6650A4)
val PurpleGrey40: Color = Color(0xFF625B71)
val Pink40: Color = Color(0xFF7D5260)

Android (XML Resources)

from resforge.android import ValuesWriter, dp, sp

with ValuesWriter("res/values/resources.xml") as res:
    res.string(
        app_name="My App",
        welcome_message="Welcome!",
    ).color(
        primary="#6200EE",
        secondary="#03DAC5",
    ).dimension(
        padding_small=dp(8),
        text_body=sp(16),
    )
<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">My App</string>
    <string name="welcome_message">Welcome!</string>
    <color name="primary">#FF6200EE</color>
    <color name="secondary">#FF00FF00</color>
    <dimen name="padding_small">8dp</dimen>
    <dimen name="text_body">16sp</dimen>
</resources>

Asset Catalog (iOS)

from resforge import Color
from resforge.apple import Appearance, AppleColor, AssetCatalog

with AssetCatalog("App", "Assets") as catalog:
    catalog.colorset(
        "MyColor",
        AppleColor(Color.p3(0.0, 1.0, 0.0)),
        AppleColor("#000000", appearances=[Appearance.Dark]),
    )
{
  "info": {
    "author": "xcode",
    "version": 1
  },
  "colors": [
    {
      "idiom": "universal",
      "color": {
        "components": {
          "red": "0.000",
          "green": "1.000",
          "blue": "0.000",
          "alpha": "1.000"
        },
        "color-space": "srgb"
      }
    },
    {
      "idiom": "universal",
      "color": {
        "components": {
          "red": "0.000",
          "green": "1.000",
          "blue": "0.000",
          "alpha": "1.000"
        },
        "color-space": "display-p3"
      },
      "display-gamut": "display-P3"
    },
    {
      "idiom": "universal",
      "color": {
        "components": {
          "red": "0.000",
          "green": "0.000",
          "blue": "0.000",
          "alpha": "1.000"
        },
        "color-space": "srgb"
      },
      "appearances": [
        {
          "appearance": "luminosity",
          "value": "dark"
        }
      ]
    }
  ]
}

Roadmap

  • SwiftUI dimensions
  • Typography
  • Images (ImageSet, IconSet, res/drawable vectors)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resforge-0.4.4.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resforge-0.4.4-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file resforge-0.4.4.tar.gz.

File metadata

  • Download URL: resforge-0.4.4.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for resforge-0.4.4.tar.gz
Algorithm Hash digest
SHA256 49dbcdc251af3dfdb96c3f5efbfb0529a81dd5c15a12b03e21083f9d385cf37a
MD5 aad35d13c265e9dcfd8dad454772bea5
BLAKE2b-256 f8a6394a4bcb799b02afa5966b891dcc605b92f51b082047087ef2da48fb054a

See more details on using hashes here.

Provenance

The following attestation bundles were made for resforge-0.4.4.tar.gz:

Publisher: publish.yml on kipila-dev/forje

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file resforge-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: resforge-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for resforge-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 99f58cfba18cf0af4b7061b6a16225e382bd2b927eb1f9af0426540f13433864
MD5 9e06d426cbcf48e7e96e568ea13e8704
BLAKE2b-256 4767a6979412ab97bc815a04344339182159495a17651eee611d3e137e974c80

See more details on using hashes here.

Provenance

The following attestation bundles were made for resforge-0.4.4-py3-none-any.whl:

Publisher: publish.yml on kipila-dev/forje

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page