diff --git a/src/platform/render_opengl.cpp b/src/platform/render_opengl.cpp index 12c2cb5..1f7af50 100644 --- a/src/platform/render_opengl.cpp +++ b/src/platform/render_opengl.cpp @@ -299,8 +299,19 @@ void DrawRect(Rect2I rect, Color color) { PushQuad2D(RenderArena, &Vertices, ToRect2(rect), MainFont.white_texture_bounding_box, color); } +Int GetCharSpacing(Font *font, int codepoint = '_') { + Glyph *g = GetGlyph(font, codepoint); + if (g->xadvance) return (Int)g->xadvance; + return (Int)g->size.x; +} + +Int GetLineSpacing(Font *font) { + Int result = (Int)(font->ascent - font->descent + font->line_gap); + return result; +} + Vec2 DrawString(Font *font, String16 string, Vec2 pos, Color color, bool draw = true) { - pos.y += font->ascent - font->descent; + pos.y += GetLineSpacing(font) + font->descent; Vec2 original_pos = pos; For(string) { Glyph *g = GetGlyph(font, it); @@ -346,17 +357,6 @@ void DrawCircle(Vec2 pos, float radius, Color color) { } } -Int GetCharSpacing(Font *font, int codepoint = '_') { - Glyph *g = GetGlyph(font, codepoint); - if (g->xadvance) return (Int)g->xadvance; - return (Int)g->size.x; -} - -Int GetLineSpacing(Font *font) { - Int result = (Int)(font->ascent - font->descent + font->line_gap); - return result; -} - String FontPath = "C:\\Windows\\Fonts\\consola.ttf"; void ReloadFont(int32_t size) { size = ClampBottom(2, size); diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index e73c6d5..48ffa98 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,3 +1,6 @@ +- bugs: + - scrolling when clicking on scroller is busted + - Windows - Mark windows as absolute or non-automatic layout and then just loop through windows - layouting, resize windows diff --git a/src/text_editor/window_draw.cpp b/src/text_editor/window_draw.cpp index ca63c1e..87326f4 100644 --- a/src/text_editor/window_draw.cpp +++ b/src/text_editor/window_draw.cpp @@ -57,7 +57,8 @@ void DrawVisibleText(Window *window) { int codepoint = line_string[col_index]; Glyph *g = GetGlyph(&MainFont, codepoint); Vec2 p = ToVec2(pos); - p.y += MainFont.ascent - MainFont.descent; + // p.y += MainFont.ascent - MainFont.descent; + p.y += FontLineSpacing + MainFont.descent; p.x += text_offset_x; Rect2 rect = Rect2FromSize(p + g->offset, g->size);