* Extract text color/font size from a txPr node: * txPr > p > pPr > defRPr (solidFill + sz).
( parentNode: SafeXmlNode, ctx: RenderContext )
| 715 | * txPr > p > pPr > defRPr (solidFill + sz). |
| 716 | */ |
| 717 | function 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 | |
| 762 | function getChartThemeFontFamily(ctx: RenderContext): string | undefined { |
| 763 | return ( |
no test coverage detected