1
Translating / UFORadiant
« on: July 09, 2009, 09:38:21 pm »
UFORadiant translation
New board
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#-------width-------##-------width-------##-------width-------#
xxxx xxxxx xxxxx xxxx xxxxx xxxxx xxxx xxxxx xxxxx xxxx
^-------------------------------------------------->
The original procedure is front to back
I think if first Guess the width
#-------width-------##-------width-------##-------width-------#
xxxx xxxxx xxxxx xxxx xxxxx xxxxx xxxx xxxxx xxxxx xxxx
^
| this is guess
^<-------| move front some number char
+---> now find break
I hope you can understand what I mean
static int R_FontFindFit (const font_t *f, char *text, int maxlen, int maxWidth, int *widthp)
{
int bestbreak = 0;
int width;
int len;
*widthp = 0;
width = R_FontChunkLength(f, text, maxlen);
if (width<=maxWidth) {
*widthp = width;
return maxlen-1;
}
/* Break first word anywhere. */
for (len = max(6,maxlen*maxWidth/width)-5; len < maxlen; len++) {
if (UTF8_CONTINUATION_BYTE(text[len]))
continue;
width = R_FontChunkLength(f, text, len);
if (width > maxWidth)
break;
bestbreak = len;
*widthp = width;
}
/** @todo Smart breaking of Chinese text */
/* Fit whole words */ /* Fit hyphenated word parts */
/* last 1/6 Width to find break */
for (len = bestbreak; len > (bestbreak - bestbreak/6); len--) {
if (text[len] == ' ' || text[len] == '-') {
width = R_FontChunkLength(f, text, len);
bestbreak = len;
*widthp = width;
break;
}
}
return bestbreak;
}
in ufopedia this is ok,but in 3D Geoscape can't display basename or nation name .