View Single Post
  #5 (permalink)  
Old 26th February 2004
Fenyo Fenyo is offline
Junior Member
BS.player Regular User
Join Date: Jun 2002
Location: Hungary
Posts: 15
Rep Power: 0
Fenyo is an unknown quantity at this point

I totaly agree about wrapping/making-up subtitles!
And i think this is a very important thing to BSPlayer, a lot of people complains about this problem! (cause at a too long line BSPlayer uses a very small font, and text is unreadable!!)
It would be great if BSPlayer can truncate a too long line, and continue it in a new line! It would be just an option in the options/subtitles.

And NO, this is NOT a hard programming challenge! I'm a programmer, and i know, that making this is very easy. I made such type of line truncating and continuing in a new line.

And my recommendation for programming this: Just check if text is not fitting the window/screen(there is functions for measuring the width of a text with a font), and compute that how many windows/screens the text can fit(with rounding up, so 1.1 screen is 2 screen), and just divide text to so many parts, placing the edge of a line to the splitting positions(just variables storing the position in the text), and get back these values with a WHILE if the current position is not a space(so splitting the text at spaces, not at words).

This is look like this in delphi:

Screens:=RoundUp(MeasureWidth(Text) / ScreenWidth);
if Screens>1 then begin
__Edges:=Length(Text) div Screens;
__for i:=0 to Screens-1 do begin
____while (j>0) and (Text[j]<>' ') do dec(j);

And now we have just split the text to X parts at SplittingPoints. That's all.
I know, that this is a simplified example, but it will do for a begin. :)

I try to write it in C++ (I'm not too good in C++, i learned it long ago, and i'm not using C++ so much(yet), so please excuse me the syntax confusing/mistaking ;) ).

int Screens=RoundUp(MeasureWidth(Text) / ScreenWidth);
if(Screens>1) {
__int Edges=Length(Text) div Screens;
__for(int i=0; i<Screens-1; i++) {
____int j=(i+1)*Edges;
____while ((j>0) && (Text[j]!=32)) j--;

That's all.

Sorry for my bad english. ;)
Reply With Quote

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20