diff options
Diffstat (limited to 'docview/components')
4 files changed, 26 insertions, 6 deletions
diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index e650141b..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 @@ -179,8 +180,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 @@ -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 482a587b..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 @@ -263,9 +265,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 diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas index 606b7805..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 @@ -136,7 +137,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); @@ -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; 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, |