{"id":28042,"library":"pictex","title":"PicTex","description":"PicTex is a Python library for generating images via CSS Flexbox layout. It uses a declarative API to compose elements, supports text shaping via HarfBuzz, Unicode bidirectional text, gradients, and inline spans. Current version 2.3.0 requires Python >=3.9. Releases occur irregularly, with breaking changes in v2.0.0 that renamed many methods.","status":"active","version":"2.3.0","language":"python","source_language":"en","source_url":"https://github.com/francozanardi/pictex","tags":["image-generation","css-flexbox","text-shaping","harfbuzz","gradients"],"install":[{"cmd":"pip install pictex","lang":"bash","label":"Install PicTex"}],"dependencies":[],"imports":[{"note":"Canvas is a top-level export; no submodule needed.","wrong":"from pictex.canvas import Canvas","symbol":"Canvas","correct":"from pictex import Canvas"},{"note":"Span is exported from the main package.","wrong":"from pictex.text import Span","symbol":"Span","correct":"from pictex import Span"},{"note":"Gradient classes are top-level exports.","wrong":"from pictex.gradients import RadialGradient","symbol":"RadialGradient","correct":"from pictex import RadialGradient"}],"quickstart":{"code":"from pictex import Canvas, Text, Rect\n\ncanvas = Canvas(200, 100, background_color=\"white\")\ncanvas.add(Rect(width=50, height=50, background_color=\"blue\"))\ncanvas.add(Text(\"Hello, PicTex!\"))\nimage = canvas.render()\nimage.save(\"output.png\")","lang":"python","description":"Creates a 200x100 canvas with a blue rectangle and text, renders to PNG."},"warnings":[{"fix":"Follow the migration guide at https://github.com/francozanardi/pictex/blob/main/docs/MIGRATION.md","message":"v2.0.0 introduced breaking changes: many methods were renamed to match CSS terminology (e.g., add_static was removed, layout changed). Existing code from v1.x will not work without migration.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use standard font paths; HarfBuzz handles shaping automatically.","message":"The v2.0.0 release replaced Skia with HarfBuzz for text shaping. If you were using skia-specific features or relying on Skia fonts, you may need to adjust.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Always specify a width on text-containing elements, e.g., Text(\"...\", width=200).","message":"Text wrapping can behave unexpectedly when no width constraint is set. Floating-point precision may cause false word-wrapping. In v2.1.1 this was fixed, but it's still a good practice to set a width for text elements.","severity":"gotcha","affected_versions":">=2.1.0"},{"fix":"Explicitly set properties on each Span to avoid inheritance surprises.","message":"Inline spans (Span) are new in v2.3.0. They are deeply nestable but properties cascade; forgetting to override a property may lead to unintended inheritance. The note says 'properties cascade down and inherit naturally unless explicitly overridden'.","severity":"gotcha","affected_versions":">=2.3.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade to latest: pip install --upgrade pictex","cause":"Installed version is too old (<2.0.0) or PicTex not installed correctly.","error":"ImportError: cannot import name 'Canvas' from 'pictex'"},{"fix":"Install: pip install pictex","cause":"PicTex is not installed.","error":"ModuleNotFoundError: No module named 'pictex'"},{"fix":"Use canvas.add() or the new positioning methods. See migration guide.","cause":"Method renamed in v2.0.0 breakage.","error":"AttributeError: 'Canvas' object has no attribute 'add_static'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}