1. petermr
  2. pdfToSvg

Commits

petermr  committed f690d9f Draft

fixed fill/stroke bug

  • Participants
  • Parent commits 5932f48
  • Branches default

Comments (0)

Files changed (1)

File src/main/java/org/xmlcml/graphics/pdf2svg/raw/PDFPage2SVGConverter.java

View file
 			createAndReOrientateTextPosition(text, currentSvgText);
 			checkIfFontSizeChanged(text, currentSvgText);
 			CheckIfClipPathChanged();
-			String formatFont = fmtFont(font);
-			if (hasChanged(currentFormatFont, formatFont)) {
-				createNewG = true;
-				currentFormatFont = formatFont;
-			}
+			CheckIfCurrentFontDescriptorChanged();
 
 			checkIfFontFamilyChanged();
-
-//			currentFontWeight = currentSvgText.createAndSetFontWeight().toLowerCase();
-//			currentSvgText.setFontWeight((FontWeight) null);
-//			currentFontStyle = currentSvgText.createAndSetFontStyle().toLowerCase();
-//			currentSvgText.setFontStyle((FontStyle) null);
-
 			checkStrokeUnchanged(currentSvgText);
 
 			currentSvgText.format(3);
 		}
 	}
 
+	private void CheckIfCurrentFontDescriptorChanged() {
+		String formatFont = fmtFont(font);
+		if (hasChanged(currentFormatFont, formatFont)) {
+			createNewG = true;
+			currentFormatFont = formatFont;
+		}
+	}
+
 	private void checkIfFontFamilyChanged() {
 		String fontFamily = getFontFamilyFromFamilyOrName();
 		if (hasChanged(currentFontFamily, fontFamily)) {
 	}
 
 	public void fillPath(int windingRule) throws IOException {
-		PDColorState colorState = getGraphicsState().getNonStrokingColor();
+		PDColorState colorState = getGraphicsState().getNonStrokingColor(); // something's muddled
+//		PDColorState colorState = getGraphicsState().getStrokingColor();
 		Paint currentPaint = getCurrentPaint(colorState, "non-stroking");
 		LOG.trace("non-stroke "+currentPaint);
 		createAndAddSVGPath(windingRule, currentPaint);
 			generalPath.setWindingRule(windingRule);
 		}
 		SVGPath svgPath = new SVGPath(generalPath);
-		if (windingRule == null) {
+		if (windingRule != null) {
 			svgPath.setFill(getCSSColor(currentPaint));
 		} else {
 			svgPath.setStroke(getCSSColor(currentPaint));
 	}
 
 	public void strokePath() throws IOException {
-		PDColorState colorState = getGraphicsState().getStrokingColor();
+		PDColorState colorState = getGraphicsState().getStrokingColor(); // Something's muddled
+//		PDColorState colorState = getGraphicsState().getNonStrokingColor();
 		Paint currentPaint = getCurrentPaint(colorState, "stroking");
 		createAndAddSVGPath((Integer) null, currentPaint);