extra fonts plus dynamic fonts
This commit is contained in:
parent
a742c1b034
commit
1ddf7abe6f
4 changed files with 46 additions and 27 deletions
|
@ -1,5 +1,12 @@
|
|||
package stirling.software.SPDF.controller.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -65,8 +72,22 @@ public class GeneralWebController {
|
|||
@Hidden
|
||||
public String signForm(Model model) {
|
||||
model.addAttribute("currentPage", "sign");
|
||||
model.addAttribute("fonts", getFontNames());
|
||||
return "sign";
|
||||
}
|
||||
private List<String> getFontNames() {
|
||||
try {
|
||||
return Files.list(Paths.get("src/main/resources/static/fonts"))
|
||||
.map(Path::getFileName)
|
||||
.map(Path::toString)
|
||||
.filter(name -> name.endsWith(".woff2"))
|
||||
.map(name -> name.substring(0, name.length() - 6)) // Remove .woff2 extension
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read font directory", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/crop")
|
||||
@Hidden
|
||||
|
|
BIN
src/main/resources/static/fonts/DancingScript-Regular.woff2
Normal file
BIN
src/main/resources/static/fonts/DancingScript-Regular.woff2
Normal file
Binary file not shown.
BIN
src/main/resources/static/fonts/IndieFlower-Regular.woff2
Normal file
BIN
src/main/resources/static/fonts/IndieFlower-Regular.woff2
Normal file
Binary file not shown.
|
@ -7,16 +7,20 @@
|
|||
<script src="js/thirdParty/interact.min.js"></script>
|
||||
|
||||
</head>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Estonia';
|
||||
src: url(fonts/Estonia.woff2) format('woff2');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Tangerine';
|
||||
src: url(fonts/Tangerine.woff2) format('woff2');
|
||||
}
|
||||
</style>
|
||||
<th:block th:each="font : ${fonts}">
|
||||
<style th:inline="text">
|
||||
@font-face {
|
||||
font-family: "[[${font}]]";
|
||||
src: url('fonts/[[${font}]].woff2') format('woff2');
|
||||
}
|
||||
|
||||
#font-select option[value="[[${font}]]"] {
|
||||
font-family: "[[${font}]]", cursive;
|
||||
}
|
||||
</style>
|
||||
</th:block>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="page-container">
|
||||
<div id="content-wrap">
|
||||
|
@ -169,9 +173,9 @@
|
|||
<input type="text" class="form-control" id="sigText" name="sigText">
|
||||
<label th:text="#{font}"></label>
|
||||
<select class="form-control" name="font" id="font-select">
|
||||
<option value="Estonia" class="estonia-font">Estonia</option>
|
||||
<option value="Tangerine" class="tangerine-font">Tangerine</option>
|
||||
</select>
|
||||
<option th:each="font : ${fonts}" th:value="${font}" th:text="${font}" th:class="${font.toLowerCase()+'-font'}"></option>
|
||||
|
||||
</select>
|
||||
<div class="margin-auto-parent">
|
||||
<button id="save-text-signature" class="btn btn-outline-success mt-2 margin-center" onclick="addDraggableFromText()" th:text="#{sign.add}"></button>
|
||||
</div>
|
||||
|
@ -196,20 +200,14 @@
|
|||
DraggableUtils.createDraggableCanvasFromUrl(dataURL);
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#font-select option {
|
||||
font-size: 30px;
|
||||
}
|
||||
#font-select option[value="Estonia"] {
|
||||
font-family: 'Estonia', sans-serif;
|
||||
}
|
||||
#font-select option[value="Tangerine"] {
|
||||
font-family: 'Tangerine', cursive;
|
||||
}
|
||||
#font-select option[value="Windsong"] {
|
||||
font-family: 'Windsong', cursive;
|
||||
}
|
||||
</style>
|
||||
<th:block th:each="font : ${fonts}">
|
||||
<style th:inline="text">
|
||||
#font-select option[value="/*[[${font}]]*/"] {
|
||||
font-family: '/*[[${font}]]*/', cursive;
|
||||
}
|
||||
</style>
|
||||
</th:block>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue