From 9fb8cf1bcfab9f37391f96c6928dbaa4d0a2efc6 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 15 Oct 2017 21:36:48 -0400 Subject: [PATCH] tweak glyph drawing --- edit.ml | 11 +++++++---- lib/x11_prims.c | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/edit.ml b/edit.ml index 8225154..0e1159f 100644 --- a/edit.ml +++ b/edit.ml @@ -1,7 +1,10 @@ open X11 -(*let font = font_load "Times New Roman:size=12"*) +let font = font_load "Times New Roman:size=12" +(* let font = font_load "Monaco:size=10::antialias=true:autohint=true" +*) + let tags_buf = ref Buf.create let edit_buf = ref Buf.create @@ -56,9 +59,9 @@ let draw_buffer pos width height = | 0x0A -> newline () | 0x0D -> () | _ -> begin - if (!x + glyph.width) > width then (newline ()); - let _ = X11.draw_glyph Cfg.Color.palette.(5) glyph (!x, !y) in - x := !x + glyph.xoff + if (!x + glyph.xoff) > width then (newline ()); + let off = X11.draw_glyph Cfg.Color.palette.(5) glyph (!x, !y) in + x := !x + off end); ((!y + font.height) < height) in diff --git a/lib/x11_prims.c b/lib/x11_prims.c index 5daf87a..7dd1881 100644 --- a/lib/x11_prims.c +++ b/lib/x11_prims.c @@ -252,13 +252,14 @@ CAMLprim value x11_font_glyph(value font, value rune) { CAMLreturn(glyph); } + CAMLprim value x11_draw_glyph(value color, value glyph, value coord) { CAMLparam3(color, glyph, coord); XftFont* font = (XftFont*)Field(glyph,0); XftGlyphFontSpec spec = { .font = font, .glyph = intfield(glyph,1), - .x = intfield(coord,0) + intfield(glyph,4), + .x = intfield(coord,0), // - intfield(glyph,4), .y = intfield(coord,1) + font->ascent }; // printf("c: '%c' w: %d x: %d y: %d xoff: %d yoff: %d\n", -- 2.52.0