diff --git a/components/thtmlport/package/htmlsubs.pas b/components/thtmlport/package/htmlsubs.pas
index c702cda73..32909f3a0 100755
--- a/components/thtmlport/package/htmlsubs.pas
+++ b/components/thtmlport/package/htmlsubs.pas
@@ -10888,7 +10888,11 @@ with LR do
begin
StartBI := StartB[I];
EndBI := EndB[I];
+{$IFNDEF FPC}
LineStart := StartCurs + Start-Buff; {offset from Section start to Line start}
+{$ELSE}
+ LineStart := StartCurs + PtrUInt(Start)-PtrUInt(Buff); {offset from Section start to Line start}
+{$ENDIF}
if (EndBI > LineStart) and (StartBI < LineStart +Ln) then
begin {it's in this line}
if not Assigned(BorderList) then