WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: luma oled font's on piCore  (Read 2992 times)

Offline lykkedk

  • Full Member
  • ***
  • Posts: 182
luma oled font's on piCore
« on: October 04, 2021, 02:35:25 AM »
Hello here...

I succesfully created some luma.core, luma.oled + freind's .tcz's for using my SSD1322 256x64 oled.
I also compiled font-amatic-sc & font-fredoka-one and created .tcz's for them too.

Well i would like to use some other fonts like the truetype one's, but can't seem to find anything about installing such on piCore?

Alsa i can't figure out howto "see" which font's are availible on my Pi.
I use piCorePlayer 8, which is based on piCore 13, and so i have all the v13.tcz's avalible - nothing special about this.

The luma.core + luma.oled is a oled display driver with python, and a silly quistions are, if the font's must be located when installed in sitepackages where all the other python stuff are placed ?  ::)

Jesper.


Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11696
Re: luma oled font's on piCore
« Reply #1 on: October 04, 2021, 08:29:43 AM »
Hi lykkedk
... Alsa i can't figure out howto "see" which font's are availible on my Pi. ...
To find which extensions contain truetype fonts ....
From a GUI use the  Provides  function in the  Apps  utility and search for:
Code: [Select]
\.ttf
Or from the command line use the  Provides  function in the  tce  utility and search for:
Code: [Select]
\\.ttf
To search for font extensions, use the  Tags/Keywords  function in those utilities and search for:
Code: [Select]
fontSome of the results returned will be font related libraries or programs, so check the extensions  .info  and  .list  files
to make sure they contain what you are looking for.

Offline lykkedk

  • Full Member
  • ***
  • Posts: 182
Re: luma oled font's on piCore
« Reply #2 on: October 04, 2021, 08:40:57 AM »
Thank's Rich... Will look into this!

Btw: i use this mockup to test the oled for now.
I will use a line simulairto this to use some other font's :
Code: [Select]
from fonts.ttf import SomeFont-FooBut nomatter what i try, i got error's about missing font.

The fonts :
Code: [Select]
from fonts.ttf import AmaticSC
from fonts.ttf import FredokaOne
Are working


Code: [Select]
import os
import time
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from fonts.ttf import AmaticSC
from fonts.ttf import FredokaOne
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1322
import RPi.GPIO as GPIO

serial = spi(port=0, device=0, gpio_DC=24, gpio_RST=25)
device = ssd1322(serial)

font25 = ImageFont.truetype(FredokaOne, 25)
font16 = ImageFont.truetype(FredokaOne, 16)

oled_volume = int(55)
str_oled_volume = (str(oled_volume))
with canvas(device) as draw:
    draw.text((0, 0), "Example Text", font=font16)
    draw.text((20, 30), str_oled_volume, font=font16)
time.sleep(4)
Jesper.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11696
Re: luma oled font's on piCore
« Reply #3 on: October 04, 2021, 09:46:16 AM »
Hi lykkedk
I'm pretty sure that's python, and I only know C.

This appears to be what you are using:
https://github.com/pimoroni/fonts-python

Maybe some of the test, setup, __init__  scripts can provide you some clue to getting your font recognized.

Offline lykkedk

  • Full Member
  • ***
  • Posts: 182
Re: luma oled font's on piCore
« Reply #4 on: October 04, 2021, 01:37:48 PM »
Yes...  :)

Installing / creating .tcz and load them at site-packages is the way to go, when only needing a few different font's ...
Thanks man!

Code: [Select]
fontSSL = ImageFont.truetype(SourceSansPro, 16)

SSPBold12 = ImageFont.truetype('/usr/local/lib/python3.8/site-packages/font_source_sans_pro/files/SourceSansPro-Bold.ttf', 12)
SSPBoldIt12 = ImageFont.truetype('/usr/local/lib/python3.8/site-packages/font_source_sans_pro/files/SourceSansPro-BoldIt.ttf', 12)
SSPBold18 = ImageFont.truetype('/usr/local/lib/python3.8/site-packages/font_source_sans_pro/files/SourceSansPro-Bold.ttf', 18)
SSPBoldIt18 = ImageFont.truetype('/usr/local/lib/python3.8/site-packages/font_source_sans_pro/files/SourceSansPro-BoldIt.ttf', 18)

Jesper.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11696
Re: luma oled font's on piCore
« Reply #5 on: October 04, 2021, 07:47:50 PM »
Hi lykkedk
... Thanks man! ...
??? I'm not sure what I did, but you are welcome.

Offline lykkedk

  • Full Member
  • ***
  • Posts: 182
Re: luma oled font's on piCore
« Reply #6 on: October 04, 2021, 11:05:52 PM »
Quote
??? I'm not sure what I did, but you are welcome

You made me realize that I needed Python fonts, not the system fonts.

Jesper.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11696
Re: luma oled font's on piCore
« Reply #7 on: October 04, 2021, 11:16:49 PM »
Hi lykkedk
Well, glad I could help. :)