[haiku-commits] Re: r33428 - haiku/trunk/src/apps/terminal

2009/10/4  <leavengood@xxxxxxxxx>:

>
> +static bool
> +IsFontUsable(const BFont &font)
> +{
> +       // TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
> +       // use that. But I don't think it's easily implementable using
> +       // Freetype.
> +
> +       if (font.IsFixed())
> +               return true;
> +
> +       // manually check if all applicable chars are the same width
> +       char buffer[2] = { ' ', 0 };
> +       int firstWidth = (int)ceilf(font.StringWidth(buffer));
> +
> +       for (int c = ' '+1; c <= 0x7e; c++) {
> +               buffer[0] = c;
> +               int width = (int)ceilf(font.StringWidth(buffer));
> +
> +               if (width != firstWidth)
> +                       return false;
> +       }
> +
> +       return true;
> +}

(Like Stephan already suggested to me eons ago), we could use
GetStringWidths() or GetEscapements() here, which should be much more
efficient.

Other related posts: