Render fixes
This commit is contained in:
@@ -4,7 +4,7 @@ use pangocairo::FontMap;
|
||||
use pango::prelude::*;
|
||||
use pango;
|
||||
|
||||
use sys::pango::*;
|
||||
use sys::pango as sys_pango;
|
||||
|
||||
use ui_model::StyledLine;
|
||||
|
||||
@@ -21,8 +21,8 @@ impl Context {
|
||||
self.pango_context = create_pango_context(font_desc);
|
||||
}
|
||||
|
||||
pub fn itemize(&self, line: &StyledLine) -> Vec<item::Item> {
|
||||
pango_itemize(&self.pango_context, &line.line_str, &line.attr_list)
|
||||
pub fn itemize(&self, line: &StyledLine) -> Vec<sys_pango::Item> {
|
||||
sys_pango::pango_itemize(&self.pango_context, &line.line_str, &line.attr_list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ mod context;
|
||||
|
||||
use sys::pango::*;
|
||||
use pango;
|
||||
use pango::prelude::*;
|
||||
use cairo;
|
||||
use pangocairo::{CairoContextExt, FontMap};
|
||||
use std::ffi::CString;
|
||||
use pangocairo::CairoContextExt;
|
||||
use ui_model;
|
||||
|
||||
pub fn render(
|
||||
ctx: &cairo::Context,
|
||||
font_desc: pango::FontDescription,
|
||||
line_height: f64,
|
||||
char_width: f64,
|
||||
ui_model: &mut ui_model::UiModel,
|
||||
) {
|
||||
let font_ctx = context::Context::new(&font_desc);
|
||||
@@ -18,17 +18,19 @@ pub fn render(
|
||||
shape_dirty(&font_ctx, ui_model);
|
||||
|
||||
|
||||
let mut line_y = line_height;
|
||||
|
||||
for line in ui_model.model_mut() {
|
||||
ctx.move_to(0.0, line_y);
|
||||
for i in 0..line.line.len() {
|
||||
let item = line.item_line[i].as_ref();
|
||||
if let Some(item) = item {
|
||||
if let Some(ref glyphs) = item.glyphs {
|
||||
let analysis = item.item.analysis();
|
||||
let font = analysis.font();
|
||||
ctx.show_glyph_string(&font, glyphs);
|
||||
ctx.show_glyph_string(item.font(), glyphs);
|
||||
}
|
||||
}
|
||||
}
|
||||
line_y += line_height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ fn shape_dirty(ctx: &context::Context, ui_model: &mut ui_model::UiModel) {
|
||||
let mut item = line.get_item_mut(i).unwrap();
|
||||
let mut glyphs = pango::GlyphString::new();
|
||||
{
|
||||
let analysis = item.item.analysis();
|
||||
let analysis = item.analysis();
|
||||
let (offset, length, _) = item.item.offset();
|
||||
pango_shape(
|
||||
&styled_line.line_str,
|
||||
|
||||
Reference in New Issue
Block a user