@@ -218,9 +218,8 @@ void EditorApp::init() {
218218 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
219219 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
220220
221- // Apply initial font settings
222- io.FontGlobalScale = settings_.font_size / 16 .0f ;
223- font_size_temp_ = settings_.font_size ;
221+ // Load fonts
222+ load_fonts ();
224223
225224 apply_theme (settings_.dark_theme );
226225
@@ -766,15 +765,32 @@ void EditorApp::clear_change_history() {
766765 tabs_[active_tab_].changed_lines .clear ();
767766}
768767
768+ void EditorApp::load_fonts () {
769+ ImGuiIO& io = ImGui::GetIO ();
770+
771+ // Just add default font - we'll control size via FontGlobalScale
772+ io.Fonts ->AddFontDefault ();
773+
774+ // Store font size temp
775+ font_size_temp_ = settings_.font_size ;
776+
777+ // Font texture is built automatically by the renderer on first use
778+
779+ // Apply initial font scale
780+ float scale = (float )settings_.font_size / 16 .0f ;
781+ io.FontGlobalScale = scale;
782+ }
783+
769784void EditorApp::rebuild_fonts () {
770- // Dynamic font change - apply immediately to all tabs
771- float scale = settings_.font_size / 16 .0f ;
772- ImGui::GetIO ().FontGlobalScale = scale;
785+ // Use font global scale to adjust font size - more stable than rebuilding
786+ ImGuiIO& io = ImGui::GetIO ();
773787
774- // Mark all tabs as needing re-render
775- for (int i = 0 ; i < (int )tabs_.size (); i++) {
776- apply_zoom (i);
777- }
788+ // Get the base font size from settings
789+ float base_size = (float )settings_.font_size ;
790+
791+ // Calculate scale relative to default 16px
792+ float scale = base_size / 16 .0f ;
793+ io.FontGlobalScale = scale;
778794}
779795
780796// ============================================================================
@@ -1039,6 +1055,17 @@ void EditorApp::render_editor_area() {
10391055
10401056 // Tab bar - only show if more than one tab
10411057 bool show_tabs = tabs_.size () > 1 ;
1058+ static int prev_active_tab = -1 ;
1059+
1060+ // Save scroll position when switching away from a tab
1061+ if (prev_active_tab != active_tab_ && prev_active_tab >= 0 && prev_active_tab < (int )tabs_.size ()) {
1062+ // Note: TextEditor doesn't have public scroll getters/setters,
1063+ // but we could track cursor position as proxy
1064+ auto & prev_tab = tabs_[prev_active_tab];
1065+ prev_tab.editor ->GetCursorPosition (); // This doesn't return scroll, but we can track cursor
1066+ }
1067+ prev_active_tab = active_tab_;
1068+
10421069 if (show_tabs) {
10431070 ImGuiTabBarFlags tab_flags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_AutoSelectNewTabs;
10441071 if (ImGui::BeginTabBar (" ##Tabs" , tab_flags)) {
@@ -1328,6 +1355,11 @@ void EditorApp::render_font_dialog() {
13281355 ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
13291356 ImGui::SetNextWindowPos (center, ImGuiCond_Appearing, ImVec2 (0 .5f , 0 .5f ));
13301357
1358+ // Initialize temp values from current settings when opening
1359+ if (show_font_ && font_name_temp_.empty ()) {
1360+ font_name_temp_ = settings_.font_name ;
1361+ }
1362+
13311363 if (ImGui::BeginPopupModal (" Font Settings" , &show_font_, ImGuiWindowFlags_AlwaysAutoResize)) {
13321364 ImGui::Text (" Font Family:" );
13331365 ImGui::SetNextItemWidth (250 );
@@ -1347,7 +1379,7 @@ void EditorApp::render_font_dialog() {
13471379
13481380 ImGui::Separator ();
13491381 ImGui::TextUnformatted (" Note: Font size changes apply to all tabs." );
1350- ImGui::TextUnformatted (" Changing font family requires application restart." );
1382+ ImGui::TextUnformatted (" Font family changes require application restart." );
13511383
13521384 if (ImGui::Button (" Apply" )) {
13531385 settings_.font_size = font_size_temp_;
0 commit comments