Skip to content

Commit

Permalink
Switch main UI font to one built to include Hiragana and Katakana. Do…
Browse files Browse the repository at this point in the history
…n't know if that is enough.

Also includes more western characters so I can write my name right :)
  • Loading branch information
hrydgard committed Apr 17, 2013
1 parent a0665d0 commit d1bcc8a
Show file tree
Hide file tree
Showing 17 changed files with 704 additions and 394 deletions.
51 changes: 28 additions & 23 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include "PPGeDraw.h"
#include "../GPU/ge_constants.h"
#include "../GPU/GPUState.h"
#include "../GPU/GPUInterface.h"
#include "../HLE/sceKernel.h"
#include "../HLE/sceKernelMemory.h"
#include "../HLE/sceGe.h"
#include "../MemMap.h"
#include "Core/Util/PPGeDraw.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
#include "GPU/GPUInterface.h"
#include "Core/HLE/sceKernel.h"
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/sceGe.h"
#include "Core/MemMap.h"
#include "image/zim_load.h"
#include "gfx/texture_atlas.h"
#include "gfx/gl_common.h"
#include "../System.h"
#include "util/text/utf8.h"
#include "MathUtil.h"
#include "Core/System.h"

static u32 atlasPtr;
static int atlasWidth;
Expand Down Expand Up @@ -249,7 +250,7 @@ void PPGeEnd()

static void PPGeMeasureText(const char *text, float scale, float *w, float *h) {
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
unsigned char cval;
unsigned int cval;
float wacc = 0;
float maxw = 0;
int lines = 1;
Expand All @@ -261,8 +262,10 @@ static void PPGeMeasureText(const char *text, float scale, float *w, float *h) {
}
if (cval < 32) continue;
if (cval > 127) continue;
AtlasChar c = atlasfont.chars[cval - 32];
wacc += c.wx * scale;
const AtlasChar *c = atlasfont.getChar(cval);
if (c) {
wacc += c->wx * scale;
}
}
if (wacc > maxw) maxw = wacc;
if (w) *w = maxw;
Expand All @@ -278,12 +281,11 @@ static void PPGeDoAlign(int flags, float *x, float *y, float *w, float *h) {

// Draws some text using the one font we have.
// Mostly stolen from DrawBuffer.
void PPGeDrawText(const char *text, float x, float y, int align, float scale, u32 color)
{
void PPGeDrawText(const char *text, float x, float y, int align, float scale, u32 color) {
if (!dlPtr)
return;
const AtlasFont &atlasfont = *ppge_atlas.fonts[0];
unsigned char cval;
unsigned int cval;
float w, h;
PPGeMeasureText(text, scale, &w, &h);
if (align) {
Expand All @@ -301,14 +303,17 @@ void PPGeDrawText(const char *text, float x, float y, int align, float scale, u3
}
if (cval < 32) continue;
if (cval > 127) continue;
AtlasChar c = atlasfont.chars[cval - 32];
float cx1 = x + c.ox * scale;
float cy1 = y + c.oy * scale;
float cx2 = x + (c.ox + c.pw) * scale;
float cy2 = y + (c.oy + c.ph) * scale;
Vertex(cx1, cy1, c.sx, c.sy, 256, 256, color);
Vertex(cx2, cy2, c.ex, c.ey, 256, 256, color);
x += c.wx * scale;
const AtlasChar *ch = atlasfont.getChar(cval);
if (ch) {
const AtlasChar &c = *ch;
float cx1 = x + c.ox * scale;
float cy1 = y + c.oy * scale;
float cx2 = x + (c.ox + c.pw) * scale;
float cy2 = y + (c.oy + c.ph) * scale;
Vertex(cx1, cy1, c.sx, c.sy, 256, 256, color);
Vertex(cx2, cy2, c.ex, c.ey, 256, 256, color);
x += c.wx * scale;
}
}
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
}
Expand Down
22 changes: 14 additions & 8 deletions Core/Util/ppge_atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

#include "ppge_atlas.h"

const AtlasFont font_UBUNTU24 = {
-1.375000f, // padding
36.687500f, // height
26.937500f, // ascend
0.750000f, // distslope
{
const AtlasChar font_UBUNTU24_chardata[] = {
// RANGE: 0x20 - 0x80, start 0x0
{0.972656f, 0.000000f, 0.976563f, 0.003906f, -2.0000f, -2.0000f, 7.0625f, 1, 1}, // 32
{0.531250f, 0.675781f, 0.562500f, 0.777344f, -0.3750f, -23.1250f, 6.3750f, 8, 26}, // 33
{0.246094f, 0.718750f, 0.292969f, 0.765625f, -0.5000f, -23.0625f, 10.2500f, 12, 12}, // 34
Expand Down Expand Up @@ -104,15 +100,25 @@ const AtlasFont font_UBUNTU24 = {
{0.933594f, 0.210938f, 0.984375f, 0.351563f, -1.3750f, -26.9375f, 10.9375f, 13, 36}, // 125
{0.296875f, 0.718750f, 0.359375f, 0.750000f, -0.5000f, -14.1875f, 14.7500f, 16, 8}, // 126
{0.582031f, 0.000000f, 0.679688f, 0.136719f, -0.5000f, -25.2500f, 23.1250f, 25, 35}, // 127
},
};
const AtlasCharRange font_UBUNTU24_ranges[] = {
{ 32, 128, 0 },};
const AtlasFont font_UBUNTU24 = {
-1.375000f, // padding
36.687500f, // height
26.937500f, // ascend
0.750000f, // distslope
font_UBUNTU24_chardata,
font_UBUNTU24_ranges,
1,
"UBUNTU24", // name
};
const AtlasFont *ppge_fonts[1] = {
&font_UBUNTU24,
};
const AtlasImage ppge_images[6] = {
{0.458984f, 0.001953f, 0.576172f, 0.119141f, 31, 31, "I_CROSS"},
{0.193359f, 0.001953f, 0.324453f, 0.133047f, 32, 32, "I_CIRCLE"},
{0.193359f, 0.001953f, 0.314453f, 0.123047f, 32, 32, "I_CIRCLE"},
{0.685547f, 0.001953f, 0.794922f, 0.111328f, 29, 29, "I_SQUARE"},
{0.322266f, 0.001953f, 0.451172f, 0.111328f, 34, 29, "I_TRIANGLE"},
{0.802734f, 0.001953f, 0.861328f, 0.193359f, 16, 50, "I_BUTTON"},
Expand Down
27 changes: 16 additions & 11 deletions UI/MenuScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void LogoScreen::render() {
ui_draw2d.SetFontScale(1.5f, 1.5f);
ui_draw2d.DrawText(UBUNTU48, "PPSSPP", dp_xres / 2, dp_yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
ui_draw2d.SetFontScale(1.0f, 1.0f);
ui_draw2d.DrawText(UBUNTU24, "Created by Henrik Rydgard", dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
ui_draw2d.DrawText(UBUNTU24, "Created by Henrik Rydg\u00E5rd", dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
ui_draw2d.DrawText(UBUNTU24, "Free Software under GPL 2.0", dp_xres / 2, dp_yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
ui_draw2d.DrawText(UBUNTU24, "www.ppsspp.org", dp_xres / 2, dp_yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
if (bootFilename_.size()) {
Expand Down Expand Up @@ -336,20 +336,23 @@ void PauseScreen::render() {
UIBegin(UIShader_Get());
DrawBackground(1.0f);

const char *title;
std::string title = game_title.c_str();
// Try to ignore (tm) etc.
if (UTF8StringNonASCIICount(game_title.c_str()) > 2) {
title = "(can't display japanese title)";
} else {
title = game_title.c_str();
}
//if (UTF8StringNonASCIICount(game_title.c_str()) > 2) {
// title = "(can't display japanese title)";
//} else {
//}


UIContext *ctx = screenManager()->getUIContext();
// This might create a texture so we must flush first.
UIFlush();
GameInfo *ginfo = g_gameInfoCache.GetInfo(PSP_CoreParameter().fileToStart, true);

if (ginfo) {
title = ginfo->title;
}

if (ginfo && ginfo->pic1Texture) {
ginfo->pic1Texture->Bind(0);
ui_draw2d.DrawTexRect(0,0,dp_xres, dp_yres, 0,0,1,1,0xFFc0c0c0);
Expand All @@ -374,7 +377,7 @@ void PauseScreen::render() {
ctx->RebindTexture();
}

ui_draw2d.DrawText(UBUNTU48, title, 10+144+10, 20, 0xFFFFFFFF, ALIGN_LEFT);
ui_draw2d.DrawText(UBUNTU24, title.c_str(), 10+144+10, 20, 0xFFFFFFFF, ALIGN_LEFT);

int x = 30;
int y = 50;
Expand Down Expand Up @@ -416,7 +419,7 @@ void PauseScreen::render() {
screenManager()->push(new SettingsScreen(), 0);
}

if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, 0, "Return to Menu", ALIGN_RIGHT)) {
if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, 0, "Back to Menu", ALIGN_RIGHT)) {
screenManager()->finishDialog(this, DR_OK);
}

Expand Down Expand Up @@ -783,7 +786,9 @@ static const char * credits[] = {
"",
"A fast and portable PSP emulator",
"",
"Created by Henrik Rydgard",
"Created by Henrik Rydg\u00E5rd",
"(aka hrydgard, ector)"
"",
"",
"Contributors:",
"unknownbrackets",
Expand All @@ -800,7 +805,7 @@ static const char * credits[] = {
"soywiz",
"kovensky",
"xele",
"cinaera",
"cinaera/BeaR",
"",
"Written in C++ for speed and portability",
"",
Expand Down
Loading

3 comments on commit d1bcc8a

@dbz400
Copy link
Contributor

@dbz400 dbz400 commented on d1bcc8a Apr 17, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) I think no more "cannot display japanese title " , right ?

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly :)

@dbz400
Copy link
Contributor

@dbz400 dbz400 commented on d1bcc8a Apr 17, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice :)

Please sign in to comment.