From 52732b23a6a264849691a303955340a620b96050 Mon Sep 17 00:00:00 2001 From: StratusFearMe21 <57533634+StratusFearMe21@users.noreply.github.com> Date: Thu, 20 Mar 2025 04:03:17 -0600 Subject: [PATCH] impl AsRef<[u8]> for FontData (#5757) * [x] I have followed the instructions in the PR template This PR implements `AsRef<[u8]>` for `FontData`, allowing it to be passed into `fontdb`'s [`Source`](https://docs.rs/fontdb/0.16.2/fontdb/enum.Source.html) type. This would allow `egui` and `cosmic_text` to share font data with eachother --- crates/epaint/src/text/fonts.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index b952b281..ccbf66f9 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -144,6 +144,12 @@ impl FontData { } } +impl AsRef<[u8]> for FontData { + fn as_ref(&self) -> &[u8] { + self.font.as_ref() + } +} + // ---------------------------------------------------------------------------- /// Extra scale and vertical tweak to apply to all text of a certain font.