You've already forked lazarus-ccr
PowerPDF, convert text to winansiencoding before getting textwidth
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1199 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1290,7 +1290,11 @@ var
|
|||||||
tmpWidth: Single;
|
tmpWidth: Single;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
{$IFDEF LAZ_POWERPDF}
|
||||||
|
// for invalid char, any value less than 32 will make FFont.GetCharWidth
|
||||||
|
// to return a default missing width for that font.
|
||||||
|
Text := _UTF8ToWinAnsi(Text, #31);
|
||||||
|
{$ENDIF}
|
||||||
// calculate width of specified text from current attributes
|
// calculate width of specified text from current attributes
|
||||||
for i := 1 to Length(Text) do
|
for i := 1 to Length(Text) do
|
||||||
begin
|
begin
|
||||||
@ -1321,6 +1325,10 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
tmpTotalWidth := 0;
|
tmpTotalWidth := 0;
|
||||||
|
|
||||||
|
{$IFDEF LAZ_POWERPDF}
|
||||||
|
Text := _UTF8ToWinAnsi(Text, #31);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
// calculate number of charactor contain in the specified width.
|
// calculate number of charactor contain in the specified width.
|
||||||
for i := 1 to Length(Text) do
|
for i := 1 to Length(Text) do
|
||||||
begin
|
begin
|
||||||
@ -2159,7 +2167,7 @@ end;
|
|||||||
|
|
||||||
procedure TPdfCanvas.RoundRect(x, y, width, height, rx, ry: Single);
|
procedure TPdfCanvas.RoundRect(x, y, width, height, rx, ry: Single);
|
||||||
var
|
var
|
||||||
hm,wm,h1,w1:single;
|
h1,w1:single;
|
||||||
begin
|
begin
|
||||||
h1 := ry*11/20;
|
h1 := ry*11/20;
|
||||||
w1 := rx*11/20;
|
w1 := rx*11/20;
|
||||||
|
@ -300,6 +300,7 @@ type
|
|||||||
|
|
||||||
{$IFDEF LAZ_POWERPDF}
|
{$IFDEF LAZ_POWERPDF}
|
||||||
function _UTF8StrToUnicodeHex(const Value:string): string;
|
function _UTF8StrToUnicodeHex(const Value:string): string;
|
||||||
|
function _UTF8ToWinAnsi(const value:string; InvalidChar:char='?'): string;
|
||||||
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string);
|
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string);
|
||||||
function PdfLazFindClass(aClassName: string):TPersistentClass;
|
function PdfLazFindClass(aClassName: string):TPersistentClass;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1052,7 +1053,7 @@ end;
|
|||||||
//type
|
//type
|
||||||
// TConvFunc=function(const W:Word): char;
|
// TConvFunc=function(const W:Word): char;
|
||||||
|
|
||||||
function CP1252(const W: Word): Char;
|
function CP1252(const W: Word; const InvalidChar: Char): Char;
|
||||||
begin
|
begin
|
||||||
case W of
|
case W of
|
||||||
$00..$7F,$A0..$FF: result := char(W);
|
$00..$7F,$A0..$FF: result := char(W);
|
||||||
@ -1084,19 +1085,10 @@ begin
|
|||||||
$017E: result := #$9E;
|
$017E: result := #$9E;
|
||||||
$0178: result := #$9F;
|
$0178: result := #$9F;
|
||||||
else
|
else
|
||||||
result:='?';
|
result:=InvalidChar;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function UnicodeToWinAnsi(W: widestring): string;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
result := '';
|
|
||||||
for i:=1 to length(w) do
|
|
||||||
result := result + CP1252(word(w[i]));
|
|
||||||
end;
|
|
||||||
|
|
||||||
// _EscapeText
|
// _EscapeText
|
||||||
function _EscapeText(const Value: string): string;
|
function _EscapeText(const Value: string): string;
|
||||||
const
|
const
|
||||||
@ -1106,15 +1098,17 @@ var
|
|||||||
i, j: integer;
|
i, j: integer;
|
||||||
flg: boolean;
|
flg: boolean;
|
||||||
S: string;
|
S: string;
|
||||||
W: widestring;
|
|
||||||
begin
|
begin
|
||||||
// If text contains chars to need escape, replace text using "\".
|
// If text contains chars to need escape, replace text using "\".
|
||||||
//
|
//
|
||||||
// TODO: implement UNICODE support in powerpdf. Currently we can't do
|
// TODO: implement UNICODE support in powerpdf. Currently we can't do
|
||||||
// any better than converting utf-8 strings to unicode.
|
// any better than converting utf-8 strings to unicode.
|
||||||
W := UTF8Decode(Value);
|
|
||||||
S := UnicodeToWinAnsi(W);
|
|
||||||
result := '';
|
result := '';
|
||||||
|
{$IFDEF LAZ_POWERPDF}
|
||||||
|
S := _UTF8ToWinAnsi(Value);
|
||||||
|
{$ELSE}
|
||||||
|
S := Value;
|
||||||
|
{$ENDIF}
|
||||||
for i := 1 to Length(S) do
|
for i := 1 to Length(S) do
|
||||||
begin
|
begin
|
||||||
flg := false;
|
flg := false;
|
||||||
@ -1207,6 +1201,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function _UTF8ToWinAnsi(const value: string; InvalidChar:char='?'): string;
|
||||||
|
var
|
||||||
|
W: widestring;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
W := UTF8Decode(Value);
|
||||||
|
result := '';
|
||||||
|
for i:=1 to length(w) do
|
||||||
|
result := result + CP1252(word(w[i]), InvalidChar);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string);
|
procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string);
|
||||||
begin
|
begin
|
||||||
Classes.RegisterClass(aClass);
|
Classes.RegisterClass(aClass);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Version Minor="9" Release="4"/>
|
<Version Minor="9" Release="5"/>
|
||||||
<Files Count="12">
|
<Files Count="12">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="PdfTypes.pas"/>
|
<Filename Value="PdfTypes.pas"/>
|
||||||
|
Reference in New Issue
Block a user