mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/18809
This commit is contained in:
parent
fe16c1d5c3
commit
11c64178d8
142 changed files with 1635 additions and 1685 deletions
|
@ -15,7 +15,7 @@ unstable = ["simd"]
|
|||
|
||||
[dependencies]
|
||||
app_units = "0.5"
|
||||
bitflags = "1.0"
|
||||
bitflags = "0.7"
|
||||
euclid = "0.15"
|
||||
fnv = "1.0"
|
||||
fontsan = {git = "https://github.com/servo/fontsan"}
|
||||
|
|
|
@ -139,17 +139,17 @@ impl Font {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct ShapingFlags: u8 {
|
||||
pub flags ShapingFlags: u8 {
|
||||
#[doc = "Set if the text is entirely whitespace."]
|
||||
const IS_WHITESPACE_SHAPING_FLAG = 0x01;
|
||||
const IS_WHITESPACE_SHAPING_FLAG = 0x01,
|
||||
#[doc = "Set if we are to ignore ligatures."]
|
||||
const IGNORE_LIGATURES_SHAPING_FLAG = 0x02;
|
||||
const IGNORE_LIGATURES_SHAPING_FLAG = 0x02,
|
||||
#[doc = "Set if we are to disable kerning."]
|
||||
const DISABLE_KERNING_SHAPING_FLAG = 0x04;
|
||||
const DISABLE_KERNING_SHAPING_FLAG = 0x04,
|
||||
#[doc = "Text direction is right-to-left."]
|
||||
const RTL_FLAG = 0x08;
|
||||
const RTL_FLAG = 0x08,
|
||||
#[doc = "Set if word-break is set to keep-all."]
|
||||
const KEEP_ALL_FLAG = 0x10;
|
||||
const KEEP_ALL_FLAG = 0x10,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,8 @@ impl Font {
|
|||
let result = self.shape_cache.borrow_mut().entry(lookup_key).or_insert_with(|| {
|
||||
let start_time = time::precise_time_ns();
|
||||
let mut glyphs = GlyphStore::new(text.len(),
|
||||
options.flags.contains(ShapingFlags::IS_WHITESPACE_SHAPING_FLAG),
|
||||
options.flags.contains(ShapingFlags::RTL_FLAG));
|
||||
options.flags.contains(IS_WHITESPACE_SHAPING_FLAG),
|
||||
options.flags.contains(RTL_FLAG));
|
||||
|
||||
if self.can_do_fast_shaping(text, options) {
|
||||
debug!("shape_text: Using ASCII fast path.");
|
||||
|
@ -211,7 +211,7 @@ impl Font {
|
|||
|
||||
fn can_do_fast_shaping(&self, text: &str, options: &ShapingOptions) -> bool {
|
||||
options.script == Script::Latin &&
|
||||
!options.flags.contains(ShapingFlags::RTL_FLAG) &&
|
||||
!options.flags.contains(RTL_FLAG) &&
|
||||
self.handle.can_do_fast_shaping() &&
|
||||
text.is_ascii()
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
use app_units::Au;
|
||||
use euclid::Point2D;
|
||||
use font::{ShapingFlags, Font, FontTableMethods, FontTableTag, ShapingOptions, KERN};
|
||||
use font::{DISABLE_KERNING_SHAPING_FLAG, Font, FontTableMethods, FontTableTag};
|
||||
use font::{IGNORE_LIGATURES_SHAPING_FLAG, KERN, RTL_FLAG, ShapingOptions};
|
||||
use harfbuzz::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY};
|
||||
use harfbuzz::{hb_blob_create, hb_face_create_for_tables};
|
||||
use harfbuzz::{hb_buffer_create, hb_font_destroy};
|
||||
|
@ -188,7 +189,7 @@ impl ShaperMethods for Shaper {
|
|||
fn shape_text(&self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore) {
|
||||
unsafe {
|
||||
let hb_buffer: *mut hb_buffer_t = hb_buffer_create();
|
||||
hb_buffer_set_direction(hb_buffer, if options.flags.contains(ShapingFlags::RTL_FLAG) {
|
||||
hb_buffer_set_direction(hb_buffer, if options.flags.contains(RTL_FLAG) {
|
||||
HB_DIRECTION_RTL
|
||||
} else {
|
||||
HB_DIRECTION_LTR
|
||||
|
@ -203,7 +204,7 @@ impl ShaperMethods for Shaper {
|
|||
text.len() as c_int);
|
||||
|
||||
let mut features = Vec::new();
|
||||
if options.flags.contains(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG) {
|
||||
if options.flags.contains(IGNORE_LIGATURES_SHAPING_FLAG) {
|
||||
features.push(hb_feature_t {
|
||||
tag: LIGA,
|
||||
value: 0,
|
||||
|
@ -211,7 +212,7 @@ impl ShaperMethods for Shaper {
|
|||
end: hb_buffer_get_length(hb_buffer),
|
||||
})
|
||||
}
|
||||
if options.flags.contains(ShapingFlags::DISABLE_KERNING_SHAPING_FLAG) {
|
||||
if options.flags.contains(DISABLE_KERNING_SHAPING_FLAG) {
|
||||
features.push(hb_feature_t {
|
||||
tag: KERN,
|
||||
value: 0,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use app_units::Au;
|
||||
use font::{Font, FontHandleMethods, FontMetrics, ShapingFlags};
|
||||
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, KEEP_ALL_FLAG};
|
||||
use font::{RunMetrics, ShapingOptions};
|
||||
use platform::font_template::FontTemplateData;
|
||||
use range::Range;
|
||||
|
@ -210,7 +210,7 @@ impl<'a> TextRun {
|
|||
.take_while(|&(_, c)| char_is_whitespace(c)).last() {
|
||||
whitespace.start = slice.start + i;
|
||||
slice.end = whitespace.start;
|
||||
} else if idx != text.len() && options.flags.contains(ShapingFlags::KEEP_ALL_FLAG) {
|
||||
} else if idx != text.len() && options.flags.contains(KEEP_ALL_FLAG) {
|
||||
// If there's no whitespace and word-break is set to
|
||||
// keep-all, try increasing the slice.
|
||||
continue;
|
||||
|
@ -224,7 +224,7 @@ impl<'a> TextRun {
|
|||
}
|
||||
if whitespace.len() > 0 {
|
||||
let mut options = options.clone();
|
||||
options.flags.insert(ShapingFlags::IS_WHITESPACE_SHAPING_FLAG);
|
||||
options.flags.insert(IS_WHITESPACE_SHAPING_FLAG);
|
||||
glyphs.push(GlyphRun {
|
||||
glyph_store: font.shape_text(&text[whitespace.clone()], &options),
|
||||
range: Range::new(ByteIndex(whitespace.start as isize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue