You've already forked lazarus-ccr
PowerPDF: implements Justify Alignment by resizing spaces instead of resizing characters, version=9.12
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3825 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -47,7 +47,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF LAZ_POWERPDF}
|
{$IFDEF LAZ_POWERPDF}
|
||||||
LCLType, LMessages, LCLIntf, GraphType, FPCanvas, LCLProc,
|
LCLType, LMessages, LCLIntf, GraphType, FPCanvas, LazUTF8, LCLProc,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows, Messages,
|
Windows, Messages,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1722,10 +1722,11 @@ begin
|
|||||||
for i:=1 to UTF8Length(S) do begin
|
for i:=1 to UTF8Length(S) do begin
|
||||||
Word := UTF8Copy(s, i, 1);
|
Word := UTF8Copy(s, i, 1);
|
||||||
Canvas.TextOut(Round(Pos), Y, Word);
|
Canvas.TextOut(Round(Pos), Y, Word);
|
||||||
with APdfCanvas do
|
with APdfCanvas do begin
|
||||||
Pos := Pos + TextWidth(Word) + Attribute.CharSpace;
|
Pos := Pos + TextWidth(Word) + Attribute.CharSpace;
|
||||||
if Word=' ' then
|
if Word=' ' then
|
||||||
Pos := Pos + FWordSpace
|
Pos := Pos + Attribute.WordSpace;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
result := Pos;
|
result := Pos;
|
||||||
end;
|
end;
|
||||||
@ -1866,6 +1867,9 @@ var
|
|||||||
tmpWidth: Single;
|
tmpWidth: Single;
|
||||||
tmpCharSpace: Single;
|
tmpCharSpace: Single;
|
||||||
CharCount: integer;
|
CharCount: integer;
|
||||||
|
{$IFDEF LAZ_POWERPDF}
|
||||||
|
str: string;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
// setting canvas attribute to the internal doc(to get font infomation).
|
// setting canvas attribute to the internal doc(to get font infomation).
|
||||||
with ACanvas do
|
with ACanvas do
|
||||||
@ -1876,6 +1880,15 @@ begin
|
|||||||
if AlignJustified then
|
if AlignJustified then
|
||||||
begin
|
begin
|
||||||
SetCharSpace(0);
|
SetCharSpace(0);
|
||||||
|
{$IFDEF LAZ_POWERPDF}
|
||||||
|
str := UTF8Trim(Caption, [u8tKeepStart]);
|
||||||
|
tmpWidth := TextWidth(str);
|
||||||
|
CharCount := _GetSpcCount(str);
|
||||||
|
if CharCount>0 then begin
|
||||||
|
tmpCharSpace := (Self.Width - tmpWidth) / CharCount;
|
||||||
|
SetWordSpace(tmpCharSpace);
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
tmpWidth := TextWidth(Caption);
|
tmpWidth := TextWidth(Caption);
|
||||||
CharCount := _GetCharCount(Caption);
|
CharCount := _GetCharCount(Caption);
|
||||||
if CharCount > 1 then
|
if CharCount > 1 then
|
||||||
@ -1884,6 +1897,7 @@ begin
|
|||||||
tmpCharSpace := 0;
|
tmpCharSpace := 0;
|
||||||
if tmpCharSpace > 0 then
|
if tmpCharSpace > 0 then
|
||||||
SetCharSpace(tmpCharSpace);
|
SetCharSpace(tmpCharSpace);
|
||||||
|
{$ENDIF}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
SetCharSpace(CharSpace);
|
SetCharSpace(CharSpace);
|
||||||
|
@ -305,6 +305,7 @@ type
|
|||||||
function _UTF8ToWinAnsi(const value:string; InvalidChar:char='?'): string;
|
function _UTF8ToWinAnsi(const value:string; InvalidChar:char='?'): string;
|
||||||
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; const Alias: string);
|
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; const Alias: string);
|
||||||
function PdfLazFindClass(const aClassName: string):TPersistentClass;
|
function PdfLazFindClass(const aClassName: string):TPersistentClass;
|
||||||
|
function _GetSpcCount(const Text: string): Integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -1236,6 +1237,19 @@ begin
|
|||||||
raise EClassNotFound.CreateFmt('No class was found', [aClassName]);
|
raise EClassNotFound.CreateFmt('No class was found', [aClassName]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function _GetSpcCount(const Text: string): Integer;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
W: widestring;
|
||||||
|
begin
|
||||||
|
result := 0;
|
||||||
|
W := UTF8Decode(Text);
|
||||||
|
for i:=1 to Length(W) do begin
|
||||||
|
if W[i]=' ' then
|
||||||
|
inc(result);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
AliasList := nil;
|
AliasList := nil;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<Package Version="4">
|
<Package Version="4">
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
@ -17,14 +17,10 @@
|
|||||||
</SyntaxOptions>
|
</SyntaxOptions>
|
||||||
</Parsing>
|
</Parsing>
|
||||||
<Other>
|
<Other>
|
||||||
<CompilerMessages>
|
|
||||||
<UseMsgFile Value="True"/>
|
|
||||||
</CompilerMessages>
|
|
||||||
<CustomOptions Value="-dLAZ_POWERPDF"/>
|
<CustomOptions Value="-dLAZ_POWERPDF"/>
|
||||||
<CompilerPath Value="$(CompPath)"/>
|
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Version Minor="9" Release="10"/>
|
<Version Minor="9" Release="12"/>
|
||||||
<Files Count="12">
|
<Files Count="12">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="PdfTypes.pas"/>
|
<Filename Value="PdfTypes.pas"/>
|
||||||
|
Reference in New Issue
Block a user