Using/Changing Fonts used in ETC Modes

As a test, I would try a standard font, but something other than times-roman. The regular zapf dingbats or wingdings might be good ones to try. Free fonts on the net can be really janky at times, so confirm you can successfully swap out a standard font first.

all fonts are working but only in modes like spanish cards. in font patterns mode there are fonts embedded (don’t know where, maybe in the os)… you can see it in the main file.

1 Like

Well that’s actually good news since we can build more patches from Spanish cards. Would like to potentially combine images with fonts…

Hi @jani & @mkunoff

Regarding using new fonts with the Font Patterns mode: you can use whatever font you want, but you need to tell the main.py file where to find the unicode characters (glyphs) inside the font file’s table using a hexadecimal number.

Not all fonts have all the same glyphs included, especially those fonts that use uncommon glyphs like the font that Font Patterns uses. (Modes like Spanish Flash Cards use the section of a font’s table which includes Roman/Latin alphabet glyphs have a higher chance of being included in a font )

You can see the function in the Font Patterns for getting random glyphs within specific ranges (eg: set 1’s range is: 0x1680 - 0x169C) of a font table:

If your font does not have any glyphs in these ranges, you will not see anything on screen. You will need to check where your font has the glyphs you want to use (and then update the main.py file). Sometimes a font’s creator will share a list of the glyphs included as well as their unicode number. If not, this is a helpful tool to see where the glyphs are in the font’s glyph table: http://bluejamesbond.github.io/CharacterMap/

2 Likes

Hey Chris, cool thank you for the tip. Now I can load them in font patterns but I need randoms from multiple ranges in one set like 0x30, 0x39 and 0x41, 0x5a if set to 1 and other (multiple) ranges if set to 2 on third knob and so on… would you provide me a code for doing this?

I tried with…

if set == 0 :
# all of them (or a lot of them…)
return unichr(random.choice(range(0x30, 0x39) + range(0x41, 0x5a)))

… the mode loaded but nothing changed except on the first frame I sometimes saw I pictogram of the second range (0x41, 0x5a).

then I tried that (sorry I’m completely noob in python, just copied it somewhere)…

if set == 0 :
# all of them (or a lot of them…)
return unichr(random.randint(*random.choice([(0x30, 0x39), (0x41, 0x5a)]))

the mode did not load.

Hey, let’s see if we can figure this out together. I want to do the same thing. There is a new utility which was just released to display the character set you want to use. https://patchstorage.com/font/

Maybe someone can help us…

My main problem is that i’ve got no experience in python or other languages as well.

So there are a few examples such as that one i’ve found…


…but no luck so far with combining one of them with the font pattern mode.

The prob is that in many fonts the entire range of characters is interrupted with unwanted symbols like the square or often with an “empty” symbol.

Randoms out of multiple ranges would be very handy for the font modes – or maybe there’s just a code to exclude unwanted symbols (ranges) in the unicode palette of a special font file.

Here’s an idea…

Use a CSV file to store a table of character hex values and only randomize the values in the table. You can use the new Font Mode [utility-Mode FONT] to determine the glyphs you want to use. A little more work for the ETC user, but perfect control over which characters are output.

This is a good idea.

a way to exclude unicodes not present like @jani mentioned, problem is I don’t think there is a way to ‘check’ if the character is valid in PyGame, you just ask for the character and get a something back or the undefined symbol. so there will always be a little work up front to make sure the characters you are utilizing are actually present.

We know the unicode hexas of them so python doesn’t have to check. the question is how to tell python with a simple code to exclude the ranges of unicode hexas we don’t like or maybe just tell Python to pick randoms of multiple ranges we want. Maybe it works like with one of that example codes from that stackoverflow link above… with a csv table for each font file it should also be good but i have no idea how to implement that?

an easy way is to just define an array of ranges:

ranges = [(0x1680, 0x169c), (0x2190, 0x21FF), (0x2200, 0x22FF)]

there are 3 ranges here, but define as many as you like, then do this:

range = ranges[random.randrange(0, len(ranges))]
character = random.randrange(range[0], range[1])

the first line chooses one of the ranges from the array, and the second line chooses a number from that range.

1 Like

Awesome! So my plan is to use the new ‘Font’ mode [ https://patchstorage.com/font/ ] to map out the various dingbat fonts I’ve hoarded. Now, to the lab!..

cool, sounds progressive :wink:

but i really have no clue where to put the new code lines in the main.py of font patterns and font recedes exactly (numbers have to be changed for each font of course).

then it should also be possible to use more fonts in one patch… just an idea… knob 3 set to 0: randoms of all ranges we like of font 1, knob 3 set to 1: all ranges we want from font 2 and so on? all fonts having a relative path like @fanwander’s idea…

T font patterns, already works very similar like this

yes it does. but it’s just limited to randoms out of one range on each knob setting (0-10). i would need randoms out of multiple ranges for each knob-setting and if set to another position the font and then the array of multiple ranges change as well. you know how to combine font patterns and font recedes with owens new code “array of ranges”?

Aaah, ok, understood.
I think you have to do this while initialization.
read all character numbers into a new array by incrementing through all allowed ranges (as described by @oweno). This new array contains all useful character numbers, and now you can do the random read on this array.

thanks i understand that in theory but practically i’ve no clue. a new modification of font patterns or font recedes would be cool to check where the code line(s) should be :wink:

Hello there,

i’ve been able to play with some cool glyphs using font pattern and font recedes and it’s definetely a lot of fun.
I what to try something a little bit different now : instead of loading randomly glyphs, i want to load them in precise order. So I assume i’ve to change the random.int function but i’m very new to programming and i’m lost.
Any help will be very appreciated (and cool for the community i guess) !!
Thanks !

Hey TonyLB,

I do this pretty easily by defining a list of unicode characters in the order I want them then using a counter variable to load them, so if the glyphs i want map to unicode “a”, “F”, “1” and “%”, I’ll include something like:

 glyph_list = ["a", "F", "1","%"]

in the main.py initialization and then include that variable in the global variable list of the draw() with

 global glyph_list

Then, with a counter of some sort, say a variable that counts every time a trigger event happens that I’ll call “triggers”

  if etc.audio_trig : triggers += 1

I can change the list position and load it with something like

 glyph_display = glyph_list[ triggers % len(glyph_list) ]

This will rotate through however many glyphs are included. You just need to do a little homework on which glyph maps to which unicode character.

I’m not great a python, so I’m sure there’s something more elegant out there, but this works for me and

2 Likes

Thank you so much, it’s very nice of you.
I will try that :slight_smile: