fix font rendering
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
4bf321f3a2
commit
2a982603d3
2 changed files with 15 additions and 6 deletions
|
|
@ -100,11 +100,11 @@ static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
int tw = 0;
|
int tw = 0;
|
||||||
|
FT_Vector vec;
|
||||||
|
|
||||||
while(text[0] != 0) {
|
while(text[0] != 0) {
|
||||||
int c, c2;
|
int c, c2;
|
||||||
FT_Vector vec;
|
|
||||||
const char* old_text;
|
const char* old_text;
|
||||||
|
|
||||||
text += MwUTF8ToUTF32(text, &c);
|
text += MwUTF8ToUTF32(text, &c);
|
||||||
|
|
@ -123,7 +123,11 @@ static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
text = old_text;
|
text = old_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
tw += ttf->face->glyph->bitmap_left + ttf->face->glyph->bitmap.width;
|
if(tw > 0) {
|
||||||
|
tw -= vec.x >> 6;
|
||||||
|
tw -= ttf->face->glyph->advance.x >> 6;
|
||||||
|
tw += ttf->face->glyph->bitmap_left + ttf->face->glyph->bitmap.width;
|
||||||
|
}
|
||||||
|
|
||||||
return tw + 1;
|
return tw + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,9 @@ static int stbtt_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
int tw = 0;
|
int tw = 0;
|
||||||
int c;
|
int c;
|
||||||
int x0, y0, x1, y1;
|
int x0, y0, x1, y1;
|
||||||
|
int kern;
|
||||||
|
|
||||||
while(text[0] != 0) {
|
while(text[0] != 0) {
|
||||||
int kern;
|
|
||||||
int c2;
|
int c2;
|
||||||
const char* old_text;
|
const char* old_text;
|
||||||
|
|
||||||
|
|
@ -113,8 +113,13 @@ static int stbtt_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
text = old_text;
|
text = old_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
if(tw > 0) {
|
||||||
tw += x1;
|
tw -= ceil(kern * ttf->scale);
|
||||||
|
tw -= ceil(ax * ttf->scale);
|
||||||
|
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
||||||
|
tw += ceil(lsb * ttf->scale);
|
||||||
|
tw += x1 - x0;
|
||||||
|
}
|
||||||
|
|
||||||
return tw + 1;
|
return tw + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue