List Info

Thread: Localization of in game strings




Localization of in game strings
country flaguser name
France
2007-07-16 01:11:42
Hello,

As discussed during yesterday's meeting I report here my
experiences
 concerning sizing strings and placing localized strings
inside the game
 area.

In kgraphviewer (a graphviz dot graphs viewer), the dot tool
gives dimensions
 of graphs nodes and says which font to use. It can happen
that the given
 font will produce too large strings in QGV, larger than
their containing
 node. So, I do the following loop:
      int stringWidthGoal = int(dro.integers[3] *
m_scaleX);
      int fontSize = node()->fontSize();
      m_font->setPointSize(fontSize);
      QFontMetrics fm(*m_font);
      while (fm.width(dro.str) > stringWidthGoal
&& fontSize > 1)
      {
        fontSize--;
        m_font->setPointSize(fontSize);
        fm = QFontMetrics(*m_font);
      }



In KsirK, the localized countries names are drawn on the
map. I have currently
 no real size problems but they have to be placed centered
on given points. 
 These points are defined in the skin (theme) file and
related to the default
 size of the SVG map. They are finaly painted with:
    const QString& countryName =
i18n(country->name().toUtf8().data());
     QRect countryNameRect =
painter.fontMetrics().boundingRect(countryName);
    painter.drawText(
   
int((country->centralPoint().x()*m_zoom-countryNameRect.w
idth()/2)),
   
int((country->centralPoint().y()*m_zoom+countryNameRect.h
eight()/2)),
        countryName);


As you can see, a combination of the two above methods could
be used to define
 a bounding box in the SGV file of the theme and then force
the drawing of
 localized strings of the correct size inside inside this
box.

Comments ?

Best regards,

Kleag
_______________________________________________
kde-games-devel mailing list
kde-games-develkde.org
https://mail.kde.org/mailman/listinfo/kde-games-devel

Re: Localization of in game strings
country flaguser name
Brazil
2007-07-16 08:54:11
kleagfree.fr wrote:
> 
> As you can see, a combination of the two above methods
could be used to define
>  a bounding box in the SGV file of the theme and then
force the drawing of
>  localized strings of the correct size inside inside
this box.
> 
> Comments ?

Seems nice, thanks for sharing it. I think that in some
cases where even 
finer control is needed the artist could also enter the
boundingBox 
directly in the SVG theme, and the code could retrieve the
boundingRect 
of the element. This would guarantee that elements do not
run over each 
other, in case of very large strings. I understand that in
Ksirk this is 
really not a concern for the country maps, and centering is
enough.

Just to complement the suggestion above, in the case of
multiple text 
fields the author could also precalculate the minimum
fontSize for all 
of them, and use the minimum size for all fields. Again,
this is not 
necessary in Ksirk, but might be nice to have in some themes
(to 
guarantee a given set of labels have the same font size,
which is 
usually more pleasant.)

Regards,
Mauricio Piacentini
_______________________________________________
kde-games-devel mailing list
kde-games-develkde.org
https://mail.kde.org/mailman/listinfo/kde-games-devel

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )