MCPcopy Index your code
hub / github.com/simstudioai/sim / extractTxPrStyle

Function extractTxPrStyle

apps/sim/lib/pptx-renderer/renderer/chart-renderer.ts:717–760  ·  view source on GitHub ↗

* Extract text color/font size from a txPr node: * txPr > p > pPr > defRPr (solidFill + sz).

(
  parentNode: SafeXmlNode,
  ctx: RenderContext
)

Source from the content-addressed store, hash-verified

715 * txPr > p > pPr > defRPr (solidFill + sz).
716 */
717function extractTxPrStyle(
718 parentNode: SafeXmlNode,
719 ctx: RenderContext
720): { color?: string; fontSize?: number; bold?: boolean; fontFamily?: string } | undefined {
721 const txPr = parentNode.child('txPr')
722 if (!txPr.exists()) return undefined
723
724 for (const p of txPr.children('p')) {
725 const pPr = p.child('pPr')
726 if (!pPr.exists()) continue
727 const defRPr = pPr.child('defRPr')
728 if (!defRPr.exists()) continue
729
730 const style: { color?: string; fontSize?: number; bold?: boolean; fontFamily?: string } = {}
731 const fill = defRPr.child('solidFill')
732 if (fill.exists()) {
733 const c = resolveColorToHex(fill, ctx)
734 if (c) style.color = c
735 }
736 const sz = defRPr.numAttr('sz')
737 if (sz !== undefined && sz > 0) {
738 // OOXML sz is 1/100 pt. Keep renderer's existing px-scale convention.
739 style.fontSize = Math.round(sz / 100)
740 }
741 const b = defRPr.attr('b')
742 if (b === '1' || b === 'true') style.bold = true
743 else if (b === '0' || b === 'false') style.bold = false
744 const latinTypeface = defRPr.child('latin').attr('typeface')
745 const eaTypeface = defRPr.child('ea').attr('typeface')
746 const csTypeface = defRPr.child('cs').attr('typeface')
747 if (latinTypeface || eaTypeface || csTypeface) {
748 style.fontFamily = latinTypeface || eaTypeface || csTypeface
749 }
750
751 if (
752 style.color ||
753 style.fontSize !== undefined ||
754 style.bold !== undefined ||
755 style.fontFamily !== undefined
756 )
757 return style
758 }
759 return undefined
760}
761
762function getChartThemeFontFamily(ctx: RenderContext): string | undefined {
763 return (

Callers 11

parseDataLabelsFunction · 0.85
extractLegendInfoFunction · 0.85
parseAxisNodeFunction · 0.85
buildBarChartOptionFunction · 0.85
buildLineChartOptionFunction · 0.85
buildPieChartOptionFunction · 0.85
buildRadarChartOptionFunction · 0.85
buildScatterChartOptionFunction · 0.85
buildBubbleChartOptionFunction · 0.85
buildStockChartOptionFunction · 0.85

Calls 6

resolveColorToHexFunction · 0.85
childMethod · 0.80
existsMethod · 0.80
childrenMethod · 0.80
numAttrMethod · 0.80
attrMethod · 0.80

Tested by

no test coverage detected