# DocStudio V3 — Tap-to-Match AI Font Upgrade

## What changed
- Native PDF text: tapping an original text region sets the detected/embedded font and formatting in the font selector immediately (no Gemini request for reliable embedded fonts).
- Scanned PDFs, images, or PDF fonts that cannot be reused: tapping an OCR region initially shows the local font match. With **Gemini AI font match on tap** enabled, the first remote match asks for consent to share **only a small crop of the tapped text** with Gemini. For the rest of that editing session it matches automatically.
- Gemini responds with an estimated font from supported options and a confidence level. The editor sets the font dropdown, bold and italic where OCR metadata is absent. The font can still be manually changed.
- **Retry match** button and automatic matching toggle are in the text edit glass panel.
- In Select mode, tap any highlighted/recognized original text directly to edit it. For JPG/scans run OCR first. Select mode may prioritize unedited text regions over overlapping objects; use another tool or edit/replace the region before adjusting the object.

## cPanel update
1. Back up your old site directory, especially `api/storage/state.php`, and any `.docstudio` projects.
2. Extract `DocStudio_AI_FONT_TAP_V3_UPDATE_ONLY.zip` and upload its contents into the existing DocStudio directory, overwriting the same paths. **Do not delete your original site folder.**
3. Do not change or upload an admin password or Gemini key in this update. Existing access keys, expiry dates, admin login and Gemini settings are preserved.
4. Refresh the editor with Ctrl+Shift+R (or clear site cache).
5. Admin → Gemini settings: Test connection. PHP cURL must be enabled. The server will read the existing stored Gemini API key; do **not** put it in frontend code.
6. Open a PDF and tap its text. For scanned PDFs or photos run Local OCR / Gemini OCR first. Approve the one-time, per-session cropped-text Gemini permission if you want visual font estimates. Use the inspector to confirm font, bold, size, color, then Replace.

## Limitations & safety
- AI visual font recognition is an **estimate**, not a reliable recovery of a proprietary/embedded font or pixel-perfect reconstruction. When an actual embedded PDF font is available, it is preferred; with subset or inaccessible fonts a substitute is necessary. Exact style matching for scanned images is not guaranteed.
- The editor's PDF export remains flattened/visual, not a native editable-text PDF. Save a `.docstudio` project to preserve layers.
- Cropped document text is uploaded to Google Gemini after explicit one-time session approval. The first request asks consent. The toggle allows stopping future automatic submissions. The chatbot and OCR have their own existing consent behavior.
- Gemini access may incur fees or quota. Each user access key is rate-limited to 60 font-match requests per hour.
- No database changes; this is a frontend + one PHP endpoint update.
