20
20
21
21
FreeTypeGX * GuiText::presentFont = NULL ;
22
22
int GuiText::presetSize = 28 ;
23
+ int GuiText::presetInternalRenderingScale = 2 .0f ; // Lets render the font at the doubled size. This make it even smoother!
23
24
int GuiText::presetMaxWidth = 0xFFFF ;
24
25
int GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE;
25
26
GX2ColorF32 GuiText::presetColor = (GX2ColorF32){ 1 .0f , 1 .0f , 1 .0f , 1 .0f };
@@ -52,6 +53,7 @@ GuiText::GuiText()
52
53
blurGlowIntensity = 0 .0f ;
53
54
blurAlpha = 0 .0f ;
54
55
blurGlowColor = glm::vec4 (0 .0f );
56
+ internalRenderingScale = presetInternalRenderingScale;
55
57
}
56
58
57
59
GuiText::GuiText (const char * t, int s, const glm::vec4 & c)
@@ -74,6 +76,7 @@ GuiText::GuiText(const char * t, int s, const glm::vec4 & c)
74
76
blurGlowIntensity = 0 .0f ;
75
77
blurAlpha = 0 .0f ;
76
78
blurGlowColor = glm::vec4 (0 .0f );
79
+ internalRenderingScale = presetInternalRenderingScale;
77
80
78
81
if (t)
79
82
{
@@ -105,6 +108,7 @@ GuiText::GuiText(const wchar_t * t, int s, const glm::vec4 & c)
105
108
blurGlowIntensity = 0 .0f ;
106
109
blurAlpha = 0 .0f ;
107
110
blurGlowColor = glm::vec4 (0 .0f );
111
+ internalRenderingScale = presetInternalRenderingScale;
108
112
109
113
if (t)
110
114
{
@@ -141,6 +145,7 @@ GuiText::GuiText(const char * t)
141
145
blurGlowIntensity = 0 .0f ;
142
146
blurAlpha = 0 .0f ;
143
147
blurGlowColor = glm::vec4 (0 .0f );
148
+ internalRenderingScale = presetInternalRenderingScale;
144
149
145
150
if (t)
146
151
{
@@ -530,16 +535,23 @@ void GuiText::draw(CVideo *pVideo)
530
535
531
536
color[3 ] = getAlpha ();
532
537
blurGlowColor[3 ] = blurAlpha * getAlpha ();
533
- int newSize = size * getScale ();
538
+
539
+ float finalRenderingScale = 2 .0f * internalRenderingScale;
540
+
541
+ int newSize = size * getScale () * finalRenderingScale;
542
+ int normal_size = size * getScale ();
534
543
535
544
if (newSize != currentSize)
536
545
{
537
- currentSize = newSize ;
546
+ currentSize = normal_size ;
538
547
539
548
if (text)
540
- textWidth = font->getWidth (text, currentSize );
549
+ textWidth = font->getWidth (text, normal_size );
541
550
}
542
551
552
+ f32 x_pos = getCenterX () * finalRenderingScale;
553
+ f32 y_pos = getCenterY () * finalRenderingScale;
554
+
543
555
if (maxWidth > 0 && maxWidth <= textWidth)
544
556
{
545
557
if (wrapMode == DOTTED) // text dotted
@@ -552,23 +564,25 @@ void GuiText::draw(CVideo *pVideo)
552
564
textDynWidth.resize (textDyn.size ());
553
565
554
566
for (u32 i = 0 ; i < textDynWidth.size (); i++)
555
- textDynWidth[i] = font->getWidth (textDyn[i], currentSize );
567
+ textDynWidth[i] = font->getWidth (textDyn[i], newSize );
556
568
}
557
569
570
+
558
571
if (textDyn.size () > 0 )
559
- font->drawText (pVideo, getCenterX (), getCenterY () , getDepth (), textDyn[textDyn.size ()-1 ], currentSize , color, alignment, textDynWidth[textDyn.size ()-1 ], defaultBlur, blurGlowIntensity, blurGlowColor);
572
+ font->drawText (pVideo, x_pos, y_pos , getDepth (), textDyn[textDyn.size ()-1 ], newSize , color, alignment, textDynWidth[textDyn.size ()-1 ], defaultBlur, blurGlowIntensity, blurGlowColor,finalRenderingScale );
560
573
}
561
574
562
575
else if (wrapMode == SCROLL_HORIZONTAL)
563
576
{
564
577
scrollText (pVideo->getFrameCount ());
565
578
566
579
if (textDyn.size () > 0 )
567
- font->drawText (pVideo, getCenterX (), getCenterY (), getDepth (), textDyn[textDyn.size ()-1 ], currentSize, color, alignment, maxWidth, defaultBlur, blurGlowIntensity, blurGlowColor);
580
+ font->drawText (pVideo, x_pos, y_pos, getDepth (), textDyn[textDyn.size ()-1 ], newSize, color, alignment, maxWidth*finalRenderingScale, defaultBlur, blurGlowIntensity, blurGlowColor,finalRenderingScale);
581
+
568
582
}
569
583
else if (wrapMode == WRAP)
570
584
{
571
- int lineheight = currentSize + 6 ;
585
+ int lineheight = newSize + 6 ;
572
586
int yoffset = 0 ;
573
587
int voffset = 0 ;
574
588
@@ -580,21 +594,22 @@ void GuiText::draw(CVideo *pVideo)
580
594
textDynWidth.resize (textDyn.size ());
581
595
582
596
for (u32 i = 0 ; i < textDynWidth.size (); i++)
583
- textDynWidth[i] = font->getWidth (textDyn[i], currentSize );
597
+ textDynWidth[i] = font->getWidth (textDyn[i], newSize );
584
598
}
585
599
586
600
if (alignment & ALIGN_MIDDLE)
587
601
voffset = (lineheight * (textDyn.size ()-1 )) >> 1 ;
588
602
589
603
for (u32 i = 0 ; i < textDyn.size (); i++)
590
604
{
591
- font->drawText (pVideo, getCenterX (), getCenterY () + voffset + yoffset, getDepth (), textDyn[i], currentSize , color, alignment, textDynWidth[i], defaultBlur, blurGlowIntensity, blurGlowColor);
605
+ font->drawText (pVideo, x_pos, y_pos + voffset + yoffset, getDepth (), textDyn[i], newSize , color, alignment, textDynWidth[i], defaultBlur, blurGlowIntensity, blurGlowColor,finalRenderingScale );
592
606
yoffset -= lineheight;
593
607
}
594
608
}
595
609
}
596
610
else
597
611
{
598
- font->drawText (pVideo, getCenterX (), getCenterY (), getDepth (), text, currentSize, color, alignment, textWidth, defaultBlur, blurGlowIntensity, blurGlowColor);
612
+ uint16_t newtextWidth = font->getWidth (text, newSize);
613
+ font->drawText (pVideo, x_pos, y_pos, getDepth (), text, newSize, color, alignment, newtextWidth, defaultBlur, blurGlowIntensity, blurGlowColor,finalRenderingScale);
599
614
}
600
615
}
0 commit comments