Skip to content

Commit

Permalink
fix: add text baseline bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
herefishyfish committed Dec 4, 2023
1 parent e7681a1 commit 885b8db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions packages/canvas/src-native/canvas-native/canvas-c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,12 @@ pub extern "C" fn canvas_native_context_get_text_baseline(
) -> *const c_char {
let context = unsafe { &*context };
let ret = match context.get_context().text_baseline() {
TextBaseline::Alphabetic => "alphabetic",
TextBaseline::Bottom => "bottom",
TextBaseline::Hanging => "hanging",
TextBaseline::Ideographic => "ideographic",
TextBaseline::Middle => "middle",
TextBaseline::Top => "top",
TextBaseline::ALPHABETIC => "alphabetic",
TextBaseline::BOTTOM => "bottom",
TextBaseline::HANGING => "hanging",
TextBaseline::IDEOGRAPHIC => "ideographic",
TextBaseline::MIDDLE => "middle",
TextBaseline::TOP => "top",
};
CString::new(ret).unwrap().into_raw()
}
Expand All @@ -1014,14 +1014,14 @@ pub extern "C" fn canvas_native_context_set_text_baseline(
match baseline.to_string_lossy().as_ref() {
"alphabetic" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Alphabetic),
"bottom" => context.get_context_mut().set_text_baseline(TextBaseline::Bottom),
"hanging" => context.get_context_mut().set_text_baseline(TextBaseline::Hanging),
.set_text_baseline(TextBaseline::ALPHABETIC),
"bottom" => context.get_context_mut().set_text_baseline(TextBaseline::BOTTOM),
"hanging" => context.get_context_mut().set_text_baseline(TextBaseline::HANGING),
"ideographic" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Ideographic),
"middle" => context.get_context_mut().set_text_baseline(TextBaseline::Middle),
"top" => context.get_context_mut().set_text_baseline(TextBaseline::Top),
.set_text_baseline(TextBaseline::IDEOGRAPHIC),
"middle" => context.get_context_mut().set_text_baseline(TextBaseline::MIDDLE),
"top" => context.get_context_mut().set_text_baseline(TextBaseline::TOP),
_ => {}
}
}
Expand Down
24 changes: 12 additions & 12 deletions packages/canvas/src-native/canvas-native/canvas-cxx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3630,12 +3630,12 @@ pub fn canvas_native_context_set_text_align(

pub fn canvas_native_context_get_text_baseline(context: &CanvasRenderingContext2D) -> &str {
match context.get_context().text_baseline() {
TextBaseline::Alphabetic => "alphabetic",
TextBaseline::Top => "top",
TextBaseline::Hanging => "hanging",
TextBaseline::Middle => "middle",
TextBaseline::Ideographic => "ideographic",
TextBaseline::Bottom => "bottom",
TextBaseline::ALPHABETIC => "alphabetic",
TextBaseline::TOP => "top",
TextBaseline::HANGING => "hanging",
TextBaseline::MIDDLE => "middle",
TextBaseline::IDEOGRAPHIC => "ideographic",
TextBaseline::BOTTOM => "bottom",
}
}

Expand All @@ -3646,20 +3646,20 @@ pub fn canvas_native_context_set_text_baseline(
match baseline {
"alphabetic" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Alphabetic),
"top" => context.get_context_mut().set_text_baseline(TextBaseline::Top),
.set_text_baseline(TextBaseline::ALPHABETIC),
"top" => context.get_context_mut().set_text_baseline(TextBaseline::TOP),
"hanging" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Hanging),
.set_text_baseline(TextBaseline::HANGING),
"middle" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Middle),
.set_text_baseline(TextBaseline::MIDDLE),
"ideographic" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Ideographic),
.set_text_baseline(TextBaseline::IDEOGRAPHIC),
"bottom" => context
.get_context_mut()
.set_text_baseline(TextBaseline::Bottom),
.set_text_baseline(TextBaseline::BOTTOM),
_ => {}
}
}
Expand Down

0 comments on commit 885b8db

Please sign in to comment.