@@ -38,7 +38,7 @@ func (sc StyleContext) ResolveImage(classes string) string {
3838// This unifies all dimension-based image styling, applying position filtering consistently.
3939//
4040// Parameters:
41- // - kind: ImageBlock or ImageInline
41+ // - kind: ImageBlock, ImageInline, or ImageInlineFixed
4242// - imageWidth, imageHeight: pixel dimensions (height only used for ImageInline)
4343// - blockStyle: for block images, optional style spec to inherit from (e.g., "image", "subtitle")
4444// If blockStyle contains "image", this is a standalone block image.
@@ -56,7 +56,8 @@ func (sc StyleContext) ResolveImage(classes string) string {
5656// - Centered only if block has text-align: center
5757//
5858// Inline image behavior:
59- // - Uses em dimensions (width/height converted from pixels using 16px base)
59+ // - ImageInline uses em dimensions (scales with the current text font-size)
60+ // - ImageInlineFixed uses rem dimensions (does not scale with heading/title font-size)
6061// - baseline-style: center for vertical alignment within text
6162// - Applies properties from "image-inline" CSS style
6263// - No margin collapsing (inline images don't participate in margin collapsing)
@@ -70,21 +71,28 @@ func (sc StyleContext) ResolveImageWithDimensions(kind ImageKind, imageWidth, im
7071
7172 props := make (map [KFXSymbol ]any )
7273
73- if kind == ImageInline {
74- return sc .resolveInlineImage (props , imageWidth , imageHeight ), false
74+ if kind == ImageInline || kind == ImageInlineFixed {
75+ return sc .resolveInlineImage (props , imageWidth , imageHeight , kind == ImageInlineFixed ), false
7576 }
7677
7778 return sc .resolveBlockImage (props , imageWidth , blockStyle )
7879}
7980
80- // resolveInlineImage handles ImageInline styling.
81- // Inline images use em dimensions and baseline-style for text alignment.
82- func (sc StyleContext ) resolveInlineImage (props map [KFXSymbol ]any , imageWidth , imageHeight int ) string {
83- const baseFontSizePx = 16.0 // Standard em base size
84-
85- // Convert pixel dimensions to em (using 16px base)
86- widthEm := float64 (imageWidth ) / baseFontSizePx
87- heightEm := float64 (imageHeight ) / baseFontSizePx
81+ // resolveInlineImage handles inline image styling.
82+ // Inline images use baseline-style for text alignment. Most inline images use em
83+ // dimensions so word-art inside normal text scales with the surrounding font.
84+ // Title art uses fixed rem dimensions so h1/h2 font-size does not magnify the
85+ // source image beyond the normal text column.
86+ func (sc StyleContext ) resolveInlineImage (props map [KFXSymbol ]any , imageWidth , imageHeight int , fixed bool ) string {
87+ const baseFontSizePx = 16.0 // Standard CSS pixel base size
88+
89+ // Convert pixel dimensions using a 16px base.
90+ width := float64 (imageWidth ) / baseFontSizePx
91+ height := float64 (imageHeight ) / baseFontSizePx
92+ unit := SymUnitEm
93+ if fixed {
94+ unit = SymUnitRem
95+ }
8896
8997 // Apply properties from "image-inline" CSS style
9098 sc .registry .EnsureBaseStyle ("image-inline" )
@@ -104,9 +112,9 @@ func (sc StyleContext) resolveInlineImage(props map[KFXSymbol]any, imageWidth, i
104112 }
105113
106114 // Add KFX-specific inline image properties
107- props [SymBaselineStyle ] = SymbolValue (SymCenter ) // baseline-style: center
108- props [SymWidth ] = DimensionValue (widthEm , SymUnitEm ) // width in em
109- props [SymHeight ] = DimensionValue (heightEm , SymUnitEm ) // height in em
115+ props [SymBaselineStyle ] = SymbolValue (SymCenter ) // baseline-style: center
116+ props [SymWidth ] = DimensionValue (width , unit )
117+ props [SymHeight ] = DimensionValue (height , unit )
110118
111119 return sc .registry .RegisterResolved (props , 0 , true )
112120}
0 commit comments