Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is too small in CHT devices #654

Closed
roytam1 opened this issue Jan 8, 2018 · 6 comments
Closed

Text is too small in CHT devices #654

roytam1 opened this issue Jan 8, 2018 · 6 comments

Comments

@roytam1
Copy link

roytam1 commented Jan 8, 2018

CHT devices(Sell officially in Hong Kong and Taiwan) has smaller font size (20x24px) than others (25x30px) for more spaces to contain larger amount characters. (Source: converted bitmap from official cbf_zh-Hant-TW.bcfnt / cbf_std.bcfnt with ctr_FontConverter)

Possible solution to deal with such situation:
check width of "あ" with fontGetCharWidthInfo, CHT devices will return smaller value. Since ideograph is square, so normally width == height. (CHECK: does it return "24" in C/J/U/E? and does it return "19" in T?)
and then adjust scale factor before print.

Cross-post:
devkitPro/3ds-hbmenu#35
https://github.com/Steveice10/FBI/issues/423

@BernardoGiordano
Copy link
Collaborator

Can you send multiple screenshots of the whole user interface? Having them in a zip file attached here would be a big help

@roytam1
Copy link
Author

roytam1 commented Jan 8, 2018

Sure.
Top and bottom bar text is barely visable.

2018-01-08_23-44-42 705_top
2018-01-08_23-44-42 705_bot
2018-01-08_23-50-23 004_top
2018-01-08_23-50-23 004_bot

@BernardoGiordano
Copy link
Collaborator

the solution you proposed is feasible, I hope for it to be implemented properly in a possible rewrite, otherwise I'll put together something rough to patch it at least for now

@fincs
Copy link

fincs commented Jan 13, 2018

For reference, this is how I fixed it in new-hbmenu: devkitPro/3ds-hbmenu@79e2e67

@roytam1
Copy link
Author

roytam1 commented Jan 14, 2018

Just ported my mod over @fincs 's commit to pp2d:

diff --git a/source/pp2d/pp2d.c b/source/pp2d/pp2d.c
index 785c4f5..e4c6612 100644
--- a/source/pp2d/pp2d.c
+++ b/source/pp2d/pp2d.c
@@ -41,6 +41,7 @@ static C3D_Mtx projectionTopLeft;
 static C3D_Mtx projectionTopRight;
 static C3D_Mtx projectionBot;
 static C3D_Tex* glyphSheets;
+static float s_textScale;
 static textVertex_s* textVtxArray;
 static int textVtxArrayPos;
 static C3D_RenderTarget* topLeft;
@@ -159,6 +160,9 @@ void pp2d_draw_text_wrap(float x, float y, float scaleX, float scaleY, u32 color
        float firstX = x;
        int lastSheet = -1;

+       scaleX *= s_textScale;
+       scaleY *= s_textScale;
+
        do
        {
                if (!*p) break;
@@ -391,6 +395,8 @@ Result pp2d_init(void)
                tex->lodParam = 0;
                #endif
        }
+       charWidthInfo_s* cwi = fontGetCharWidthInfo(fontGlyphIndexFromCodePoint(0x3042));
+       s_textScale = 20.0f / (cwi->glyphWidth); // 20 is glyphWidth in J machines

        textVtxArray = (textVertex_s*)linearAlloc(sizeof(textVertex_s)*TEXT_VTX_ARRAY_COUNT);
        C3D_BufInfo* bufInfo = C3D_GetBufInfo();
@@ -443,6 +449,9 @@ static void pp2d_get_text_size_internal(float* width, float* height, float scale
     float firstX = x;
     const uint8_t* p = (const uint8_t*)text;

+       scaleX *= s_textScale;
+       scaleY *= s_textScale;
+
     do
     {
         if (!*p) break;

and it looks better (Some Japanese glyphs are missing in TWN/CHT machines as expected):
t_title_atop
t_title_bot
t_box_atop
t_box_bot

@roytam1
Copy link
Author

roytam1 commented Jan 14, 2018

@BernardoGiordano closed this in 0445e96 5 hours ago

will you merge same change to others using pp2d, like https://github.com/BernardoGiordano/Checkpoint ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants