From da4db3af243946159219ed468148b55282e5b349 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 6 Aug 2015 00:00:18 +0100 Subject: RichText: fixed the bug where Underlined text didn't work. A simple spelling mistake! --- docview/components/richtext/CanvasFontManager.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docview/components/richtext') diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index e650141b..71e6d2fa 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -179,8 +179,8 @@ begin AFontDesc := AFontDesc + ':Strikeout'; if faUnderScore in Attrs Then - if Pos(':Underscore', AFontDesc) = 0 then - AFontDesc := AFontDesc + ':Underscore'; + if Pos(':Underline', AFontDesc) = 0 then + AFontDesc := AFontDesc + ':Underline'; end; // Provide font name substitutes for some common bitmap fonts found in INF files -- cgit v1.2.3-70-g09d2 From 286870c70d5f7c20c7b6fd94625cb2d028102ee3 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 7 Aug 2015 12:52:47 +0100 Subject: richview: fixes bug with Italic text adding an extra space at the end I thought I fixed all of these before, but I missed this one. --- docview/components/richtext/RichTextDisplayUnit.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docview/components/richtext') diff --git a/docview/components/richtext/RichTextDisplayUnit.pas b/docview/components/richtext/RichTextDisplayUnit.pas index 482a587b..613dba84 100644 --- a/docview/components/richtext/RichTextDisplayUnit.pas +++ b/docview/components/richtext/RichTextDisplayUnit.pas @@ -263,9 +263,10 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); and ( faItalic in Style.FontAttributes ) and ( not FontManager.IsFixed ) then + begin // end of italic; add a space - inc( X, FontManager.CharWidth( ' ' ) ); - +// inc( X, FontManager.CharWidth( ' ' ) ); + end; Layout.PerformStyleTag( Element.Tag, Style, X ); NewMarginX := ( Start.X + Style.LeftMargin ); if NewMarginX > X then -- cgit v1.2.3-70-g09d2 From 06e3090b489f40ce796237dd33df78ed5012fb1f Mon Sep 17 00:00:00 2001 From: Philippe Lévi Date: Sun, 9 Aug 2015 18:54:29 +0100 Subject: richview: correctly typecast result in TLayoutLineList.GetItem() --- docview/components/richtext/RichTextLayoutUnit.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docview/components/richtext') diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas index 606b7805..f5efe08a 100644 --- a/docview/components/richtext/RichTextLayoutUnit.pas +++ b/docview/components/richtext/RichTextLayoutUnit.pas @@ -136,7 +136,7 @@ uses function TLayoutLineList.GetItem(Index: Integer): TLayoutLine; begin - inherited GetItem(Index); + result := TLayoutLine( inherited GetItem(Index)); end; procedure TLayoutLineList.SetItem(Index: Integer; const AValue: TLayoutLine); -- cgit v1.2.3-70-g09d2 From 15e8dd494c2fcfca9df750dc9e31b93b905b9ede Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sun, 9 Aug 2015 19:58:14 +0100 Subject: richview: earmarked TRichTextView.CopyTextToBuffer() to be removed --- docview/components/richtext/RichTextView.pas | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docview/components/richtext') diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas index e890ca54..bc967d59 100644 --- a/docview/components/richtext/RichTextView.pas +++ b/docview/components/richtext/RichTextView.pas @@ -2414,9 +2414,13 @@ begin // BufferLength ); end; +// TODO: This doesn't seem to be used anywhere, so we could probably delete it. function TRichTextView.CopyTextToBuffer( Buffer: PChar; BufferLength: longint ): longint; begin + Result := -1; + // TODO: we do this to trap code using this, so we can fix it accordingly. + raise Exception.Create('TRichTextView.CopyTextToBuffer was called, but it is not implemented yet.'); //Result := CopyPlainTextToBuffer( FText, // FText + strlen( FText ), // Buffer, -- cgit v1.2.3-70-g09d2 From 7a840bd1da714ff057995bebf5240602e25a772d Mon Sep 17 00:00:00 2001 From: Philippe Lévi Date: Sat, 22 Aug 2015 09:02:18 +0100 Subject: richview: fix bug where varied size fonts didn't start on baseline. --- docview/components/richtext/CanvasFontManager.pas | 6 ++++++ docview/components/richtext/RichTextDisplayUnit.pas | 4 +++- docview/components/richtext/RichTextLayoutUnit.pas | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'docview/components/richtext') diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index 71e6d2fa..fe9606e6 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -44,6 +44,7 @@ type constructor Create(ACanvas: TfpgCanvas; AWidget: TfpgWidget); reintroduce; destructor Destroy; override; function AverageCharWidth: longint; + function CharAscender: longint; function CharDescender: longint; function CharHeight: longint; function CharWidth( const C: TfpgChar ): longint; // Retrieve the width of the given char, in the current font @@ -314,6 +315,11 @@ begin Result := FCanvas.Font.TextWidth('c'); end; +function TCanvasFontManager.CharAscender: longint; +begin + Result := FCanvas.Font.Ascent; +end; + function TCanvasFontManager.MaximumCharWidth: longint; begin Result := FCanvas.Font.TextWidth('W'); diff --git a/docview/components/richtext/RichTextDisplayUnit.pas b/docview/components/richtext/RichTextDisplayUnit.pas index 613dba84..cfdd20a7 100644 --- a/docview/components/richtext/RichTextDisplayUnit.pas +++ b/docview/components/richtext/RichTextDisplayUnit.pas @@ -122,6 +122,7 @@ Procedure DrawRichTextLine( var FontManager: TCanvasFontManager; Line: TLayoutLine; Start: TPoint ); var X, Y: longint; + YBaseLine: longint; Element: TTextElement; StartedDrawing: boolean; Style: TTextDrawStyle; @@ -180,7 +181,7 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); TextBlockStart := P; - Y := Start.Y; // + Line.MaxDescender; // co-ordinates are from top/left, so do we need descender? [Graeme] + YBaseLine := Start.Y + Line.MaxAscender; while P < EndP do begin @@ -209,6 +210,7 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); StartedDrawing := true; end; + Y := YBaseLine - FontManager.CharAscender; // Now do the drawing if Element.ElementType = teImage then begin diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas index f5efe08a..8e39d65f 100644 --- a/docview/components/richtext/RichTextLayoutUnit.pas +++ b/docview/components/richtext/RichTextLayoutUnit.pas @@ -23,6 +23,7 @@ Type Length: longint; Height: longint; Width: longint; + MaxAscender: longint; MaxDescender: longint; MaxTextHeight: longint; // maximum height of text, doesn't include images LinkIndex: longint; // link index at start of line, if any @@ -240,8 +241,10 @@ Procedure TRichTextLayout.CheckFontHeights( Var Line: TLayoutLine ); var FontHeight: longint; Descender: longint; + Ascender: longint; begin FontHeight := FFontManager.CharHeight; + Ascender := FFontManager.CharAscender; Descender := FFontManager.CharDescender; if FontHeight > Line.Height then @@ -252,6 +255,9 @@ begin if Descender > Line.MaxDescender then Line.MaxDescender := Descender; + + if Ascender > Line.MaxAscender then + Line.MaxAscender := Ascender; end; function TRichTextLayout.IsValidBitmapIndex( Index: longint ): boolean; @@ -297,6 +303,7 @@ Var CurrentLine := TLayoutLine.Create; CurrentLine.Style := Style; CurrentLine.Height := 0; + CurrentLine.MaxAscender := 0; CurrentLine.MaxDescender := 0; CurrentLine.MaxTextHeight := 0; CurrentLine.Width := 0; -- cgit v1.2.3-70-g09d2