neovim-gtk/src/render/mod.rs

31 lines
881 B
Rust
Raw Normal View History

2017-08-24 14:41:20 +00:00
mod context;
use sys::pango::*;
use pango;
2017-08-22 09:27:59 +00:00
use pango::prelude::*;
use cairo;
2017-08-23 09:45:56 +00:00
use pangocairo::{CairoContextExt, FontMap};
use std::ffi::CString;
2017-08-24 14:41:20 +00:00
use ui_model;
2017-08-22 09:27:59 +00:00
pub fn render(ctx: &cairo::Context, font_desc: pango::FontDescription) {
2017-08-23 09:45:56 +00:00
let font_map = FontMap::get_default();
let pango_context = font_map.create_context().unwrap();
pango_context.set_font_description(&font_desc);
2017-08-22 09:27:59 +00:00
2017-08-24 14:41:20 +00:00
let text = "TEST String".to_owned();
2017-08-23 09:45:56 +00:00
let attr_list = pango::AttrList::new();
2017-08-23 09:45:56 +00:00
ctx.move_to(0.0, 50.0);
2017-08-24 14:41:20 +00:00
let items = pango_itemize(&pango_context, &text, &attr_list);
2017-08-23 09:45:56 +00:00
for item in items {
let mut glyphs = pango::GlyphString::new();
let analysis = item.analysis();
2017-08-24 14:41:20 +00:00
pango_shape(&text, &analysis, &mut glyphs);
2017-08-23 09:45:56 +00:00
let font = analysis.font();
let (ink, logical) = glyphs.extents(&font);
ctx.show_glyph_string(&font, &glyphs);
}
}
2017-08-24 14:41:20 +00:00