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
| | |-+  determine font pixel-heights
« previous next »
  • Print
Pages: [1]

Author Topic: determine font pixel-heights  (Read 2733 times)

Offline lenny

  • Member
  • *
  • Posts: 190
determine font pixel-heights
« on: December 22, 2006, 01:02:52 PM »
what is the easiest way to determine the pixel-height of a font?
Logged

Offline bk

  • Member
  • *
  • Posts: 266
Re: determine font pixel-heights
« Reply #1 on: December 23, 2006, 05:24:55 AM »
http://www.rockbox.org/twiki/bin/view/Main/FontFormat

The height (16 bit value) is stored at an offset of 6 bytes.

edit: misread, actually 16 bit value
« Last Edit: December 23, 2006, 02:10:07 PM by bk »
Logged

Offline lenny

  • Member
  • *
  • Posts: 190
Re: determine font pixel-heights
« Reply #2 on: December 23, 2006, 01:39:35 PM »
I don't have the knowledge of how to read the 32 bit value offset 6 bytes in the header... How would I do that? All I'm trying to do is find an alternative to counting the pixels on the screen :P
Logged

Offline Yotto

  • Artist
  • Member
  • *
  • Posts: 826
  • Every Silver Lining has a Cloud
    • My Blog
Re: determine font pixel-heights
« Reply #3 on: December 23, 2006, 02:26:01 PM »
I always look to see how many lines fit on the screen, and divide the screen height by that.

Not much better than counting pixels, but hey. :D
Logged
Pulp Audio Weekly - Where we talk about News, Reviews, and pretty much anything else we feel like discussing.

Offline bk

  • Member
  • *
  • Posts: 266
Re: determine font pixel-heights
« Reply #4 on: December 23, 2006, 02:33:24 PM »
Here's a little program that outputs all the header information from a rockbox font file.

Compile with any ANSI C compiler (GCC on any platform should work) and use as follows:
fntinfo font.fnt



[attachment deleted by admin, too old]
Logged

Offline bascule

  • Rockbox Expert
  • Member
  • *
  • Posts: 1298
Re: determine font pixel-heights
« Reply #5 on: December 23, 2006, 03:16:36 PM »
Forgive my ignorance, but doesn't the name give it away?

Nimbus 14 = 14 pixel-high font, no?
Logged
DataBase fanboy and author of the totally overhauled Rockbox Sync Tool

Offline Yotto

  • Artist
  • Member
  • *
  • Posts: 826
  • Every Silver Lining has a Cloud
    • My Blog
Re: determine font pixel-heights
« Reply #6 on: December 23, 2006, 03:27:36 PM »
I think you're right, assuming the font has a number in it.  Many of the fonts in my folder are lacking numbers.
Logged
Pulp Audio Weekly - Where we talk about News, Reviews, and pretty much anything else we feel like discussing.

Offline lenny

  • Member
  • *
  • Posts: 190
Re: determine font pixel-heights
« Reply #7 on: December 23, 2006, 06:01:02 PM »
Wow that's awsome. I've never had anybody respond to me with a program!

Anyway...
used on rockbox_default.fnt

Output:
Code: [Select]
Max width: 1536
Height: 2048
Ascent (baseline): 1792
Total characters: 65536

That can't be right
(I'm on mac 10.4 fyi)
Logged

Offline bk

  • Member
  • *
  • Posts: 266
Re: determine font pixel-heights
« Reply #8 on: December 23, 2006, 07:05:30 PM »
Hmmm, Macs are 64 bit arch, right? That'll screw fntinfo up.

This version should work but may not be ANSI compatible (gcc -ansi doesn't complain though). I'm not totally sure how to write portable C that handles variable int sizes but this should be a decent quick and dirty fix.


[attachment deleted by admin, too old]
Logged

Offline lenny

  • Member
  • *
  • Posts: 190
Re: determine font pixel-heights
« Reply #9 on: December 24, 2006, 01:43:28 AM »
well, thanks. unfortunately the new fntinfo generates the same output for me. I have an old powerpc g4. I tried wikipedia to find out bit architecture info for ya but it's over my head. good news is when I run either fntinfo program on a font file with a number, the output for height is always 256 times the expected answer. For now that will work just fine for me.

Still, it seems like waaaayyy too much work to accomplish such a small thing. Oh well!

Perhaps:
1) all font names should be ended with the pixel height number
2) a chart should exist somewhere in the wiki

I vote for number 1 ;D
Logged

Offline NsN

  • Member
  • *
  • Posts: 1
Re: determine font pixel-heights
« Reply #10 on: January 06, 2007, 07:40:21 PM »
PowerPC macs are big endian and some are 64 Bit.
Shouldn't be very problematic though, i can try to whip something up by tomorrow.

EDIT:
I had some old endian check code lying around. The attached program should work on pretty much any architecture. If for some reason your int is not 4 Bytes you might need to edit the defines at the beginning.

Tested on Pentium M linux and windows and on a G4 Power PC Mac OS 10.4



Bye,
NsN

[attachment deleted by admin, too old]
« Last Edit: January 06, 2007, 09:39:47 PM by NsN »
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  determine font pixel-heights
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.091 seconds with 14 queries.