File size: 4,767 Bytes
09208f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f85acb
09208f9
bc517b3
1f85acb
 
 
 
 
09208f9
24cd4bf
 
 
 
 
 
09208f9
9fadf37
 
1f85acb
24cd4bf
1f85acb
24cd4bf
1f85acb
9fadf37
09208f9
 
 
 
 
 
 
1f85acb
09208f9
 
 
 
 
 
 
 
 
 
 
24cd4bf
09208f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24cd4bf
09208f9
 
 
1f85acb
 
 
 
 
 
 
24cd4bf
09208f9
 
24cd4bf
09208f9
 
 
 
 
 
a35e270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
09208f9
 
 
24cd4bf
09208f9
 
 
 
 
a35e270
 
 
 
 
 
 
 
09208f9
 
 
 
24cd4bf
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
license: mit
base_model: black-forest-labs/FLUX.2-klein-9B
tags:
  - lora
  - flux
  - flux.2
  - flux.2-klein-9b
  - image-to-image
  - text-to-image
  - font
  - typography
  - atlas
  - comfyui
  - safetensors
---

# Ref2Font V3 — Contextual LoRA for FLUX.2 Klein 9B

**Ref2Font V3** is an updated **contextual LoRA** trained for **black-forest-labs/FLUX.2-klein-9B**. It generates **1280×1280 font atlases** from a single reference image (**"Aa"** for Latin or **"Аа"** for Cyrillic scripts).

### Changes in V3:
- **Cyrillic Support:** Now generates Russian fonts using "Аа" as reference.
- **Extended Glyphs:** Added `"` and `&`.
- **Straighter Letters:** Improved alignment and reduced "jitter" in atlas generation.

**Changes in V2:**
- Fixed alignment issues (letters no longer "dance" or jump).
- Increased resolution to **1280x1280**.
- Improved vectorization scripts.

> Disclaimer: it works **well**, but **not perfectly**. Expect occasional artifacts.

## Examples

![Example_1_C](https://cdn-uploads.huggingface.co/production/uploads/658814fd586088fd274d8cc1/u7Jl9Un35cK1kLJty6I2g.png)

![Example_3_C](https://cdn-uploads.huggingface.co/production/uploads/658814fd586088fd274d8cc1/IwlYEc154OqfAFdZaUz19.png)

![Example_6_C](https://cdn-uploads.huggingface.co/production/uploads/658814fd586088fd274d8cc1/7Ky9ERLVmi4mRO-J9s5YV.png)

## Guide
The full usage, installation guide and detailed workflow live in the [GitHub repo](https://github.com/SnJake/Ref2Font):
```
https://github.com/SnJake/Ref2Font
```

## What’s included
- `Ref2FontV3.safetensors` (LoRA weights)
- `Example Workflow/` (ComfyUI workflow with notes inside nodes)
- `Example/` (input images and their atlases)
- Post-processing scripts (`flux_pipeline.py`, `flux_grid_to_ttf.py`, `flux_upscale.py`)

## License
MIT

## ComfyUI setup
### Required models
1) Base model:
```
https://huggingface.co/black-forest-labs/FLUX.2-klein-base-9B/blob/main/flux-2-klein-base-9b.safetensors
```
Place in: `ComfyUI/models/diffusion_models`

2) Text encoder (Qwen):
```
https://huggingface.co/Comfy-Org/vae-text-encorder-for-flux-klein-9b/blob/main/split_files/text_encoders/qwen_3_8b.safetensors
```
Place in: `ComfyUI/models/text_encoders`

3) VAE:
```
https://huggingface.co/Comfy-Org/vae-text-encorder-for-flux-klein-9b/blob/main/split_files/vae/flux2-vae.safetensors
```
Place in: `ComfyUI/models/vae`

### LoRA
Download:
```
https://huggingface.co/SnJake/Ref2Font/blob/main/Ref2FontV2.safetensors
```
Place in: `ComfyUI/models/loras`

## ⚠️ IMPORTANT: V3 Required Prompts

**For Latin ("Aa" reference):**
> A technical font atlas grid of the Latin charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?.,;:-"&". The style is strictly derived from the reference image "Aa".

**For Cyrillic ("Аа" reference):**
> A technical font atlas grid of the Cyrillic charset: "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя0123456789!?.,;:-"&". The style is strictly derived from the reference image "Аа".

### Input image rules
- **Strict black & white only** (no gray, no shadows, no volume)
- **1280×1280** (recommended)
- Follow the examples in `Example/`

## Post-processing: Atlas → TTF
Use the included pipeline script to convert the atlas into a TTF.

### Example command (Windows)
```
python flux_pipeline.py ^
  --input "path\to\your_atlas.png" ^
  --output-dir "output\folder" ^
  --no-upscale ^
  --use-grid ^
  --simplify 0.5 ^
  --canvas 1280 ^
  --contour-level 0.5 ^
  --trace-scale 4 ^
  --trace-blur 1.0 ^
  --smooth-iters 2 ^
  --baseline-mode auto ^
  --align-mode visual ^
  --keep-components 4 ^
  --min-component-area 3 ^
  --component-center-bias 0.65 ^
  --cell-bleed 0.4 ^
  --cell-bleed-max 10 ^
  --core-overlap-min 0.35 ^
  --charset "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?.,;:-""&" ^
  --no-auto-invert
```

```
python flux_pipeline.py ^
  --input "path\to\your_atlas.png" ^
  --output-dir "output\folder" ^
  --no-upscale ^
  --use-grid ^
  --simplify 0.5 ^
  --canvas 1280 ^
  --contour-level 0.5 ^
  --trace-scale 4 ^
  --trace-blur 1.0 ^
  --smooth-iters 2 ^
  --baseline-mode auto ^
  --align-mode visual ^
  --keep-components 4 ^
  --min-component-area 3 ^
  --component-center-bias 0.65 ^
  --cell-bleed 0.4 ^
  --cell-bleed-max 10 ^
  --core-overlap-min 0.35 ^
  --charset "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя0123456789!?.,;:-""&" ^
  --no-auto-invert
```

## Notes
- `flux_upscale.py` is optional; you can skip it with `--no-upscale`.
- If the atlas looks inverted, try removing `--no-auto-invert` or add `--invert`.