Skip to main content

topcoat_font/
view.rs

1use topcoat_core::context::{Cx, app_context};
2use topcoat_view::{AttributeValueViewParts, DynViewPart, HtmlWriter, PartsWriter};
3
4use crate::{Font, FontResolver};
5
6impl DynViewPart for Font {
7    #[track_caller]
8    fn render(&self, cx: &Cx, w: &mut HtmlWriter<'_, '_>) {
9        let _ = app_context::<FontResolver>(cx).resolve(*self, w);
10    }
11}
12
13impl AttributeValueViewParts for Font {
14    #[inline]
15    fn attribute_present(&self) -> bool {
16        true
17    }
18
19    #[inline]
20    fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>) {
21        parts.push_dyn(Box::new(self));
22    }
23}