🔧 Remove unused text attrs

This commit is contained in:
Elena Torro
2025-10-31 09:22:01 +01:00
parent cc40448cb5
commit eaa3904a3a
4 changed files with 10 additions and 40 deletions

View File

@@ -15,7 +15,7 @@
[app.render-wasm.serializers :as sr]
[app.render-wasm.wasm :as wasm]))
(def ^:const PARAGRAPH-ATTR-U8-SIZE 44)
(def ^:const PARAGRAPH-ATTR-U8-SIZE 12)
(def ^:const SPAN-ATTR-U8-SIZE 64)
(def ^:const MAX-TEXT-FILLS types.fills.impl/MAX-FILLS)
@@ -56,10 +56,7 @@
text-decoration (sr/translate-text-decoration (get paragraph :text-decoration))
text-transform (sr/translate-text-transform (get paragraph :text-transform))
line-height (get paragraph :line-height)
letter-spacing (get paragraph :letter-spacing)
typography-ref-file (get paragraph :typography-ref-file)
typography-ref-id (get paragraph :typography-ref-id)]
letter-spacing (get paragraph :letter-spacing)]
(-> offset
(mem/write-u8 dview text-align)
@@ -70,8 +67,6 @@
(mem/write-f32 dview line-height)
(mem/write-f32 dview letter-spacing)
(mem/write-uuid dview (d/nilv typography-ref-file uuid/zero))
(mem/write-uuid dview (d/nilv typography-ref-id uuid/zero))
(mem/assert-written offset PARAGRAPH-ATTR-U8-SIZE))))
(defn- write-spans
@@ -80,19 +75,18 @@
paragraph-font-weight (-> paragraph :font-weight f/serialize-font-weight)
paragraph-line-height (get paragraph :line-height)]
(reduce (fn [offset span]
(let [font-style (sr/translate-font-style (get span :font-style))
(let [font-style (sr/translate-font-style (get span :font-style "normal"))
font-size (get span :font-size paragraph-font-size)
line-height (get span :line-height paragraph-line-height)
letter-spacing (get span :letter-spacing)
letter-spacing (get span :letter-spacing 0.0)
font-weight (get span :font-weight paragraph-font-weight)
font-weight (f/serialize-font-weight font-weight)
font-id (f/normalize-font-id (get span :font-id "sourcesanspro"))
font-family (hash (get span :font-family "sourcesanspro"))
font-id (f/normalize-font-id (get span :font-id))
font-family (hash (get span :font-family))
text-buffer (encode-text (get span :text))
text-buffer (encode-text (get span :text ""))
text-length (mem/size text-buffer)
fills (take MAX-TEXT-FILLS (get span :fills))
fills (take MAX-TEXT-FILLS (get span :fills []))
font-variant-id
(get span :font-variant-id)

View File

@@ -168,8 +168,6 @@ export class TextParagraph {
textDirection = 0;
lineHeight = 1.2;
letterSpacing = 0;
typographyRefFile = UUID.ZERO;
typographyRefId = UUID.ZERO;
constructor(init) {
this.textAlign = init?.textAlign ?? TextAlign.LEFT;
@@ -178,8 +176,6 @@ export class TextParagraph {
this.textDirection = init?.textDirection ?? TextDirection.LTR;
this.lineHeight = init?.lineHeight ?? 1.2;
this.letterSpacing = init?.letterSpacing ?? 0.0;
this.typographyRefFile = init?.typographyRefFile ?? UUID.ZERO;
this.typographyRefId = init?.typographyRefId ?? UUID.ZERO;
this.#leaves = init?.leaves ?? [];
if (
!Array.isArray(this.#leaves) ||

View File

@@ -542,8 +542,6 @@ pub struct Paragraph {
text_transform: Option<TextTransform>,
line_height: f32,
letter_spacing: f32,
typography_ref_file: Uuid,
typography_ref_id: Uuid,
children: Vec<TextSpan>,
}
@@ -556,8 +554,6 @@ impl Default for Paragraph {
text_transform: None,
line_height: 1.0,
letter_spacing: 0.0,
typography_ref_file: Uuid::nil(),
typography_ref_id: Uuid::nil(),
children: vec![],
}
}
@@ -572,8 +568,6 @@ impl Paragraph {
text_transform: Option<TextTransform>,
line_height: f32,
letter_spacing: f32,
typography_ref_file: Uuid,
typography_ref_id: Uuid,
children: Vec<TextSpan>,
) -> Self {
Self {
@@ -583,8 +577,6 @@ impl Paragraph {
text_transform,
line_height,
letter_spacing,
typography_ref_file,
typography_ref_id,
children,
}
}
@@ -695,13 +687,8 @@ impl TextSpan {
paint = merge_fills(&self.fills, *content_bounds);
}
// FIXME
if self.line_height <= 0.0 {
style.set_height(paragraph_line_height);
} else {
style.set_height(self.line_height);
}
let max_line_height = f32::max(paragraph_line_height, self.line_height);
style.set_height(max_line_height);
style.set_height_override(true);
style.set_foreground_paint(&paint);
style.set_decoration_type(match self.text_decoration {

View File

@@ -101,8 +101,6 @@ pub struct RawParagraphData {
text_transform: RawTextTransform,
line_height: f32,
letter_spacing: f32,
typography_ref_file: [u32; 4],
typography_ref_id: [u32; 4],
}
impl From<[u8; RAW_PARAGRAPH_DATA_SIZE]> for RawParagraphData {
@@ -226,9 +224,6 @@ impl TryFrom<&Vec<u8>> for RawParagraph {
impl From<RawParagraph> for shapes::Paragraph {
fn from(value: RawParagraph) -> Self {
let typography_ref_file = uuid_from_u32(value.attrs.typography_ref_file);
let typography_ref_id = uuid_from_u32(value.attrs.typography_ref_id);
let mut spans = vec![];
let mut offset = 0;
@@ -252,8 +247,6 @@ impl From<RawParagraph> for shapes::Paragraph {
value.attrs.text_transform.into(),
value.attrs.line_height,
value.attrs.letter_spacing,
typography_ref_file,
typography_ref_id,
spans,
)
}