mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
[gfx] [layout] [style] Upgrade unicode-bidi to 0.3
This commit is contained in:
parent
594479fe15
commit
14c524df4f
10 changed files with 61 additions and 34 deletions
|
@ -37,6 +37,7 @@ smallvec = "0.3"
|
|||
style = {path = "../style"}
|
||||
style_traits = {path = "../style_traits"}
|
||||
time = "0.1.12"
|
||||
unicode-bidi = {version = "0.3", features = ["with_serde"]}
|
||||
unicode-script = {version = "0.1", features = ["harfbuzz"]}
|
||||
webrender_traits = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
xi-unicode = "0.1.0"
|
||||
|
|
|
@ -69,6 +69,7 @@ extern crate smallvec;
|
|||
extern crate style;
|
||||
extern crate style_traits;
|
||||
extern crate time;
|
||||
extern crate unicode_bidi;
|
||||
extern crate unicode_script;
|
||||
extern crate webrender_traits;
|
||||
extern crate xi_unicode;
|
||||
|
|
|
@ -13,6 +13,7 @@ use std::slice::Iter;
|
|||
use std::sync::Arc;
|
||||
use style::str::char_is_whitespace;
|
||||
use text::glyph::{ByteIndex, GlyphStore};
|
||||
use unicode_bidi as bidi;
|
||||
use webrender_traits;
|
||||
use xi_unicode::LineBreakIterator;
|
||||
|
||||
|
@ -32,7 +33,7 @@ pub struct TextRun {
|
|||
pub font_key: webrender_traits::FontKey,
|
||||
/// The glyph runs that make up this text run.
|
||||
pub glyphs: Arc<Vec<GlyphRun>>,
|
||||
pub bidi_level: u8,
|
||||
pub bidi_level: bidi::Level,
|
||||
pub extra_word_spacing: Au,
|
||||
}
|
||||
|
||||
|
@ -179,7 +180,7 @@ impl<'a> Iterator for CharacterSliceIterator<'a> {
|
|||
}
|
||||
|
||||
impl<'a> TextRun {
|
||||
pub fn new(font: &mut Font, text: String, options: &ShapingOptions, bidi_level: u8) -> TextRun {
|
||||
pub fn new(font: &mut Font, text: String, options: &ShapingOptions, bidi_level: bidi::Level) -> TextRun {
|
||||
let glyphs = TextRun::break_and_shape(font, &text, options);
|
||||
TextRun {
|
||||
text: Arc::new(text),
|
||||
|
@ -340,7 +341,7 @@ impl<'a> TextRun {
|
|||
pub fn natural_word_slices_in_visual_order(&'a self, range: &Range<ByteIndex>)
|
||||
-> NaturalWordSliceIterator<'a> {
|
||||
// Iterate in reverse order if bidi level is RTL.
|
||||
let reverse = self.bidi_level % 2 == 1;
|
||||
let reverse = self.bidi_level.is_rtl();
|
||||
|
||||
let index = if reverse {
|
||||
match self.index_of_first_glyph_run_containing(range.end() - ByteIndex(1)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue