Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

feat(text): optional text-stroke for hollow/outlined glyphs

sergioerm21b466d5f719
diff --git a/slides/src/model.ts b/slides/src/model.ts
index 54082973..3b9b4eb5 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -117,6 +117,10 @@ export interface TextElement extends ElementBase {
lineHeight: number
/** px; optional tracking for letter-spaced caps labels */
letterSpacing?: number
+ /** Outline / hollow glyphs via -webkit-text-stroke. `fill:'none'` makes the
+ * interior transparent (the classic hollow section-break word); default keeps
+ * the solid `color` fill and just adds an outline. */
+ textStroke?: { width: number; color: string; fill?: string }
/**
* Layout placeholder prompt ("Click to add title"). While the element's
* html is empty: the editor shows this dimmed; present and print hide the
diff --git a/slides/src/render.ts b/slides/src/render.ts
index 89610716..b3f02422 100644
--- a/slides/src/render.ts
+++ b/slides/src/render.ts
@@ -412,6 +412,11 @@ export function renderElement(el: SlideElement, doc: BentoDoc, opts: RenderOpts
inner.style.fontFamily = el.fontFamily || doc.theme.fontFamily
inner.style.fontWeight = String(el.fontWeight)
inner.style.color = el.color
+ const ts = el.textStroke
+ if (ts && ts.width) {
+ inner.style.setProperty('-webkit-text-stroke', `${ts.width}px ${ts.color}`)
+ if (ts.fill === 'none') inner.style.color = 'transparent'
+ }
inner.style.textAlign = el.align
inner.style.lineHeight = String(el.lineHeight)
if (el.letterSpacing) inner.style.letterSpacing = `${el.letterSpacing}px`