# Stage 5 local renderer setup

Uploads stop at preparation. Image generation requires the isolated Linux renderer. Original presentation text is never translated.

## Windows

Start Docker Desktop with its Linux engine and build from the backend directory:

```powershell
docker build -t docudeck-renderer:1 resources/font-renderer
docker run --rm docudeck-renderer:1 environment
php artisan migrate
php artisan queue:restart
php artisan queue:work --queue=conversions --timeout=1000
```

Set `RENDERER_DOCKER_BINARY=docker` and `RENDERER_DOCKER_IMAGE=docudeck-renderer:1`. The PHP web-server and queue-worker accounts need access to Docker and the private conversion disk. Docker access is privileged; do not expose its socket publicly. The container receives explicit job mounts, no network, bounded memory/CPU/processes, and no global font installation.

## Ubuntu

```bash
sudo apt-get install libreoffice-impress poppler-utils fontconfig fonts-noto-core python3-venv locales
sudo locale-gen en_US.UTF-8 ar_SA.UTF-8
python3 -m venv .renderer-venv
.renderer-venv/bin/pip install -r resources/font-renderer/requirements.txt
.renderer-venv/bin/python resources/font-renderer/renderer.py environment
```

Set `FONT_PYTHON_BINARY` to the absolute `.renderer-venv/bin/python` path. Run migrations and restart workers. Keep source presentations, fonts, generation directories and caches private and writable by the application/worker account. Fonts are not shipped in image-only SCORM packages.

## Verification

Run `php artisan test`. `IsolatedRendererIntegrationTest` requires a functioning renderer and the repository-local Arabic font example; it skips explicitly when unavailable. Run `test_renderer.py` with the same Python environment for formatting-preservation tests. A passing legacy LibreOffice smoke test is not a passing Stage 5 isolation test. Native Ubuntu, Windows Docker, reference-export comparisons, RTL visual acceptance and Moodle acceptance must be recorded separately.

Font limits: static TTF/OTF only, 10 MB/file, 100 MB/project, 50 files. Permission acknowledgement is mandatory. Missing/style-mismatched fonts and unresolved references require explicit substitution acknowledgement for the submitted preparation revision.
