mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Make shape_text take &str instead of ~str
This commit is contained in:
parent
ae27032299
commit
728c1ae601
1 changed files with 5 additions and 4 deletions
|
@ -3,7 +3,7 @@ extern mod harfbuzz;
|
||||||
export shape_text;
|
export shape_text;
|
||||||
|
|
||||||
use libc::types::common::c99::int32_t;
|
use libc::types::common::c99::int32_t;
|
||||||
use libc::{c_uint, c_int, c_void};
|
use libc::{c_uint, c_int, c_void, c_char};
|
||||||
use font::Font;
|
use font::Font;
|
||||||
use glyph::{Glyph, GlyphPos};
|
use glyph::{Glyph, GlyphPos};
|
||||||
use ptr::{null, addr_of, offset};
|
use ptr::{null, addr_of, offset};
|
||||||
|
@ -36,7 +36,7 @@ use harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
|
||||||
Calculate the layout metrics associated with a some given text
|
Calculate the layout metrics associated with a some given text
|
||||||
when rendered in a specific font.
|
when rendered in a specific font.
|
||||||
"]
|
"]
|
||||||
fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
|
fn shape_text(font: &Font, text: &str) -> ~[Glyph] unsafe {
|
||||||
#debug("shaping text '%s'", text);
|
#debug("shaping text '%s'", text);
|
||||||
|
|
||||||
let face_blob = vec::as_imm_buf(*(*font).buf(), |buf, len| {
|
let face_blob = vec::as_imm_buf(*(*font).buf(), |buf, len| {
|
||||||
|
@ -62,8 +62,9 @@ fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
|
||||||
|
|
||||||
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
|
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
|
||||||
|
|
||||||
str::as_c_str(text, |ctext| {
|
// Using as_buf because it never does a copy - we don't need the trailing null
|
||||||
hb_buffer_add_utf8(buffer, ctext,
|
str::as_buf(text, |ctext, _l| {
|
||||||
|
hb_buffer_add_utf8(buffer, ctext as *c_char,
|
||||||
text.len() as c_int,
|
text.len() as c_int,
|
||||||
0 as c_uint,
|
0 as c_uint,
|
||||||
text.len() as c_int);
|
text.len() as c_int);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue