Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ members = [
"examples/neon-triangle",
"examples/neon-triangle/editor/editor-bridge",
"examples/arm",
"examples/text-width",

# maybe clean this up?
# "fframes-lyon-renderer",
Expand Down
Binary file modified e2e/snapshots/captions/1.5s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/snapshots/captions/5.2s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/snapshots/captions/7s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed e2e/snapshots/text-width/0.5s.png
Binary file not shown.
24 changes: 0 additions & 24 deletions examples/text-width/Cargo.toml

This file was deleted.

Binary file removed examples/text-width/media/NotoSansArabic-subset.ttf
Binary file not shown.
Binary file not shown.
117 changes: 0 additions & 117 deletions examples/text-width/src/lib.rs

This file was deleted.

25 changes: 0 additions & 25 deletions examples/text-width/src/main.rs

This file was deleted.

2 changes: 0 additions & 2 deletions fframes-editor-controller/src/wasm_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,6 @@ impl<TVideo: Video, TMedia: StaticMediaProvider<'static> + 'static> WasmEditor<T
pub fn ingest_font(&self, slice: &[u8]) -> JsValue {
let mut fonts = self.fonts.lock().unwrap();
let face_info = fonts.insert_font(slice.to_vec().into(), None);
// Cache keys name the font, not its bytes, so a replaced font would keep old widths.
self.break_lines_cache.clear();

serde_wasm_bindgen::to_value(&face_info).unwrap()
}
Expand Down
22 changes: 0 additions & 22 deletions fframes-editor-controller/src/wasm_font_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ impl StaticFontFace {
pub struct WasmFontSource {
pub static_fonts: Vec<StaticFontFace>,
pub data: HashMap<FaceInfo, Cow<'static, [u8]>>,
/// The same fonts for measuring text the way the native renderer lays it out.
pub fontdb: fframes::usvgr::fontdb::Database,
/// Faces each font added to `fontdb`, replaced when the font is inserted again.
face_ids: HashMap<FaceInfo, Vec<fframes::usvgr::fontdb::ID>>,
}

impl WasmFontSource {
pub fn new() -> Self {
Self {
static_fonts: vec![],
data: HashMap::new(),
fontdb: fframes::usvgr::fontdb::Database::new(),
face_ids: HashMap::new(),
}
}

Expand Down Expand Up @@ -87,18 +81,6 @@ impl WasmFontSource {
})
}

// Static fonts are shared with fontdb, not copied.
let shared: Arc<dyn AsRef<[u8]> + Send + Sync> = match &data {
Cow::Borrowed(bytes) => Arc::new(*bytes),
Cow::Owned(bytes) => Arc::new(bytes.clone()),
};
for id in self.face_ids.remove(&face_info).into_iter().flatten() {
self.fontdb.remove_face(id);
}
let ids = self
.fontdb
.load_font_source(fframes::usvgr::fontdb::Source::Binary(shared));
self.face_ids.insert(face_info.clone(), ids.to_vec());
self.data.insert(face_info.clone(), data);
Some(face_info)
}
Expand Down Expand Up @@ -155,10 +137,6 @@ impl<'a> fframes::FontSource<'a> for WasmFontSource {
}))
}

fn measure_text(&self, font: &fframes::FontQuery, text: &str) -> Option<f32> {
fframes::measure_text_width(&self.fontdb, font, text)
}

fn add_font(&mut self, _filename: String, _font_data: Arc<dyn AsRef<[u8]> + Sync + Send>) {
unimplemented!(
"Adding fonts for wasm font source must be done through WasmFontSource::insert_font api"
Expand Down
6 changes: 0 additions & 6 deletions fframes/src/font_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,4 @@ pub trait FontSource<'a>: Sync + Send + std::fmt::Debug {
font_style: FontStyle,
font_stretch: FontStretch,
) -> Option<Box<dyn FontFace<'a> + 'a>>;

/// Width of `text` in pixels as the renderer lays it out, see
/// [`crate::measure_text_width`]. `None` falls back to per-character advances.
fn measure_text(&self, _font: &crate::FontQuery, _text: &str) -> Option<f32> {
None
}
}
Loading
Loading