Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Nudging Glyphs (Font Editor Deck)

A topic by Ace created 7 days ago Views: 145 Replies: 7
Viewing posts 1 to 5
(1 edit) (+2)

I’ve been making several fonts and I believe a 4-directional shift feature of the active glyph image would help immensely (saves having to redraw the entire glyph just to nudge it).

This is a mock-up to illustrate the interface change idea.

image.png

To avoid accidentally losing glyph details, it should wrap the pixels (as one row or column is removed from the edge, it’s added to the opposite side).

If someone would provide the script for each directional button, that would be wonderful. If it seems useful, perhaps this could be an update to the existing font editor deck.

I’ll be sure to share the fonts I make!

(+3)

Well, the code in these buttons isn't from me directly. I've asked for help (privately) in the past for buttons to nudge my custom fonts around, and more recently I had to ask for help understanding various things that can be done with the image interface.


In this case, image.translate[pos w] does the moving and wrapping around that you want.

And here is a set of working buttons, as requested:

%%WGT0{"w":[{"name":"nudgeleft","type":"button","size":[16,16],"pos":[345,148],"script":"on click do\n c:char.value-32\n f:currfont[]\n f[c]:f[c].translate[(-1,0) 1]\n view[]\nend","font":"mono","text":"<"},{"name":"nudgeright","type":"button","size":[16,16],"pos":[365,148],"script":"on click do\n c:char.value-32\n f:currfont[]\n f[c]:f[c].translate[(1,0) 1]\n view[]\nend","font":"mono","text":">"},{"name":"nudgeup","type":"button","size":[16,16],"pos":[355,129],"script":"on click do\n c:char.value-32\n f:currfont[]\n f[c]:f[c].translate[(0,-1) 1]\n view[]\nend","font":"mono","text":"^"},{"name":"nudgedown","type":"button","size":[16,16],"pos":[355,167],"script":"on click do\n c:char.value-32\n f:currfont[]\n f[c]:f[c].translate[(0,1) 1]\n view[]\nend","font":"mono","text":"v"}],"d":{}}

The arrows aren't as nice as your example, but hopefully this is enough to get you started.

(1 edit) (+3)

Whipped up a quick script for the buttons

on click do
 f:currfont[]
 f[char.value-32]:f[char.value-32].translate[(1,0) 1]
 view[]
end

Just change the (1,0) out for (-1,0) and (0,1) and (0,-1)  for the other directions.


edit: looks like ahm beat me to it haha!

(+3)

Thank you, both of you!

The code worked perfectly.

(5 edits) (+2)

I find myself wanting to make alternate sizes of the same font or use an existing font to build off of for something entirely new.

I find it efficient to copy the source font, increase the height and then drop the baseline of all glyphs and then edit each glyph as needed.

To accommodate adjusting the baseline of the entire font, I made two buttons that translate all glyphs up and down.

on click do
 f:currfont[]
 i:0
 while i<96
  f[i]:f[i].translate[(0,1) 1]
  i:i+1
 end
 view[]
end

I’m unsure if using a while loop is the best way to access all the glyphs of the current font, but this script seems to work fine. (Font glyphs must range from 0 to 95 though.)

I hope some find this feature useful.

And please let me know if there is a better way to translate an entire font.

Developer (1 edit) (+2)

A slightly simpler equivalent would be to use an "each" loop:

each i in range 96
 f[i]:f[i].translate[0,1 1]
end

If "f" were a list of Images, it would be possible to use ".." notation to manipulate every element in-place in the same way:

f..translate[0,1 1]

But this notation cannot be applied to an Interface type like a Font to implicitly iterate over every glyph. Alas!

(+2)

That is so much nicer to read!

on click do
 f:currfont[]
 each i in range 96
  f[i]:f[i].translate[0,1 1]
 end
 view[]
end

Thank you!

Developer(+2)

If you haven't seen it previously, Learn Lil in 10 Minutes is a fast-paced overview of most of Lil's features targeted at folks who already have some exposure to other programming languages.