mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
* added custom font. its called "font.ttf" and will loaded from theme-path (issue 541)
* little Bugfix
This commit is contained in:
parent
f3443c0ae8
commit
88ab764854
@ -20,7 +20,8 @@
|
||||
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FreeTypeGX.h"
|
||||
#include <sys/stat.h>
|
||||
#include "FreeTypeGX.h"
|
||||
#include "language/CH2Unicode.h"
|
||||
#include "language/GB2Unicode.h"
|
||||
#include "language/sjis2unicode.h"
|
||||
@ -77,6 +78,7 @@ FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex) {
|
||||
* Default destructor for the FreeTypeGX class.
|
||||
*/
|
||||
FreeTypeGX::~FreeTypeGX() {
|
||||
FT_Done_FreeType(this->ftLibrary);
|
||||
this->unloadFont();
|
||||
}
|
||||
|
||||
@ -205,11 +207,13 @@ void FreeTypeGX::setDefaultMode() {
|
||||
* @param pointSize The desired point size this wrapper's configured font face.
|
||||
* @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false.
|
||||
*/
|
||||
uint16_t FreeTypeGX::loadFont(uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
|
||||
#include <unistd.h>
|
||||
uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
|
||||
this->unloadFont();
|
||||
this->ftPointSize = pointSize;
|
||||
|
||||
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
|
||||
struct stat st;
|
||||
if( !( fontPath && (stat(fontPath, &st)==0) && (FT_New_Face(this->ftLibrary, fontPath, 0, &this->ftFace)==0) ) )
|
||||
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
|
||||
|
||||
if(this->ftPointSize > 0)
|
||||
FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize);
|
||||
@ -228,8 +232,8 @@ uint16_t FreeTypeGX::loadFont(uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt p
|
||||
*
|
||||
* \overload
|
||||
*/
|
||||
uint16_t FreeTypeGX::loadFont(const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
|
||||
return this->loadFont((uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll);
|
||||
uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
|
||||
return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,8 +254,8 @@ class FreeTypeGX {
|
||||
void setVertexFormat(uint8_t vertexIndex);
|
||||
void setCompatibilityMode(uint32_t compatibilityMode);
|
||||
|
||||
uint16_t loadFont(uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
|
||||
uint16_t loadFont(const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
|
||||
uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
|
||||
uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
|
||||
void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0);
|
||||
|
||||
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
|
||||
|
@ -78,7 +78,8 @@ main(int argc, char *argv[])
|
||||
if(!bootDevice_found)
|
||||
{
|
||||
//try USB
|
||||
if((stat("USB:/apps/usbloader_gx/boot.dol", NULL) == 0) || (stat("USB:/apps/usbloader_gx/boot.elf", NULL) == 0))
|
||||
struct stat st;
|
||||
if((stat("USB:/apps/usbloader_gx/boot.dol", &st) == 0) || (stat("USB:/apps/usbloader_gx/boot.elf", NULL) == 0))
|
||||
strcpy(bootDevice, "USB:");
|
||||
}
|
||||
|
||||
@ -119,13 +120,28 @@ main(int argc, char *argv[])
|
||||
|
||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
|
||||
|
||||
printf("\n\n load Font\n");
|
||||
fontSystem = new FreeTypeGX();
|
||||
fontSystem->loadFont(font_ttf, font_ttf_size, 0);
|
||||
char *fontPath=0;
|
||||
asprintf(&fontPath, "%sfont.ttf", CFG.theme_path);
|
||||
printf(" from: %s\n", fontPath);
|
||||
printf(" 5\n");
|
||||
sleep(1);
|
||||
printf(" 4\n");
|
||||
sleep(1);
|
||||
printf(" 3\n");
|
||||
sleep(1);
|
||||
printf(" 2\n");
|
||||
sleep(1);
|
||||
printf(" 1\n");
|
||||
sleep(1);
|
||||
printf(" 0\n");
|
||||
fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0);
|
||||
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
|
||||
free(fontPath);
|
||||
|
||||
fontClock = new FreeTypeGX();
|
||||
fontClock->loadFont(clock_ttf, clock_ttf_size, 0);
|
||||
fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0);
|
||||
fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
|
||||
|
||||
InitGUIThreads();
|
||||
|
Loading…
Reference in New Issue
Block a user