intraFont - A bitmap font library for PSP using the PSP's internal font (firmware pgf files) intraFont Version 0.2 by BenHur - http://www.psp-programming.com/benhur intraFont uses parts of pgeFont by InsertWittyName - http://insomniac.0x89.org -=Info=- The library loads a pgf font from firmware and generates a 4-bit paletted bitmap font texture on the fly when drawing text. It caches previously drawn characters and is accurate to 1/4 pixel. As of version 0.2 intraFont supports regular, italic and/or bold Latin, Japanese, Korean and symbol fonts: flash0:/font/ltn0.pgf, ltn1.pgf, ..., ltn15.pgf, jpn0.pgf, kr0.pgf and arib.pgf (kr0.pgf and arib.pgf might be missing/replaced by a dummy file depending on the CFW). Unless this version has a severe bug, there are currently no plans for a future version. However there are still things that can be improved: - implement INTRAFONT_VERTADVANCE - maybe increase accuracy to 1/64 pixel (at the cost of memory) - speed & memory optimizations, bug fixes, cleanup, ... -=Samples=- There are two samples included, one for raw GU and the other using the graphics library from Yeldarb's tutorials on psp-programming.com If you're using the graphics library then you may need to reset the sceGuTex* states to what they are defaulted to in the initGraphics() functions, after using the intraFont* functions. It should be easy enough to add to any other library. -=Dependencies=- none (i.e. freetype is NOT required) -=Performance=- Depending on the purpose one can optimize the use of intraFont for loadtime [ms], memory [kB] and speed [kiloCharacters Per Second] via the INTRAFONT_CACHE_??? flags. Rule of thumb: - if you use less than 100 different characters: use INTRAFONT_CACHE_MED (default) - if you use more than 100 different characters: use INTRAFONT_CACHE_LARGE for faster loadtime OR use INTRAFONT_CACHE_ALL for lower memory consumption and steady fps The following table shows typical performance numbers: font: ¦ INTRAFONT_CACHE_MED (def) ¦ INTRAFONT_CACHE_LARGE ¦ INTRAFONT_CACHE_ALL --------+---------------------------+-------------------------+---------------------------- ltn0-7 ¦ 52ms, 117kB, 2.5kCPS(*)¦ 52ms, 215kB, 2.5kCPS ¦ 190ms, 122kB, 100kCPS ltn8-15 ¦ 35ms, 85kB, 4.2kCPS ¦ 35ms, 184kB, 4.2kCPS ¦ 95ms, 66kB, 100kCPS jpn0 ¦ 1015ms, 1805kB, 0.5kCPS ¦ 1015ms, 1903kB, 0.5kCPS ¦ - too many glyphs - kr0 ¦ 340ms, 640kB, 0.7kCPS ¦ 340ms, 738kB, 0.7kCPS ¦ 1926ms, 451kB, 70kCPS(**) arib ¦ 177ms, 273kB, 1.8kCPS ¦ 117ms, 371kB, 1.8kCPS ¦ - too many glyphs - ------------------------------------------------------------------------------------------ (*) Low speeds (<10kCPS) occur when characters are not cached. Printing the same characters a second time results in 100 kCPS, i.e. the speed penalty is gone. (**) kr0 is slower because one character can consist of up to three glyphs. -=Changelog=- 0.2 - added support for Korean (kr0.pgf) and symbols (arib.pgf) - added cache options (cache size and pre-cache all) - added right and center alignments - improved fixed width appearance (width can be set by user or left as default) - fixed various bugs (mostly in glyph cache to prevent graphical glitches) - reduced memory required (variable-size texture, free unneeded stuff) - improved speed (optimizations, texture swizzling) 0.1 - initial release -=Credits=- Skylark and Freeplay: basic deciphering of the pgf format InsertWittyName: pgeFont CpuWhiz: "Hello World" in Japanese J.F.: intraFontMeasureText() -=License=- This is released under the Creative Commons Attribution-Share Alike 3.0 License. See LICENSE for more information. -=Atttribution=- With accordance to the license, the following must be adhered to: If you use the code in any way, shape or form you must attribute it in the following way: 'Uses intraFont by BenHur' If you alter the code in any way, shape or form you must also release the updated code under the same license. See http://creativecommons.org/licenses/by-sa/3.0/ if you need more information.