Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  Convert fnt back to bdf
« previous next »
  • Print
Pages: [1]

Author Topic: Convert fnt back to bdf  (Read 196 times)

Offline rockbox_dev123

  • Member
  • *
  • Posts: 78
Convert fnt back to bdf
« on: February 12, 2023, 11:50:37 AM »
I already used the search function and didn't find a suitable reply e.g. https://forums.rockbox.org/index.php/topic,53334.msg246236.html#msg246236

I am maintaining a custom build of rockbox which changes the default theme. The fonts that are used, are only available in .fnt format, so the compilation process of rockbox does not detect the .bdf files and generate the .fnt files in the right directory. Because of this I am having to manually insert theme assets into the built rockbox.zip.

I would like to convert the fnt files back to bdf so that the build process converts them back to fnt.

How can I do this?

(I previously tried compiling ttf2bdf and converting the original Roboto* fonts to bdf but the results were terrible. I also tried fnt2bdf from hxtools and didn't have good results.)
« Last Edit: February 12, 2023, 12:15:55 PM by rockbox_dev123 »
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3531
  • creature
Re: Convert fnt back to bdf
« Reply #1 on: February 12, 2023, 02:05:04 PM »
If you don't want to change the fonts I'd try a different approach: instead of converting them back make the build system aware of fnt files in the font folder, and instead of converting them like the bdf files simply copy them.
Logged

Offline rockbox_dev123

  • Member
  • *
  • Posts: 78
Re: Convert fnt back to bdf
« Reply #2 on: February 12, 2023, 02:44:17 PM »
Thanks for the suggestion. After wasting lots of time trying to convert the ttf files to bdf and then to fnt only to find they still look terrible I've decided to take your suggestion  :)

wps/wpsbuild.py
Code: [Select]
sub copythemefont
{
    my ($font) = @_;
    #copy the font specified by the theme

    mkdir "$tempdir/fonts";
    if (-e "${ROOT}/fonts/${font}")
    {
        #if 'font_foo.fnt' already exists, no need to convert 'font_foo.bdf' to '.fnt'
        #just copy it to the final directory.
        system("cp ${ROOT}/fonts/${font} ${tempdir}/fonts/${font}");
    }
    else
    {
        my $o =~ s/\.fnt/\.bdf/;
        system("$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ");
    }
}

Fingers crossed this will get the job done  ;)

EDIT: updated code
« Last Edit: February 12, 2023, 03:50:29 PM by rockbox_dev123 »
Logged

Offline rockbox_dev123

  • Member
  • *
  • Posts: 78
Re: Convert fnt back to bdf
« Reply #3 on: February 12, 2023, 03:50:18 PM »
The code above has done the job of copying the font file during
Code: [Select]
make zip
However, there is a final caveat.

The SBS (what does this stand for? Status Bar Screen?) defines:
Code: [Select]
# Additional fonts
%Fl(2,12-Roboto-Bold.fnt)

These additional fonts are not caught by wps/wpsbuild.py and are not copied or converted.

I will need to come up with a solution for this!
Logged

Offline rockbox_dev123

  • Member
  • *
  • Posts: 78
Re: Convert fnt back to bdf
« Reply #4 on: February 12, 2023, 04:25:28 PM »
Solution found.

Inside of the WPSLIST I have defined:

Code: [Select]
## This is a hack to include the additional font needed for naranjada.
## As wps/wpslist.py is incapable of including additional fonts
## referenced by a skin's .sbs/.fms/.wps files!
## wpslist.py will combine the Name of "" with ".cfg" and generate:
## .rockbox/themes/.cfg
## rockbox's theme browser doesn't list this file when browsing themes.
<theme>
Name:
Authors:
WPS: no
FMS: no
RWPS: no
SBS: no
RSBS: no

<main>
Font.320x240x(16|24): 12-Roboto-Bold.fnt
</main>
</theme>
Logged

Offline rockbox_dev123

  • Member
  • *
  • Posts: 78
Re: Convert fnt back to bdf
« Reply #5 on: February 19, 2023, 03:40:52 PM »
Bumping this because I found what I think is actually the 'correct' and final solution.

Make the following change to tools/buildzip.pl:

Code: [Select]
@@ -366,9 +366,6 @@
         print($cmd."\n") if $verbose;
         system($cmd);
         chdir("../../");
+       
+        # Copy pre-compiled .fnt files without conversion.
+        system("cp ${ROOT}/fonts/*fnt ${temp_dir}/fonts/");
 
         if($fonts < 2) {
           # fonts-only package, return

Make sure to run:
Code: [Select]
make fullzip
Instead of:
Code: [Select]
make zip
I can now remove the hack I added to WPSLIST!
« Last Edit: February 19, 2023, 03:43:07 PM by rockbox_dev123 »
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  Convert fnt back to bdf
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.036 seconds with 17 queries.