diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-family/document.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-family/document.qmd
index 095855317ba..c068b1c0420 100644
--- a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-family/document.qmd
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-family/document.qmd
@@ -19,7 +19,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- - '#set text\(font: \("Georgia", "serif"\)\); #table\('
+ - '#{set text\(font: \("Georgia", "serif"\)\); table\('
- []
---
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-size/document.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-size/document.qmd
index 29abfa1aec1..6b628220b22 100644
--- a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-size/document.qmd
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-size/document.qmd
@@ -19,7 +19,7 @@ _quarto:
typst:
ensureTypstFileRegexMatches:
-
- - '#\[\s*#set text\(size: 6pt\); #table\('
+ - '#{set text\(size: 6pt\); table\('
- []
---
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/div-font-style-italic.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/div-font-style-italic.qmd
new file mode 100644
index 00000000000..98d7ba9cb89
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/div-font-style-italic.qmd
@@ -0,0 +1,32 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '#block\[\s*#set text\(style: "italic"\); Italic div\s*\]'
+ - []
+---
+
+::: {style="font-style: italic"}
+
+Italic div
+
+:::
+
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-italic.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-italic.qmd
new file mode 100644
index 00000000000..4ee03425f7b
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-italic.qmd
@@ -0,0 +1,31 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '\[#set text\(style: "italic"\); B\]'
+ - []
+---
+
+```{=html}
+
+```
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-normal.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-normal.qmd
new file mode 100644
index 00000000000..ffb5d519640
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-normal.qmd
@@ -0,0 +1,31 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '\[#set text\(style: "normal"\); B\]'
+ - []
+---
+
+```{=html}
+
+```
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-oblique.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-oblique.qmd
new file mode 100644
index 00000000000..bbdd55add35
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-style/td-font-style-oblique.qmd
@@ -0,0 +1,31 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '\[#set text\(style: "oblique"\); B\]'
+ - []
+---
+
+```{=html}
+
+```
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/div-font-weight-demi-bold.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/div-font-weight-demi-bold.qmd
new file mode 100644
index 00000000000..c566e82541a
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/div-font-weight-demi-bold.qmd
@@ -0,0 +1,32 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '#block\[\s*#set text\(weight: "semibold"\); Demi-bold div\s*\]'
+ - []
+---
+
+::: {style="font-weight: demi-bold"}
+
+Demi-bold div
+
+:::
+
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-bold.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-bold.qmd
new file mode 100644
index 00000000000..71585f94638
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-bold.qmd
@@ -0,0 +1,31 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '\[#set text\(fill: rgb\(255, 0, 255\)\); B\]'
+ - []
+---
+
+```{=html}
+
+```
+
diff --git a/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-ultra-light.qmd b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-ultra-light.qmd
new file mode 100644
index 00000000000..aa947fa4e09
--- /dev/null
+++ b/dev-docs/feature-format-matrix/qmd-files/css-properties/font-weight/td-font-weight-ultra-light.qmd
@@ -0,0 +1,31 @@
+---
+format:
+ html:
+ quality: 1
+ pdf:
+ quality: na
+ typst:
+ quality: 2
+ comment: "td, span only"
+ dashboard:
+ quality: 1
+ docx:
+ quality: na
+ pptx:
+ quality: na
+keep-typ: true
+_quarto:
+ tests:
+ typst:
+ ensureTypstFileRegexMatches:
+ -
+ - '\[#set text\(weight: "extralight"\); B\]'
+ - []
+---
+
+```{=html}
+
+```
+
diff --git a/src/resources/filters/modules/typst_css.lua b/src/resources/filters/modules/typst_css.lua
index 1e04cc0a318..5dfc2f8b5d1 100644
--- a/src/resources/filters/modules/typst_css.lua
+++ b/src/resources/filters/modules/typst_css.lua
@@ -598,7 +598,6 @@ end
local same_weights = {
'thin',
'light',
- 'normal',
'regular',
'medium',
'bold',
@@ -606,6 +605,7 @@ local same_weights = {
}
local weight_synonyms = {
+ ['normal'] = 'regular',
['ultra-light'] = 'extra-light',
['demi-bold'] = 'semi-bold',
['ultra-bold'] = 'extra-bold',
@@ -613,11 +613,8 @@ local weight_synonyms = {
local dashed_weights = {
'extra-light',
- 'ultra-light',
'semi-bold',
- 'demi-bold',
'extra-bold',
- 'ultra-bold',
}
local function translate_font_weight(w, warnings)
@@ -625,13 +622,15 @@ local function translate_font_weight(w, warnings)
local num = tonumber(w)
if num and 1 <= num and num <= 1000 then
return num
- elseif tcontains(same_weights, w) then
+ end
+ w = weight_synonyms[w] or w
+ if tcontains(same_weights, w) then
return w
- elseif tcontains(dashed_weights, w) then
- w = weight_synonyms[w] or w
+ end
+ if tcontains(dashed_weights, w) then
return w:gsub('-', '')
else
- output_warning(warnings, 'invalid font weight ' .. tostring(w))
+ output_warning(null, 'invalid font weight ' .. tostring(w))
return nil
end
end
@@ -770,6 +769,8 @@ local function expand_side_shorthand(items, context, warnings)
end
return {
+ quote = quote,
+ dequote = dequote,
set_brand_mode = set_brand_mode,
parse_color = parse_color,
parse_opacity = parse_opacity,
diff --git a/src/resources/filters/quarto-post/typst-css-property-processing.lua b/src/resources/filters/quarto-post/typst-css-property-processing.lua
index 5dba2f4a80e..9ed32fc69e7 100644
--- a/src/resources/filters/quarto-post/typst-css-property-processing.lua
+++ b/src/resources/filters/quarto-post/typst-css-property-processing.lua
@@ -170,6 +170,10 @@ function render_typst_css_property_processing()
opacity = _quarto.format.typst.css.parse_opacity(v, _warnings)
elseif k == 'font-size' then
cell.attributes['typst:text:size'] = _quarto.format.typst.css.translate_length(v, _warnings)
+ elseif k == 'font-weight' then
+ cell.attributes['typst:text:weight'] = _quarto.format.typst.css.quote(_quarto.format.typst.css.translate_font_weight(v, _warnings))
+ elseif k == 'font-style' then
+ cell.attributes['typst:text:style'] = _quarto.format.typst.css.quote(v)
elseif k == 'vertical-align' then
local a = translate_vertical_align(v)
if a then table.insert(aligns, a) end
@@ -306,6 +310,10 @@ function render_typst_css_property_processing()
div.attributes['typst:text:font'] = _quarto.format.typst.css.translate_font_family_list(v)
elseif k == 'font-size' then
div.attributes['typst:text:size'] = _quarto.format.typst.css.translate_length(v, _warnings)
+ elseif k == 'font-weight' then
+ div.attributes['typst:text:weight'] = _quarto.format.typst.css.quote(_quarto.format.typst.css.translate_font_weight(v, _warnings))
+ elseif k == 'font-style' then
+ div.attributes['typst:text:style'] = _quarto.format.typst.css.quote(v)
elseif k == 'background-color' then
div.attributes['typst:fill'] = _quarto.format.typst.css.output_color(_quarto.format.typst.css.parse_color(v, _warnings), nil, _warnings)
elseif k == 'color' then
diff --git a/tests/docs/smoke-all/typst/gt-islands.qmd b/tests/docs/smoke-all/typst/gt-islands.qmd
index 1135ad87154..6f80c9ac663 100644
--- a/tests/docs/smoke-all/typst/gt-islands.qmd
+++ b/tests/docs/smoke-all/typst/gt-islands.qmd
@@ -11,7 +11,7 @@ _quarto:
tests:
typst:
ensureTypstFileRegexMatches:
- - ['#set text\(size: 1.25em , fill: rgb\("#333333"\)\); Large Landmasses of the World']
+ - ['#set text\(size: 1\.25em , weight: "regular" , fill: rgb\("#333333"\)\); Large Landmasses of the World']
- []
---