Libfontconfig dependency is causing huge startup times in Android (20 seconds on each page load!). On other platforms fontconfig caches are already available or can be prebuilt on installation scripts, but this can't be done on Android. Updating libfontconfig dependency doesn't fix the problem either. This PR gets rid of libfontconfig in Android. It queries available fonts and variations from Android System font configuration files. Android doesn't provide an API to query system fonts until Android O (which is very far from the minimum API right now...) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #16195 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: f388c0ab1e4df8cbd94d58eb7657f36baaf813fe
60 lines
1.6 KiB
Rust
60 lines
1.6 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
pub use platform::freetype::{font, font_context};
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
pub use platform::freetype::{font_list, font_template};
|
|
|
|
#[cfg(target_os = "windows")]
|
|
pub use platform::windows::{font, font_context, font_list, font_template};
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub use platform::macos::{font, font_context, font_list, font_template};
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
mod freetype {
|
|
use libc::c_char;
|
|
use std::ffi::CStr;
|
|
use std::str;
|
|
|
|
/// Creates a String from the given null-terminated buffer.
|
|
/// Panics if the buffer does not contain UTF-8.
|
|
unsafe fn c_str_to_string(s: *const c_char) -> String {
|
|
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned()
|
|
}
|
|
|
|
pub mod font;
|
|
pub mod font_context;
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub mod font_list;
|
|
#[cfg(target_os = "android")]
|
|
mod android {
|
|
pub mod font_list;
|
|
}
|
|
#[cfg(target_os = "android")]
|
|
pub use self::android::font_list;
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
pub mod font_template;
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
mod macos {
|
|
pub mod font;
|
|
pub mod font_context;
|
|
pub mod font_list;
|
|
pub mod font_template;
|
|
}
|
|
|
|
#[cfg(target_os = "windows")]
|
|
mod windows {
|
|
pub mod font;
|
|
pub mod font_context;
|
|
pub mod font_list;
|
|
pub mod font_template;
|
|
}
|