diff --git a/ImGuiFrontend.cc b/ImGuiFrontend.cc index 682a499..f8d9457 100644 --- a/ImGuiFrontend.cc +++ b/ImGuiFrontend.cc @@ -18,6 +18,7 @@ #include "GUITheme.h" #include "fonts/Font.h" // embedded default font (DefaultFont) #include "fonts/FontRegistry.h" +#include "fonts/IosevkaExtended.h" #include "syntax/HighlighterRegistry.h" #include "syntax/NullHighlighter.h" @@ -369,30 +370,19 @@ GUIFrontend::LoadGuiFont_(const char * /*path*/, const float size_px) &config, io.Fonts->GetGlyphRangesDefault()); - // Merge Greek and Coptic - config.MergeMode = true; - static const ImWchar greek_ranges[] = { + // Merge Greek and Mathematical symbols from IosevkaExtended + config.MergeMode = true; + static const ImWchar extended_ranges[] = { 0x0370, 0x03FF, // Greek and Coptic - 0, - }; - io.Fonts->AddFontFromMemoryCompressedTTF( - kte::Fonts::DefaultFontData, - kte::Fonts::DefaultFontSize, - size_px, - &config, - greek_ranges); - - // Merge Mathematical Operators - static const ImWchar math_ranges[] = { 0x2200, 0x22FF, // Mathematical Operators 0, }; io.Fonts->AddFontFromMemoryCompressedTTF( - kte::Fonts::DefaultFontData, - kte::Fonts::DefaultFontSize, + kte::Fonts::IosevkaExtended::DefaultFontRegularCompressedData, + kte::Fonts::IosevkaExtended::DefaultFontRegularCompressedSize, size_px, &config, - math_ranges); + extended_ranges); io.Fonts->Build(); return true; diff --git a/ImGuiRenderer.cc b/ImGuiRenderer.cc index 2a686fc..957e45a 100644 --- a/ImGuiRenderer.cc +++ b/ImGuiRenderer.cc @@ -560,7 +560,7 @@ ImGuiRenderer::Draw(Editor &ed) (size_t) std::max( 1, (size_t) (tail.size() / 4))) : 1; - start += skip; + start += skip; std::string candidate = tail.substr(start); ImVec2 cand_sz = ImGui::CalcTextSize(candidate.c_str()); if (cand_sz.x <= avail_px) { @@ -618,11 +618,11 @@ ImGuiRenderer::Draw(Editor &ed) std::size_t total = ed.BufferCount(); if (total > 0) { std::size_t idx1 = ed.CurrentBufferIndex() + 1; // 1-based for display - left += "["; - left += std::to_string(static_cast(idx1)); - left += "/"; - left += std::to_string(static_cast(total)); - left += "] "; + left += "["; + left += std::to_string(static_cast(idx1)); + left += "/"; + left += std::to_string(static_cast(total)); + left += "] "; } } left += fname; @@ -631,9 +631,9 @@ ImGuiRenderer::Draw(Editor &ed) // Append total line count as "L" { unsigned long lcount = static_cast(buf->Rows().size()); - left += " "; - left += std::to_string(lcount); - left += "L"; + left += " "; + left += std::to_string(lcount); + left += "L"; } // Build right text (cursor/mark) diff --git a/QtFrontend.cc b/QtFrontend.cc index 1963060..89940fc 100644 --- a/QtFrontend.cc +++ b/QtFrontend.cc @@ -142,13 +142,13 @@ protected: p.save(); p.setClipRect(viewport); - // Iterate visible lines - for (std::size_t i = rowoffs, vis_idx = 0; i < last_row; ++i, ++vis_idx) { - // Materialize the Buffer::Line into a std::string for - // regex/iterator usage and general string ops. - const std::string line = static_cast(lines[i]); - const int y = viewport.y() + static_cast(vis_idx) * line_h; - const int baseline = y + fm.ascent(); + // Iterate visible lines + for (std::size_t i = rowoffs, vis_idx = 0; i < last_row; ++i, ++vis_idx) { + // Materialize the Buffer::Line into a std::string for + // regex/iterator usage and general string ops. + const std::string line = static_cast(lines[i]); + const int y = viewport.y() + static_cast(vis_idx) * line_h; + const int baseline = y + fm.ascent(); // Helper: convert src col -> rx with tab expansion auto src_to_rx_line = [&](std::size_t src_col) -> std::size_t { @@ -453,11 +453,11 @@ protected: std::size_t total = ed_->BufferCount(); if (total > 0) { std::size_t idx1 = ed_->CurrentBufferIndex() + 1; // 1-based - left += QStringLiteral(" ["); - left += QString::number(static_cast(idx1)); - left += QStringLiteral("/"); - left += QString::number(static_cast(total)); - left += QStringLiteral("] "); + left += QStringLiteral(" ["); + left += QString::number(static_cast(idx1)); + left += QStringLiteral("/"); + left += QString::number(static_cast(total)); + left += QStringLiteral("] "); } else { left += QStringLiteral(" "); } @@ -477,9 +477,9 @@ protected: // total lines suffix " L" unsigned long lcount = static_cast(buf->Rows().size()); - left += QStringLiteral(" "); - left += QString::number(static_cast(lcount)); - left += QStringLiteral("L"); + left += QStringLiteral(" "); + left += QString::number(static_cast(lcount)); + left += QStringLiteral("L"); } // Build right segment: cursor and mark @@ -602,12 +602,12 @@ protected: int d_cols = 0; if (std::fabs(v_scroll_accum_) >= 1.0 && (!horiz_mode || std::fabs(v_scroll_accum_) > std::fabs( h_scroll_accum_))) { - d_rows = static_cast(v_scroll_accum_); + d_rows = static_cast(v_scroll_accum_); v_scroll_accum_ -= d_rows; } if (std::fabs(h_scroll_accum_) >= 1.0 && (horiz_mode || std::fabs(h_scroll_accum_) >= std::fabs( v_scroll_accum_))) { - d_cols = static_cast(h_scroll_accum_); + d_cols = static_cast(h_scroll_accum_); h_scroll_accum_ -= d_cols; } diff --git a/fonts/Font.cc b/fonts/Font.cc index 8d86df1..db357cd 100644 --- a/fonts/Font.cc +++ b/fonts/Font.cc @@ -1,4 +1,5 @@ #include "Font.h" +#include "IosevkaExtended.h" #include "imgui.h" @@ -20,30 +21,19 @@ Font::Load(const float size) const &config, io.Fonts->GetGlyphRangesDefault()); - // Merge Greek and Coptic - config.MergeMode = true; - static const ImWchar greek_ranges[] = { + // Merge Greek and Mathematical symbols from IosevkaExtended as fallback + config.MergeMode = true; + static const ImWchar extended_ranges[] = { 0x0370, 0x03FF, // Greek and Coptic - 0, - }; - io.Fonts->AddFontFromMemoryCompressedTTF( - this->data_, - this->size_, - size, - &config, - greek_ranges); - - // Merge Mathematical Operators - static const ImWchar math_ranges[] = { 0x2200, 0x22FF, // Mathematical Operators 0, }; io.Fonts->AddFontFromMemoryCompressedTTF( - this->data_, - this->size_, + kte::Fonts::IosevkaExtended::DefaultFontRegularCompressedData, + kte::Fonts::IosevkaExtended::DefaultFontRegularCompressedSize, size, &config, - math_ranges); + extended_ranges); io.Fonts->Build(); }