Browse Source

basic fix issue -- text layout calculation problem
Text is scanned character by character and based on the analysis of symbols is formed TextView.Layout (string index), which contains information about the beginning of lines in the text store, and rendering options. The rendering options are calculated for each row individually, on the basis of data from the font. To calculate the height of the row is calculated height of each character in the row and selects the highest value.
Problem that when scanning characters of the last line, character EOT(0) is treated as part of the text, and attempt to obtain from the font settings for the character with code EOT(0) gives an incorrect result. Thus, the parameters of the last(only) line are calculated incorrectly. This is manifested in different artifacts when rendering text is incorrectly aligned the text in single-line fields, the last line in multiline elements has a large vertical offset ( particularly evident on the ttf fonts. If you set the parameter System.Configuration.WindowManager.FontManager.DefaultFont to the TTF font, PET/Notepad... it will be clearly seen)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6382 8c9fc860-2736-0410-a75d-ab315db34111

eth.metacore 9 years ago
parent
commit
2b59851919
1 changed files with 10 additions and 6 deletions
  1. 10 6
      source/WMTextView.Mod

+ 10 - 6
source/WMTextView.Mod

@@ -2079,7 +2079,7 @@ TYPE
 			cf := GetFont();
 			style.font := cf;
 
-			x := 0; l.pos := pos; l.height := style.font.GetHeight(); eol := FALSE;
+			x := 0; l.pos := pos; l.height := style.font.GetHeight();
 
 			(* For layouting a reordered line, the reordered text is needed, to correctly measure
 				the extends of each character. *)
@@ -2128,10 +2128,11 @@ TYPE
 			highlighterStyle := NIL; lastHighlighterStyle := NIL;
 			currentStyle := NIL; lastStyle := NIL;
 
-			REPEAT
+			eol := FALSE;
+			readerPosition := localTextReader.GetPosition();
+			localTextReader.ReadCh(ch);
 
-				readerPosition := localTextReader.GetPosition();
-				localTextReader.ReadCh(ch);
+			WHILE ~(localTextReader.eot OR eol) DO
 
 				IF (highlighter # NIL) THEN
 					ASSERT(state # NIL);
@@ -2297,8 +2298,11 @@ TYPE
 				ELSE
 					eol := TRUE
 				END;
-				INC(i)
-			UNTIL eol OR localTextReader.eot;
+				INC(i);
+				readerPosition := localTextReader.GetPosition();
+				localTextReader.ReadCh(ch);
+			END;
+
 
 			l.width := x;
 			l.ascent := ascent; l.height := leading; (* ascent + descent; *)