Skip to content

Commit d4aab83

Browse files
🐛Fix 수학기호 깨짐 해결 및 폰트 경로 임베딩 적용
1 parent 56fb8f9 commit d4aab83

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/main/java/com/mathfusion/domain/ai/rendering/SwitchSvgService.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,22 @@ private String renderLatexToSvg(String latex) {
8080
var domImpl = org.apache.batik.dom.GenericDOMImplementation.getDOMImplementation();
8181
var document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
8282
var svgGen = new org.apache.batik.svggen.SVGGraphics2D(document);
83+
svgGen.getGeneratorContext().setEmbeddedFontsOn(true);
8384
svgGen.setSVGCanvasSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
8485

8586
Graphics2D g2 = (Graphics2D) svgGen.create();
8687
icon.paintIcon(null, g2, 0, 0);
8788
g2.dispose();
8889

8990
StringWriter sw = new StringWriter();
90-
svgGen.stream(sw, true);
91+
svgGen.stream(sw, false);
9192
sw.flush();
9293

9394
String svg = sw.toString()
94-
.replace("font-family:'cmr10'", "font-family:'Noto Sans Symbols', 'DejaVu Sans', sans-serif")
95-
.replace("font-family:'cmmi10'", "font-family:'Noto Sans Symbols', 'DejaVu Sans', sans-serif")
96-
.replace("font-family:'cmsy10'", "font-family:'Noto Sans Symbols', 'DejaVu Sans', sans-serif")
97-
.replace("font-family:'cmex10'", "font-family:'Noto Sans Symbols', 'DejaVu Sans', sans-serif")
98-
.replace("−", "-")
99-
.replace(";", " ");
95+
.replace("font-family:'cmr10'", "font-family:'STIXGeneral','Latin Modern Math','DejaVu Sans',sans-serif")
96+
.replace("font-family:'cmmi10'", "font-family:'STIXGeneral','Latin Modern Math','DejaVu Sans',sans-serif")
97+
.replace("font-family:'cmsy10'", "font-family:'STIXGeneral','Latin Modern Math','DejaVu Sans',sans-serif")
98+
.replace("font-family:'cmex10'", "font-family:'STIXGeneral','Latin Modern Math','DejaVu Sans',sans-serif");
10099

101100
return svg;
102101
} catch (Exception e) {

0 commit comments

Comments
 (0)