Comment 1 for bug 950670

Marek BardoĊ„ski (bdfhjk) wrote :

Hi Frederik!

Thanks for posting first, real bug for UAT.

I found two answers:

1. Fast, easy to implement

 You can use binary search algorithm[1].

It will reduce number of comparing in worst case from 80 (96-16) to log2 80 = 7, so program in theory can be 10x faster, and changes should be unnoticeable.

2. Very fast, average level of difficulty in implementation

You can use fixed size fonts, calc number of chars and places, where are new line characters, and then use binary search to find optimal font width, in each try calculating if all chars fit in their window. When optimal value will be found, then paint all chars only one time.

I suggest try number 1, if You still have problems try number 2.

If You will have problems with implementing binary search algorithm, please reply, I will help.

Good luck!

[1]http://en.wikipedia.org/wiki/Binary_search_algorithm