Auto merge of #426 - pcwalton:text-baseline-c, r=pcwalton
Expose `CanvasRenderingContext2D::set_text_baseline()` to C. Closes #425.
This commit is contained in:
commit
bad735e88d
23
c/src/lib.rs
23
c/src/lib.rs
|
@ -13,7 +13,7 @@
|
||||||
use font_kit::handle::Handle;
|
use font_kit::handle::Handle;
|
||||||
use gl;
|
use gl;
|
||||||
use pathfinder_canvas::{Canvas, CanvasFontContext, CanvasRenderingContext2D, FillStyle, LineJoin};
|
use pathfinder_canvas::{Canvas, CanvasFontContext, CanvasRenderingContext2D, FillStyle, LineJoin};
|
||||||
use pathfinder_canvas::{Path2D, TextAlign, TextMetrics};
|
use pathfinder_canvas::{Path2D, TextAlign, TextBaseline, TextMetrics};
|
||||||
use pathfinder_color::{ColorF, ColorU};
|
use pathfinder_color::{ColorF, ColorU};
|
||||||
use pathfinder_content::fill::FillRule;
|
use pathfinder_content::fill::FillRule;
|
||||||
use pathfinder_content::outline::ArcDirection;
|
use pathfinder_content::outline::ArcDirection;
|
||||||
|
@ -67,6 +67,13 @@ pub const PF_TEXT_ALIGN_LEFT: u8 = 0;
|
||||||
pub const PF_TEXT_ALIGN_CENTER: u8 = 1;
|
pub const PF_TEXT_ALIGN_CENTER: u8 = 1;
|
||||||
pub const PF_TEXT_ALIGN_RIGHT: u8 = 2;
|
pub const PF_TEXT_ALIGN_RIGHT: u8 = 2;
|
||||||
|
|
||||||
|
pub const PF_TEXT_BASELINE_ALPHABETIC: u8 = 0;
|
||||||
|
pub const PF_TEXT_BASELINE_TOP: u8 = 1;
|
||||||
|
pub const PF_TEXT_BASELINE_HANGING: u8 = 2;
|
||||||
|
pub const PF_TEXT_BASELINE_MIDDLE: u8 = 3;
|
||||||
|
pub const PF_TEXT_BASELINE_IDEOGRAPHIC: u8 = 4;
|
||||||
|
pub const PF_TEXT_BASELINE_BOTTOM: u8 = 5;
|
||||||
|
|
||||||
// `content`
|
// `content`
|
||||||
|
|
||||||
pub const PF_ARC_DIRECTION_CW: u8 = 0;
|
pub const PF_ARC_DIRECTION_CW: u8 = 0;
|
||||||
|
@ -100,6 +107,7 @@ pub type PFLineCap = u8;
|
||||||
pub type PFLineJoin = u8;
|
pub type PFLineJoin = u8;
|
||||||
pub type PFArcDirection = u8;
|
pub type PFArcDirection = u8;
|
||||||
pub type PFTextAlign = u8;
|
pub type PFTextAlign = u8;
|
||||||
|
pub type PFTextBaseline = u8;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct PFTextMetrics {
|
pub struct PFTextMetrics {
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
|
@ -387,6 +395,19 @@ pub unsafe extern "C" fn PFCanvasSetTextAlign(canvas: PFCanvasRef, new_text_alig
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn PFCanvasSetTextBaseline(canvas: PFCanvasRef,
|
||||||
|
new_text_baseline: PFTextBaseline) {
|
||||||
|
(*canvas).set_text_baseline(match new_text_baseline {
|
||||||
|
PF_TEXT_BASELINE_ALPHABETIC => TextBaseline::Alphabetic,
|
||||||
|
PF_TEXT_BASELINE_TOP => TextBaseline::Top,
|
||||||
|
PF_TEXT_BASELINE_HANGING => TextBaseline::Hanging,
|
||||||
|
PF_TEXT_BASELINE_MIDDLE => TextBaseline::Middle,
|
||||||
|
PF_TEXT_BASELINE_IDEOGRAPHIC => TextBaseline::Ideographic,
|
||||||
|
_ => TextBaseline::Bottom,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn PFCanvasSetFillStyle(canvas: PFCanvasRef, fill_style: PFFillStyleRef) {
|
pub unsafe extern "C" fn PFCanvasSetFillStyle(canvas: PFCanvasRef, fill_style: PFFillStyleRef) {
|
||||||
// FIXME(pcwalton): Avoid the copy?
|
// FIXME(pcwalton): Avoid the copy?
|
||||||
|
|
Loading…
Reference in New Issue