Skip to content

Commit

Permalink
transcoder: fix KEY_ALTERNATE_STYLESHEET support in `CSSTranscoding…
Browse files Browse the repository at this point in the history
…Helper`
  • Loading branch information
carlosame committed Sep 5, 2023
1 parent bd4c06b commit 9a0129c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,11 @@ public void testCSS3Print() throws TranscoderException, IOException {
testPrint("samples/tests/spec2/styling/css3.html", 5);
}

@Test
public void testCSS3AlternateStylesheet() throws TranscoderException, IOException {
testAlternate("samples/tests/spec2/styling/css3.html", "Gray", false, 5);
}

@Test
public void testCSS3Dark() throws TranscoderException, IOException {
testDark("samples/tests/spec2/styling/css3.html", 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ private void transcodeDOMDocument(DOMDocument document, TranscoderOutput output,

// If there is an alternate style sheet, set it
if (alt != null && (alt = alt.trim()).length() != 0) {
document.enableStyleSheetsForSet(alt);
document.setSelectedStyleSheetSet(alt);
}

// Now fill the SVG document with computed styles
Expand Down
11 changes: 11 additions & 0 deletions samples/tests/resources/style/gray.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
circle {
fill: #9a9a9a60 ! important;
stroke-width: 8px ! important;
}
ellipse {
fill: #7070704f ! important;
stroke-width: calc(2px + 0.2em) ! important;
}
text {
font-size: calc(2*5pt + .36em) ! important;
}
1 change: 1 addition & 0 deletions samples/tests/spec2/styling/css3.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<!-- ====================================================================== -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="alternate stylesheet" type="text/css" title="Gray" href="../../resources/style/gray.css"/>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" id="theSVG">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9a0129c

Please sign in to comment.