@@ -37,6 +37,8 @@ program fortty |
| 37 | 37 | real(8) :: current_time, last_time, blink_timer |
| 38 | 38 | logical :: cursor_blink_visible |
| 39 | 39 | type(selection_t) :: sel |
| 40 | + integer :: font_delta, new_font_size, base_font_size |
| 41 | + character(len=256) :: font_path_saved, fallback_path_saved |
| 40 | 42 | |
| 41 | 43 | ! Load configuration (uses defaults if no config file found) |
| 42 | 44 | cfg = config_load('') |
@@ -92,6 +94,11 @@ program fortty |
| 92 | 94 | ! After assignment, we need to update it to point to ren%font |
| 93 | 95 | ren%atlas%font => ren%font |
| 94 | 96 | |
| 97 | + ! Save font path and base size for runtime font size changes |
| 98 | + font_path_saved = font_path |
| 99 | + base_font_size = cfg%font_size |
| 100 | + fallback_path_saved = '' ! Will be set when fallback is loaded |
| 101 | + |
| 95 | 102 | ! Load fallback font for missing glyphs (icons, symbols, etc.) |
| 96 | 103 | ! Use config fallback if specified, otherwise auto-detect via fontconfig |
| 97 | 104 | if (len_trim(cfg%font_fallback) > 0) then |
@@ -162,7 +169,13 @@ program fortty |
| 162 | 169 | end if |
| 163 | 170 | |
| 164 | 171 | if (ren%font%has_fallback) then |
| 165 | | - print *, "Fallback font loaded: ", trim(fallback_path) |
| 172 | + ! Save the successful fallback path for font size changes |
| 173 | + if (len_trim(cfg%font_fallback) > 0) then |
| 174 | + fallback_path_saved = cfg%font_fallback |
| 175 | + else |
| 176 | + fallback_path_saved = fallback_path |
| 177 | + end if |
| 178 | + print *, "Fallback font loaded: ", trim(fallback_path_saved) |
| 166 | 179 | else |
| 167 | 180 | print *, "Warning: No fallback font loaded - some icons may not display" |
| 168 | 181 | end if |
@@ -227,6 +240,59 @@ program fortty |
| 227 | 240 | blink_timer = 0.0d0 |
| 228 | 241 | end if |
| 229 | 242 | |
| 243 | + ! Check for font size change request (Ctrl/Cmd +/-) |
| 244 | + font_delta = window_get_font_delta() |
| 245 | + if (font_delta /= 0) then |
| 246 | + call window_clear_font_delta() |
| 247 | + |
| 248 | + if (font_delta == -999) then |
| 249 | + ! Reset to default |
| 250 | + new_font_size = base_font_size |
| 251 | + else |
| 252 | + new_font_size = ren%font%size_px + font_delta |
| 253 | + end if |
| 254 | + |
| 255 | + ! Clamp to reasonable range (8px to 72px) |
| 256 | + new_font_size = max(8, min(72, new_font_size)) |
| 257 | + |
| 258 | + if (new_font_size /= ren%font%size_px) then |
| 259 | + ! Reload font with new size |
| 260 | + call renderer_change_font_size(ren, trim(font_path_saved), new_font_size) |
| 261 | + |
| 262 | + ! Fix atlas font pointer after reload |
| 263 | + ren%atlas%font => ren%font |
| 264 | + |
| 265 | + ! Reload fallback font (using saved path from startup) |
| 266 | + if (len_trim(fallback_path_saved) > 0) then |
| 267 | + call renderer_load_fallback_font(ren, trim(fallback_path_saved)) |
| 268 | + end if |
| 269 | + |
| 270 | + ! Update cell dimensions from new font |
| 271 | + cell_width = ren%font%cell_width |
| 272 | + cell_height = ren%font%cell_height |
| 273 | + ascender = ren%font%ascender |
| 274 | + if (cell_width < 1) cell_width = 10 |
| 275 | + if (cell_height < 1) cell_height = 18 |
| 276 | + if (ascender < 1) ascender = cell_height - 4 |
| 277 | + |
| 278 | + ! Update window module's cell size for mouse coords |
| 279 | + call window_set_cell_size(cell_width, cell_height) |
| 280 | + |
| 281 | + ! Recalculate terminal dimensions |
| 282 | + new_cols = win_width / cell_width |
| 283 | + new_rows = win_height / cell_height |
| 284 | + if (new_cols /= term_cols .or. new_rows /= term_rows) then |
| 285 | + term_cols = new_cols |
| 286 | + term_rows = new_rows |
| 287 | + call pty_resize(pty, term_rows, term_cols) |
| 288 | + call terminal_resize(term, term_rows, term_cols) |
| 289 | + end if |
| 290 | + |
| 291 | + call window_set_font_size(new_font_size) |
| 292 | + print *, "Font size:", new_font_size, "px (", term_cols, "x", term_rows, ")" |
| 293 | + end if |
| 294 | + end if |
| 295 | + |
| 230 | 296 | ! Check for window resize |
| 231 | 297 | call window_get_size(win, win_width, win_height) |
| 232 | 298 | if (win_width /= prev_width .or. win_height /= prev_height) then |