1use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8#[derive(Debug, Clone, Copy)]
10pub struct TextStyle<'m, 's> {
11 record: Record<'m, 's>,
12}
13
14impl<'m, 's> TextStyle<'m, 's> {
15 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
16 Self { record }
17 }
18
19 pub fn id(&self) -> EntityId {
21 self.record.id
22 }
23
24 pub fn name(&self) -> StyleResult<Option<&'m str>> {
26 self.record.optional_text("Name")
27 }
28
29 pub fn text_character_appearance(&self) -> StyleResult<Option<EntityId>> {
31 self.record
32 .optional_ref("TextCharacterAppearance", "IfcTextStyleForDefinedFont")
33 }
34
35 pub fn text_style(&self) -> StyleResult<Option<EntityId>> {
38 self.record.optional_ref_select(
39 "TextStyle",
40 "IfcTextStyleSelect",
41 &[
42 "IfcTextStyleTextModel",
43 "IfcTextStyleWithBoxCharacteristics",
44 ],
45 )
46 }
47
48 pub fn text_font_style(&self) -> StyleResult<EntityId> {
51 self.record.required_ref_select(
52 "TextFontStyle",
53 "IfcTextFontSelect",
54 &["IfcExternallyDefinedTextFont", "IfcPreDefinedTextFont"],
55 )
56 }
57
58 pub fn model_or_draughting(&self) -> StyleResult<Option<bool>> {
61 self.record.optional_bool("ModelOrDraughting")
62 }
63}
64
65#[derive(Debug, Clone, Copy)]
67pub struct TextStyleFontModel<'m, 's> {
68 record: Record<'m, 's>,
69}
70
71impl<'m, 's> TextStyleFontModel<'m, 's> {
72 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
73 Self { record }
74 }
75
76 pub fn name(&self) -> StyleResult<&'m str> {
78 self.record.required_text("Name")
79 }
80
81 pub fn font_family(&self) -> StyleResult<Option<&'m Value>> {
83 self.record.optional_raw("FontFamily")
84 }
85
86 pub fn font_style(&self) -> StyleResult<Option<&'m Value>> {
88 self.record.optional_raw("FontStyle")
89 }
90
91 pub fn font_variant(&self) -> StyleResult<Option<&'m Value>> {
93 self.record.optional_raw("FontVariant")
94 }
95
96 pub fn font_weight(&self) -> StyleResult<Option<&'m Value>> {
98 self.record.optional_raw("FontWeight")
99 }
100
101 pub fn font_size(&self) -> StyleResult<&'m Value> {
103 self.record.value("FontSize")
104 }
105}