diff --git a/components/config/opts.rs b/components/config/opts.rs index 293a5f64c10..1f6c6ecad46 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -968,6 +968,11 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult { .as_boolean() .unwrap(); + let enable_subpixel_text_antialiasing = !debug_options.disable_subpixel_aa && PREFS + .get("gfx.subpixel-text-antialiasing.enabled") + .as_boolean() + .unwrap(); + let is_printing_version = opt_match.opt_present("v") || opt_match.opt_present("version"); let opts = Opts { @@ -1003,7 +1008,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult { show_debug_fragment_borders: debug_options.show_fragment_borders, show_debug_parallel_layout: debug_options.show_parallel_layout, enable_text_antialiasing: !debug_options.disable_text_aa, - enable_subpixel_text_antialiasing: !debug_options.disable_subpixel_aa, + enable_subpixel_text_antialiasing: enable_subpixel_text_antialiasing, enable_canvas_antialiasing: !debug_options.disable_canvas_aa, dump_style_tree: debug_options.dump_style_tree, dump_rule_tree: debug_options.dump_rule_tree, diff --git a/ports/libsimpleservo/src/api.rs b/ports/libsimpleservo/src/api.rs index 6b47c9bbc06..d8ed898cc53 100644 --- a/ports/libsimpleservo/src/api.rs +++ b/ports/libsimpleservo/src/api.rs @@ -11,7 +11,7 @@ use servo::euclid::{Length, TypedPoint2D, TypedScale, TypedSize2D, TypedVector2D use servo::msg::constellation_msg::TraversalDirection; use servo::script_traits::{MouseButton, TouchEventType}; use servo::servo_config::opts; -use servo::servo_config::prefs::PREFS; +use servo::servo_config::prefs::{PrefValue, PREFS}; use servo::servo_url::ServoUrl; use servo::style_traits::DevicePixel; use std::cell::{Cell, RefCell}; @@ -34,6 +34,7 @@ pub struct InitOptions { pub width: u32, pub height: u32, pub density: f32, + pub enable_subpixel_text_antialiasing: bool, } /// Delegate resource file reading to the embedder. @@ -115,6 +116,9 @@ pub fn init( })?; // opts::from_cmdline_args expects the first argument to be the binary name. args.insert(0, "servo".to_string()); + + let pref = PrefValue::Boolean(init_opts.enable_subpixel_text_antialiasing); + PREFS.set("gfx.subpixel-text-antialiasing.enabled", pref); opts::from_cmdline_args(&args); } diff --git a/ports/libsimpleservo/src/capi.rs b/ports/libsimpleservo/src/capi.rs index e7b4defdea8..28c036cff56 100644 --- a/ports/libsimpleservo/src/capi.rs +++ b/ports/libsimpleservo/src/capi.rs @@ -45,6 +45,7 @@ pub struct CInitOptions { pub width: u32, pub height: u32, pub density: f32, + pub enable_subpixel_text_antialiasing: bool, } /// The returned string is not freed. This will leak. @@ -75,6 +76,7 @@ fn init( width: opts.width, height: opts.height, density: opts.density, + enable_subpixel_text_antialiasing: opts.enable_subpixel_text_antialiasing, }; let wakeup = Box::new(WakeupCallback::new(wakeup)); diff --git a/ports/libsimpleservo/src/jniapi.rs b/ports/libsimpleservo/src/jniapi.rs index 1475c986b11..f4633429f11 100644 --- a/ports/libsimpleservo/src/jniapi.rs +++ b/ports/libsimpleservo/src/jniapi.rs @@ -596,12 +596,17 @@ fn get_options(env: &JNIEnv, opts: JObject) -> Result<(InitOptions, bool, Option let log = get_non_null_field(env, opts, "enableLogs", "Z")? .z() .map_err(|_| "enableLogs not a boolean")?; + let enable_subpixel_text_antialiasing = + get_non_null_field(env, opts, "enableSubpixelTextAntialiasing", "Z")? + .z() + .map_err(|_| "enableSubpixelTextAntialiasing not a boolean")?; let opts = InitOptions { args, url, width, height, density, + enable_subpixel_text_antialiasing, }; Ok((opts, log, log_str)) } diff --git a/resources/prefs.json b/resources/prefs.json index 375fd7ee9ee..ecdad8c9ba7 100644 --- a/resources/prefs.json +++ b/resources/prefs.json @@ -19,6 +19,7 @@ "dom.webgl2.enabled": false, "dom.webvr.enabled": false, "dom.webvr.event_polling_interval": 500, + "gfx.subpixel-text-antialiasing.enabled": true, "js.asmjs.enabled": true, "js.asyncstack.enabled": false, "js.baseline.enabled": true, diff --git a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/JNIServo.java b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/JNIServo.java index 2184f6e805e..004b91888a5 100644 --- a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/JNIServo.java +++ b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/JNIServo.java @@ -60,6 +60,7 @@ public class JNIServo { public int width = 0; public int height = 0; public float density = 1; + public boolean enableSubpixelTextAntialiasing = true; public String logStr; public boolean enableLogs = false; } diff --git a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoSurface.java b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoSurface.java index a0ca1969542..84dab5500ca 100644 --- a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoSurface.java +++ b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoSurface.java @@ -213,6 +213,7 @@ public class ServoSurface { options.url = mInitialUri == null ? null : mInitialUri; options.logStr = mServoLog; options.enableLogs = true; + options.enableSubpixelTextAntialiasing = false; mServo = new Servo(options, this, surface, mClient, mActivity); }); diff --git a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoView.java b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoView.java index c93db5c170f..fadf71f706d 100644 --- a/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoView.java +++ b/support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoView.java @@ -141,6 +141,7 @@ public class ServoView extends GLSurfaceView options.width = getWidth(); options.height = getHeight(); options.enableLogs = true; + options.enableSubpixelTextAntialiasing = true; DisplayMetrics metrics = new DisplayMetrics(); mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics); options.density = metrics.density;