Skip to content

Commit 174b7dc

Browse files
giroletmHackbrettXXX
authored andcommitted
Use dominant-baseline if alignment-baseline is missing (#80) & ctx fix
Fixes #80 Applies the current context before rendering a text node
1 parent c1f4082 commit 174b7dc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/applyparseattributes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ export function parseAttributes(context: Context, svgNode: SvgNode, node?: Eleme
133133

134134
const alignmentBaseline =
135135
getAttribute(domNode, context.styleSheets, 'vertical-align') ||
136-
getAttribute(domNode, context.styleSheets, 'alignment-baseline')
136+
getAttribute(domNode, context.styleSheets, 'alignment-baseline') ||
137+
getAttribute(domNode, context.styleSheets, 'dominant-baseline')
137138
if (alignmentBaseline) {
138139
const matchArr = alignmentBaseline.match(
139140
/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/

src/nodes/text.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { GraphicsNode } from './graphicsnode'
1616
import { Rect } from '../utils/geometry'
1717
import { Matrix } from 'jspdf'
1818
import { SvgNode } from './svgnode'
19-
import { parseAttributes } from '../applyparseattributes'
19+
import { parseAttributes, applyContext } from '../applyparseattributes'
2020

2121
interface TrimInfo {
2222
prevText: string
@@ -153,6 +153,7 @@ export class TextNode extends GraphicsNode {
153153
if (visibility === 'visible') {
154154
const alignmentBaseline = context.attributeState.alignmentBaseline
155155
const textRenderingMode = getTextRenderingMode(context.attributeState)
156+
applyContext(context)
156157
context.pdf.text(transformedText, textX + dx - xOffset, textY + dy, {
157158
baseline: mapAlignmentBaseline(alignmentBaseline),
158159
angle: context.transform,

0 commit comments

Comments
 (0)