mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Fix incorrect origin for drawing glyphs. Fixes #153.
This commit is contained in:
parent
91c7ca11b3
commit
416ffeaca6
1 changed files with 8 additions and 3 deletions
|
@ -74,6 +74,10 @@ impl RenderContext {
|
||||||
draw_surface_options, draw_options);
|
draw_surface_options, draw_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: azure takes the origin as the left or right baseline. We
|
||||||
|
// should be passing in a bunch of glyphs and the baseline
|
||||||
|
// point. The baseline point should be computed somewhere else,
|
||||||
|
// like Font::draw_to_context() or TextRun::draw_to_context().
|
||||||
pub fn draw_text(&self, bounds: Rect<Au>, run: &TextRun, range: Range) {
|
pub fn draw_text(&self, bounds: Rect<Au>, run: &TextRun, range: Range) {
|
||||||
use ptr::{null};
|
use ptr::{null};
|
||||||
use vec::raw::to_ptr;
|
use vec::raw::to_ptr;
|
||||||
|
@ -89,7 +93,8 @@ impl RenderContext {
|
||||||
use azure::cairo::bindgen::cairo_scaled_font_destroy;
|
use azure::cairo::bindgen::cairo_scaled_font_destroy;
|
||||||
|
|
||||||
let font = run.font;
|
let font = run.font;
|
||||||
|
// See the TODO above.
|
||||||
|
let y_adjust = font.metrics.descent;
|
||||||
let nfont: AzNativeFont = {
|
let nfont: AzNativeFont = {
|
||||||
mType: AZ_NATIVE_FONT_CAIRO_FONT_FACE,
|
mType: AZ_NATIVE_FONT_CAIRO_FONT_FACE,
|
||||||
mFont: null()
|
mFont: null()
|
||||||
|
@ -114,7 +119,7 @@ impl RenderContext {
|
||||||
fields: 0 as uint16_t
|
fields: 0 as uint16_t
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(&bounds.size.height));
|
let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(&bounds.size.height) - y_adjust);
|
||||||
let azglyphs = DVec();
|
let azglyphs = DVec();
|
||||||
azglyphs.reserve(range.length());
|
azglyphs.reserve(range.length());
|
||||||
|
|
||||||
|
@ -232,7 +237,7 @@ fn get_cairo_font(font: &Font) -> *cairo_scaled_font_t {
|
||||||
cairo_matrix_init_identity(to_unsafe_ptr(&idmatrix));
|
cairo_matrix_init_identity(to_unsafe_ptr(&idmatrix));
|
||||||
|
|
||||||
let fontmatrix = idmatrix;
|
let fontmatrix = idmatrix;
|
||||||
cairo_matrix_scale(to_unsafe_ptr(&fontmatrix), 20f as c_double, 20f as c_double);
|
cairo_matrix_scale(to_unsafe_ptr(&fontmatrix), 21f as c_double, 21f as c_double);
|
||||||
let options = cairo_font_options_create();
|
let options = cairo_font_options_create();
|
||||||
let cfont = cairo_scaled_font_create(face, to_unsafe_ptr(&fontmatrix),
|
let cfont = cairo_scaled_font_create(face, to_unsafe_ptr(&fontmatrix),
|
||||||
to_unsafe_ptr(&idmatrix), options);
|
to_unsafe_ptr(&idmatrix), options);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue