@@ -219,14 +219,14 @@ inline bool SamePix(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Ptr, const EFI_GRAPHICS
219
219
// used for proportional fonts in raster themes
220
220
// search empty column from begin Step=1 or from end Step=-1 in the input buffer
221
221
// empty means similar to FirstPixel
222
- INTN XTheme::GetEmpty (const XImage& Buffer, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& FirstPixel, INTN Start, INTN Step)
222
+ INTN XTheme::GetEmpty (const XImage& Buffer, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& FirstPixel, INTN MaxWidth, INTN Start, INTN Step)
223
223
{
224
224
INTN m, i;
225
225
// INTN Shift = (Step > 0)?0:1;
226
- m = FontWidth ;
226
+ m = MaxWidth ;
227
227
if (Step == 1 ) {
228
228
for (INTN j = 0 ; j < FontHeight; j++) {
229
- for (i = 0 ; i < FontWidth ; i++) {
229
+ for (i = 0 ; i < MaxWidth ; i++) {
230
230
if (!SamePix (Buffer.GetPixel (Start + i,j), FirstPixel)) { // found not empty pixel
231
231
break ;
232
232
}
@@ -235,14 +235,14 @@ INTN XTheme::GetEmpty(const XImage& Buffer, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL&
235
235
if (m == 0 ) break ;
236
236
}
237
237
} else { // go back
238
- m = 0 ;
239
238
for (INTN j = 0 ; j < FontHeight; j++) {
240
- for (i = FontWidth - 1 ; i >= 0 ; --i ) {
241
- if (!SamePix (Buffer.GetPixel (Start + i,j), FirstPixel)) { // found not empty pixel
239
+ for (i = 1 ; i <= MaxWidth; i++ ) {
240
+ if (!SamePix (Buffer.GetPixel (Start - i,j), FirstPixel)) { // found not empty pixel
242
241
break ;
243
242
}
244
243
}
245
- m = MAX (m, i); // for each line to find minimum
244
+ m = MIN (m, i); // for each line to find minimum
245
+ if (m == 0 ) break ;
246
246
}
247
247
}
248
248
return m;
@@ -319,13 +319,13 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
319
319
if (c0 <= 0x20 ) { // space before or at buffer edge
320
320
LeftSpace = 2 ;
321
321
} else {
322
- LeftSpace = GetEmpty (CompImage, FirstPixel, PosX, -1 );
322
+ LeftSpace = GetEmpty (CompImage, FirstPixel, RealWidth, PosX, -1 );
323
323
}
324
324
if (c <= 0x20 ) { // new space will be half font width
325
325
RightSpace = 1 ;
326
326
RealWidth = (CharScaledWidth >> 1 ) + 1 ;
327
327
} else {
328
- RightSpace = GetEmpty (FontImage, FontPixel, c * FontWidth, 1 ); // not scaled yet
328
+ RightSpace = GetEmpty (FontImage, FontPixel, FontWidth, c * FontWidth, 1 ); // not scaled yet
329
329
if (RightSpace >= FontWidth) {
330
330
RightSpace = 0 ; // empty place for invisible characters
331
331
}
0 commit comments