mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +02:00
Use plGetSharedFontByType() and updated comments, etc. Better error handling.
This commit is contained in:
parent
850b935c92
commit
d0ced51d15
@ -84,16 +84,17 @@ int main(int argc, char **argv)
|
|||||||
u32* framebuf;
|
u32* framebuf;
|
||||||
|
|
||||||
u64 LanguageCode=0;
|
u64 LanguageCode=0;
|
||||||
|
PlFontData font;
|
||||||
PlFontData fonts[PlSharedFontType_Total];
|
PlFontData fonts[PlSharedFontType_Total];
|
||||||
size_t total_fonts=0;
|
size_t total_fonts=0;
|
||||||
FT_Error ret=0, libret=0, faceret=0;
|
FT_Error ret=0, libret=1, faceret=1;
|
||||||
FT_Library library;
|
FT_Library library;
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
|
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
consoleInit(NULL);
|
consoleInit(NULL);
|
||||||
|
|
||||||
rc = setInitialize();
|
rc = setInitialize();//Only needed with shared-font when using plGetSharedFont.
|
||||||
if (R_SUCCEEDED(rc)) rc = setGetSystemLanguage(&LanguageCode);
|
if (R_SUCCEEDED(rc)) rc = setGetSystemLanguage(&LanguageCode);
|
||||||
setExit();
|
setExit();
|
||||||
|
|
||||||
@ -106,21 +107,25 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
|
//Use this when using multiple shared-fonts.
|
||||||
rc = plGetSharedFont(LanguageCode, fonts, PlSharedFontType_Total, &total_fonts);
|
rc = plGetSharedFont(LanguageCode, fonts, PlSharedFontType_Total, &total_fonts);
|
||||||
|
|
||||||
if (R_FAILED(rc)) printf("plGetSharedFont() failed: 0x%x\n", rc);
|
if (R_FAILED(rc)) printf("plGetSharedFont() failed: 0x%x\n", rc);
|
||||||
|
|
||||||
|
//Use this when you want to use specific shared-font(s). Since this example only uses 1 font, only the font loaded by this will be used.
|
||||||
|
rc = plGetSharedFontByType(&font, PlSharedFontType_Standard);
|
||||||
|
if (R_FAILED(rc)) printf("plGetSharedFontByType() failed: 0x%x\n", rc);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
{
|
||||||
ret = FT_Init_FreeType(&library);
|
ret = FT_Init_FreeType(&library);
|
||||||
libret = ret;
|
libret = ret;
|
||||||
if (ret) printf("FT_Init_FreeType() failed: %d\n", ret);
|
if (ret) printf("FT_Init_FreeType() failed: %d\n", ret);
|
||||||
|
|
||||||
if (ret==0)
|
if (ret==0)
|
||||||
{
|
{
|
||||||
//Use the second font. You may want to use all fonts, if you want to support non-{Japan, US and Europe} fonts.
|
|
||||||
//TODO: Probably should use PlSharedFontType_Standard explicitly, instead of assuming it's fonts[1].
|
|
||||||
ret = FT_New_Memory_Face( library,
|
ret = FT_New_Memory_Face( library,
|
||||||
fonts[1].address, /* first byte in memory */
|
font.address, /* first byte in memory */
|
||||||
fonts[1].size, /* size in bytes */
|
font.size, /* size in bytes */
|
||||||
0, /* face_index */
|
0, /* face_index */
|
||||||
&face);
|
&face);
|
||||||
|
|
||||||
@ -141,6 +146,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc) && ret==0)
|
if (R_SUCCEEDED(rc) && ret==0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user