Skip to content

Commit

Permalink
TextView: Fix missing font (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
TruongQuangSB authored Oct 16, 2024
1 parent d1a5b33 commit b746af2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package org.eclipse.set.application.parts;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -106,7 +108,7 @@ protected void createView(final Composite parent) {
browser.serveUri(PROBLEMS_JSON, this::serveProblems);
browser.serveFile(LAYOUT_XML, "text/plain",
session.getToolboxFile().getLayoutPath());

browser.serveUri("font", this::serveFont);
browser.setToolboxUrl("index.html");
} catch (final Exception e) {
throw new RuntimeException(e);
Expand All @@ -124,6 +126,13 @@ protected void createView(final Composite parent) {
problemsChangeEventHandler);
}

@SuppressWarnings("resource")
private void serveFont(final Response response) throws IOException {
response.setMimeType("application/x-font-ttf");
response.setResponseData(
Files.newInputStream(fontService.getDefaultFont()));
}

@SuppressWarnings("unchecked")
private void serveProblems(
@SuppressWarnings("unused") final Request request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.eclipse.set.core.services.font;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
* Provides fonts.
Expand All @@ -27,4 +28,13 @@ public record FopFont(Path path, String name, String weight, String style) {
* @return a list of fonts to register for fop
*/
Iterable<FopFont> getFopFonts();

/**
* @return the default path of Toolbox Font
*/
@SuppressWarnings("nls")
default Path getDefaultFont() {
return Paths
.get("data/fonts/Open_Sans_Condensed/OpenSans-CondLight.ttf");
}
}

0 comments on commit b746af2

Please sign in to comment.