1//todo!(linux) remove
2#[allow(unused)]
3use crate::{
4 Bounds, DevicePixels, Font, FontId, FontMetrics, FontRun, GlyphId, LineLayout, Pixels,
5 PlatformTextSystem, RenderGlyphParams, SharedString, Size,
6};
7use anyhow::Result;
8use collections::HashMap;
9use font_kit::{font::Font as FontKitFont, source::SystemSource, sources::mem::MemSource};
10use parking_lot::RwLock;
11use smallvec::SmallVec;
12use std::borrow::Cow;
13
14pub(crate) struct LinuxTextSystem(RwLock<LinuxTextSystemState>);
15
16struct LinuxTextSystemState {
17 memory_source: MemSource,
18 system_source: SystemSource,
19 fonts: Vec<FontKitFont>,
20 font_selections: HashMap<Font, FontId>,
21 font_ids_by_postscript_name: HashMap<String, FontId>,
22 font_ids_by_family_name: HashMap<SharedString, SmallVec<[FontId; 4]>>,
23 postscript_names_by_font_id: HashMap<FontId, String>,
24}
25
26// todo!(linux): Double check this
27unsafe impl Send for LinuxTextSystemState {}
28unsafe impl Sync for LinuxTextSystemState {}
29
30impl LinuxTextSystem {
31 pub(crate) fn new() -> Self {
32 Self(RwLock::new(LinuxTextSystemState {
33 memory_source: MemSource::empty(),
34 system_source: SystemSource::new(),
35 fonts: Vec::new(),
36 font_selections: HashMap::default(),
37 font_ids_by_postscript_name: HashMap::default(),
38 font_ids_by_family_name: HashMap::default(),
39 postscript_names_by_font_id: HashMap::default(),
40 }))
41 }
42}
43
44impl Default for LinuxTextSystem {
45 fn default() -> Self {
46 Self::new()
47 }
48}
49
50#[allow(unused)]
51impl PlatformTextSystem for LinuxTextSystem {
52 // todo!(linux)
53 fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()> {
54 Ok(())
55 }
56
57 // todo!(linux)
58 fn all_font_names(&self) -> Vec<String> {
59 Vec::new()
60 }
61
62 // todo!(linux)
63 fn all_font_families(&self) -> Vec<String> {
64 Vec::new()
65 }
66
67 // todo!(linux)
68 fn font_id(&self, descriptor: &Font) -> Result<FontId> {
69 Ok(FontId(0))
70 }
71
72 // todo!(linux)
73 fn font_metrics(&self, font_id: FontId) -> FontMetrics {
74 unimplemented!()
75 }
76
77 // todo!(linux)
78 fn typographic_bounds(&self, font_id: FontId, glyph_id: GlyphId) -> Result<Bounds<f32>> {
79 unimplemented!()
80 }
81
82 // todo!(linux)
83 fn advance(&self, font_id: FontId, glyph_id: GlyphId) -> Result<Size<f32>> {
84 unimplemented!()
85 }
86
87 // todo!(linux)
88 fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option<GlyphId> {
89 None
90 }
91
92 // todo!(linux)
93 fn glyph_raster_bounds(&self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
94 unimplemented!()
95 }
96
97 // todo!(linux)
98 fn rasterize_glyph(
99 &self,
100 params: &RenderGlyphParams,
101 raster_bounds: Bounds<DevicePixels>,
102 ) -> Result<(Size<DevicePixels>, Vec<u8>)> {
103 unimplemented!()
104 }
105
106 // todo!(linux)
107 fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
108 LineLayout::default() //TODO
109 }
110
111 // todo!(linux)
112 fn wrap_line(
113 &self,
114 text: &str,
115 font_id: FontId,
116 font_size: Pixels,
117 width: Pixels,
118 ) -> Vec<usize> {
119 unimplemented!()
120 }
121}