Skip to content

Commit

Permalink
add default character spacing support
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanhowell5195 committed Aug 31, 2024
1 parent 0d022ce commit fa36982
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Anyone can submit fonts and textures to this plugin, as long as they meet the re
- Fonts/textures must be somewhat high quality. No low-effort submissions.
- Fonts/textures must be somewhat unique from other fonts/textures. Try not to re-use other textures.
- Full credit must be provided. If you are basing a font/texture off of someone else's design, credit them too!
- Font/texture IDs must be in the snake_case format, and only use the characters `a-z`, `0-9`, and underscores.
- Texture IDs must be in the snake_case format, and only use the characters `a-z`, `0-9`, and underscores.
- Font IDs must be in the kebab-case format, and only use the characters `a-z`, `0-9`, and hyphens.

## How to make a submission
To make a submission, create a fork of this repository and edit/upload the necessary files. After all the changes are made, create a pull request and explain what you are adding.
Expand Down Expand Up @@ -251,6 +252,7 @@ If you want to make a font using different characters, please make an issue abou
"text" // The bottom text
],
"flat": true, // The font is a flat plane with no depth (optional)
"characterSpacing": 8, // A default amount of character spacing to use (optional)
"variants": [ // The variants for this font (optional)
{
"id": "variant-id", // The ID of the variant
Expand Down
3 changes: 2 additions & 1 deletion scripts/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async function addTitleText(scene, str, args) {
let width = 0
const cubes = []
const group = new THREE.Group()
for (const char of str) {
for (const [i, char] of Array.from(str).entries()) {
if (char === " ") {
width += 8
continue
Expand Down Expand Up @@ -271,6 +271,7 @@ async function addTitleText(scene, str, args) {
character.add(mesh)
cubes.push(mesh)
}
if (i) max += font.characterSpacing ?? 0
for (const cube of character.children) {
cube.position.x -= width + max
}
Expand Down

0 comments on commit fa36982

Please sign in to comment.