PGF Binary Format
System: Sony Playstation
Portable (PSP)
Firmware: 1.5 - 3.71 (verified, possibly more)
Format: little endian, low bits/nibble of a byte preceede high bits/nibble
in the input stream
Status: 99.34% (number of bytes with a meaning / total number of bytes)
Written: 2007 by BenHur
Credits: Skylark & Freeplay (for their basic deciphering of pgf files)
PGF files consist of the following blocks:
Those blocks are described in the following sections (type sff26.6 stands for signed fixed float = sl32 / 64.0)
| start | end | size | type | typical value | description |
| 0x0000 | 0x0001 | 2 | us16 | 0 | header offset? |
| 0x0002 | 0x0003 | 2 | us16 | 392 or 412 | header length or data offset |
| 0x0004 | 0x0007 | 4 | char[4] | "PGF0" | pgf-id |
| 0x0008 | 0x000B | 4 | ul32 | 2 or 3 | revision? |
| 0x000C | 0x000F | 4 | ul32 | 6 | version? |
| 0x0010 | 0x0013 | 4 | ul32 | max. 65536 | number of elements in charmap (number of char-glyphs in fontdata) |
| 0x0014 | 0x0017 | 4 | ul32 | max. 512 | number of elements in char_pointer_table |
| 0x0018 | 0x001B | 4 | ul32 | number of bits per element in charmap | |
| 0x001C | 0x001F | 4 | ul32 | number of bits per element in char_pointer_table | |
| 0x0020 | 0x0034 | 21 | ??? | ||
| 0x0035 | 0x0074 | 64 | char[64] | "FTT-NewRodin Pro Latin" | font name |
| 0x0075 | 0x00B4 | 64 | char[64] | "Regular" | font type |
| 0x00B5 | 0x00B5 | 1 | 0 | ??? | |
| 0x00B6 | 0x00B7 | 2 | us16 | first element in charmap | |
| 0x00B8 | 0x00B9 | 2 | us16 | last element in charmap | |
| 0x00BA | 0x00D3 | 26 | ??? | ||
| 0x00D4 | 0x00D7 | 4 | 0 | ??? | |
| 0x00D8 | 0x00DB | 4 | 0 | ??? | |
| 0x00DC | 0x00DF | 4 | sff26.6 | max. left-aligned x-adjustment | |
| 0x00E0 | 0x00E3 | 4 | sff26.6 | max. baseline y-adjustment | |
| 0x00E4 | 0x00E7 | 4 | sff26.6 | min. center-aligned x-adjustment | |
| 0x00E8 | 0x00EB | 4 | sff26.6 | max. top-aligned y-adjustment | |
| 0x00EC | 0x00EF | 4 | sff26.6 | max. x-advance | |
| 0x00F0 | 0x00F3 | 4 | sff26.6 | max. y-advance | |
| 0x00F4 | 0x00F7 | 4 | sff26.6 | max. x-dimension | |
| 0x00F8 | 0x00FB | 4 | sff26.6 | max. y-dimension | |
| 0x00FC | 0x00FD | 2 | us16 | max. glyph-width in fontdata | |
| 0x00FE | 0x00FF | 2 | us16 | max. glyph-height in fontdata | |
| 0x0100 | 0x0101 | 2 | us16 | 4 | ??? |
| 0x0102 | 0x0102 | 1 | ub8 | number of elements in dimension_table | |
| 0x0103 | 0x0103 | 1 | ub8 | number of elements in x_adjust_table | |
| 0x0104 | 0x0104 | 1 | ub8 | number of elements in y_adjust_table | |
| 0x0105 | 0x0105 | 1 | ub8 | number of elements in advance_table | |
| 0x0106 | 0x016B | 102 | 0 | ??? | |
| 0x016C | 0x016F | 4 | ul32 | max. 512 | number of elements in shadow_charmap (number of shadow-glyphs in fontdata) |
| 0x0170 | 0x0173 | 4 | ul32 | 16 (fixed?) | number of bits per element in shadow_charmap |
| 0x0174 | 0x0177 | 4 | sff26.6 | 24.0625 | ??? |
| 0x0178 | 0x017B | 4 | sff26.6 | 0.5 or 1.0 | x-shadowscale |
| 0x017C | 0x017F | 4 | sff26.6 | 0.5 or 1.0 | y-shadowscale |
| 0x0180 | 0x0183 | 4 | sff26.6 | 15.0 | ??? |
| 0x0184 | 0x0187 | 4 | sff26.6 | 15.0 | ??? |
For revision 3 files (kr0.pgf) there is a header extension:
| start | end | size | type | typical value | description |
| 0x0188 | 0x018B | 4 | ul32 | 16 | number of bits per element in first part of charmap_compression_table |
| 0x018C | 0x018D | 2 | us16 | 5 | number of elements in first part of charmap_compression_table |
| 0x018E | 0x018F | 2 | us16 | 4 | ??? |
| 0x0190 | 0x0193 | 4 | ul32 | 16 | number of bits per element in second part of charmap_compression_table |
| 0x0194 | 0x0195 | 2 | us16 | 5 | number of elements in second part of charmap_compression_table |
| 0x0196 | 0x0197 | 2 | us16 | 4 | ??? |
| 0x0198 | 0x019B | 4 | ul32 | 3 | ??? |
| start | end | size | type | description |
| 0x0000 | n*8-1 | n*8 | sff26.6[2][n] | n pairs of x/y-dimensions (n = number of elements in dimension_table as stated in header) |
| start | end | size | type | description |
| 0x0000 | n*8-1 | n*8 | sff26.6[2][n] | n pairs of left/center-aligned x-adjustments (n = number of elements in x_adjust_table as stated in header) |
| start | end | size | type | description |
| 0x0000 | n*8-1 | n*8 | sff26.6[2][n] | n pairs of baseline/top-aligned y-adjustments (n = number of elements in y_adjust_table as stated in header) |
| start | end | size | type | description |
| 0x0000 | n*8-1 | n*8 | sff26.6[2][n] | n pairs of x/y-advance (n = number of elements in advance_table as stated in header) |
| start | end | size | type | description |
| 0x0000 | n*2-1 | n*2 | us16 | n UCS2 values of chars that have a shadow glyph in fontdata (n as stated in header) |
This table exists only in revision 3 files (kr0.pgf)
| start | end | size | type | description |
| 0x0000 | n1*4-1 | n1*4 | us16[2][n1] | n1 pairs of subcharmap-start (UCS2 value) and subcharmap-length (n1 as stated in extended header) |
| n1*4 | (n1+n2)*4-1 | n2*4 | us16[2][n2] | n2 pairs of subcharmap-start (UCS2 value) and subcharmap-length (n2 as stated in extended header, unknown meaning) |
| start | end | size | type | typical values | description |
| 0x0000 | size-1 | (n*bpe+31)/8 | ubpe[n]+pad | id<n_chars or id=2^bpe-1 | n values with bpe bits per element indicating the char's id (value < 2^bpe-1) or its absence (value = 2^bpe) |
| start | end | size | type | typical value | description |
| 0x0000 | size-1 | (n*bpe+31)/8 | ubpe[n]+pad | n values with bpe bits per element indicating the char's offset in fontdata divided by 4 |
Fontdata is a list of metric/bitmap pairs. The values of the char_pointer_table point to the offsets of the char-metrics. If the UCS2 value of a char appears in the shadow_charmap, there is an additional shadow-metric/shadow-bitmap pair after the char-metric/char-bitmap pair. It is pointed to by the offset value given in the char-metric.
In the following tables units of start, end and size are bits (and not bytes as before).
10.1 Metric
| start | end | size | type | typical value | description |
| 0000 | 0013 | 14 | u14 | offset of the shadow metric in bytes | |
| 0014 | 0020 | 7 | u7 | glyph-width in pixels | |
| 0021 | 0027 | 7 | u7 | glyph-height in pixels | |
| 0028 | 0034 | 7 | s7 | horizontal adjustment in pixels | |
| 0035 | 0041 | 7 | s7 | vertical adjustment in pixels | |
| 0042 | 0043 | 2 | u2 | 1, 2 or 3 | glyph transposition (1: horizontal rows, 2: vertical rows, 3: glyph data contains list of UCS2 values of chars to overlay) |
| 0044 | 0044 | 1 | u1 | metric type (0: shadow, 1: character) | |
| 0045 | 0045 | 1 | u1 | flag1 (0: dimension values are stored in extended metric, 1: dimension values are stored in dimension_table) | |
| 0046 | 0046 | 1 | u1 | flag2 (0: x-adjust values are stored in extended metric, 1: x-adjust values are stored in x_adjust_table) | |
| 0047 | 0047 | 1 | u1 | flag3 (0: y-adjust values are stored in extended metric, 1: y-adjust values are stored in y_adjust_table) |
For character metrics (metric type 1) there is a (variable size) metric extension:
| start | end | size | type | typical value | description |
| 0048 | 0054 | 7 | ??? | ||
| 0055 | 0063 | 9 | u9 | shadow id (which shadow in shadow_charmap to use for this char) | |
| 0064 | 8 or 64 | u8 or sff26.6[2] | (flag1) ? (use dimension values stored in dimension_table[0:1][u8]) : (use dimension values stored in extended metric) | ||
| 8 or 64 | u8 or sff26.6[2] | (flag2) ? (use x-adjust values stored in x_adjust_table[0:1][u8]) : (use x-adjust values stored in extended metric) | |||
| 8 or 64 | u8 or sff26.6[2] | (flag3) ? (use y-adjust values stored in y_adjust_table[0:1][u8]) : (use y-adjust values stored in extended metric) | |||
| 8 | u8 | use values stored in advance_table[0:1][u8] |
10.2 Bitmap
Each char has at least one glyph (up to 3 in kr0.pgf), which is stored as a 4bpp rle-compressed bitmap. Width, height and transposition are stated in the preceding metric. There are two sequences defined for the rle-compression:
The sequences are repeated until the output stream (width*height) is full.
In case of transposition == 3 (kr0.pgf), there is a list of 3 UCS2 values (us16) instead of the rle-compressed bitmap stream. To correctly draw this char, one has to look up the 3 UCS values in the (compressed) charmap to identify the corresponding glyph-ids and overlay them.
< Home | 22. Nov. 2007 | For questions or comments mail to
![]()