mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-03 12:40:38 +02:00
--- Merging r43290 into '.':
U packages/fcl-image/src/freetype.pp --- Recording mergeinfo for merge of r43290 into '.': U . --- Merging r43291 into '.': G packages/fcl-image/src/freetype.pp --- Recording mergeinfo for merge of r43291 into '.': G . --- Merging r43292 into '.': U packages/fcl-image/src/libfreetype.inc --- Recording mergeinfo for merge of r43292 into '.': G . --- Merging r43293 into '.': U packages/fcl-image/examples/textout.pp G packages/fcl-image/src/freetype.pp U packages/fcl-image/src/ftfont.pp --- Recording mergeinfo for merge of r43293 into '.': G . --- Merging r43334 into '.': U packages/fcl-image/src/freetypehdyn.pp --- Recording mergeinfo for merge of r43334 into '.': G . --- Merging r43335 into '.': U packages/fcl-image/src/fphelper.inc --- Recording mergeinfo for merge of r43335 into '.': G . --- Merging r43420 into '.': U packages/rtl-generics/src/inc/generics.dictionaries.inc --- Recording mergeinfo for merge of r43420 into '.': G . # revisions: 43290,43291,43292,43293,43334,43335,43420 git-svn-id: branches/fixes_3_2@44300 -
This commit is contained in:
parent
c06a8ad7bb
commit
7b1408640e
@ -50,6 +50,8 @@ begin
|
||||
Font.FPColor:=colBlack;
|
||||
S:='Hello, world!';
|
||||
Canvas.TextOut(20,20,S);
|
||||
F.Size := 14.5;
|
||||
Canvas.TextOut(20,30,S);
|
||||
U:=UTF8Decode('привет, Мир!');
|
||||
Font.FPColor:=colBlue;
|
||||
Canvas.TextOut(50,50,U);
|
||||
|
@ -114,6 +114,8 @@ begin
|
||||
except
|
||||
FCanvas := nil;
|
||||
FAllocated := False;
|
||||
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -135,11 +135,11 @@ type
|
||||
function GetGlyph (c : cardinal) : PMgrGlyph;
|
||||
function CreateGlyph (c : cardinal) : PMgrGlyph;
|
||||
procedure MakeTransformation (angle:real; out Transformation:FT_Matrix);
|
||||
procedure InitMakeString (FontID, Size:integer);
|
||||
function MakeString (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:string; Size:integer) : TStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:Unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
procedure InitMakeString (FontID, Size:real);
|
||||
function MakeString (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:string; Size:real) : TStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:Unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
function MakeString (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
public
|
||||
constructor Create;
|
||||
destructor destroy; override;
|
||||
@ -147,17 +147,17 @@ type
|
||||
function RequestFont (afilename:string) : integer;
|
||||
function RequestFont (afilename:string; anindex:integer) : integer;
|
||||
function GetFreeTypeFont (aFontID:integer) : PFT_Face;
|
||||
function GetString (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function GetString (FontId:integer; Text:Unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function GetString (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
function GetString (FontId:integer; Text:Unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
// Black and white
|
||||
function GetStringGray (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text:unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text:unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
// Anti Aliased gray scale
|
||||
function GetString (FontId:integer; Text:string; Size:integer) : TStringBitmaps;
|
||||
function GetString (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
function GetString (FontId:integer; Text:string; Size:real) : TStringBitmaps;
|
||||
function GetString (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
// Black and white, following the direction of the font (left to right, top to bottom, ...)
|
||||
function GetStringGray (FontId:integer; Text: String; Size:integer) : TStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text: String; Size:real) : TStringBitmaps;
|
||||
function GetStringGray (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
// Anti Aliased gray scale, following the direction of the font (left to right, top to bottom, ...)
|
||||
property SearchPath : string read GetSearchPath write SetSearchPath;
|
||||
property DefaultExtention : string read FExtention write SetExtention;
|
||||
@ -195,7 +195,7 @@ const
|
||||
{$IFDEF MAC}
|
||||
DefaultResolution : integer = 72;
|
||||
{$ELSE}
|
||||
DefaultResolution : integer = 97;
|
||||
DefaultResolution : integer = 96;
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
@ -518,8 +518,7 @@ procedure TFontManager.SetPixelSize (aSize, aResolution : integer);
|
||||
end;
|
||||
end;
|
||||
|
||||
var s : longint;
|
||||
Err : integer;
|
||||
var Err : integer;
|
||||
|
||||
begin
|
||||
with Curfont, Font^ do
|
||||
@ -532,8 +531,7 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
s := aSize shl 6;
|
||||
Err := FT_Set_char_size (Font, s, s, aResolution, aResolution);
|
||||
Err := FT_Set_char_size (Font, aSize, aSize, aResolution, aResolution);
|
||||
if Err <> 0 then
|
||||
FTError (format(sErrSetCharSize,[aSize,aResolution]), Err);
|
||||
end;
|
||||
@ -587,31 +585,33 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFontManager.InitMakeString (FontID, Size:integer);
|
||||
procedure TFontManager.InitMakeString (FontID, Size:real);
|
||||
begin
|
||||
GetSize (size,Resolution);
|
||||
GetSize (round(size*64),Resolution);
|
||||
UseKerning := ((Curfont.font^.face_flags and FT_FACE_FLAG_KERNING) <> 0);
|
||||
end;
|
||||
|
||||
function TFontManager.MakeString (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function TFontManager.MakeString (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
|
||||
Var
|
||||
T : Array of cardinal;
|
||||
C,I : Integer;
|
||||
U: UnicodeString;
|
||||
|
||||
begin
|
||||
CurFont := GetFont(FontID);
|
||||
InitMakeString (FontID, Size);
|
||||
c := length(text);
|
||||
U := UnicodeString(Text);
|
||||
c := length(U);
|
||||
result := TStringBitmaps.Create(c);
|
||||
result.FText := Text;
|
||||
SetLength(T,Length(Text));
|
||||
For I:=1 to Length(Text) do
|
||||
T[I-1]:=Ord(Text[i]);
|
||||
SetLength(T,c);
|
||||
For I:=1 to c do
|
||||
T[I-1]:=Ord(U[i]);
|
||||
DoMakeString(T,Angle,Result);
|
||||
end;
|
||||
|
||||
function TFontManager.MakeString (FontId:integer; Text:Unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function TFontManager.MakeString (FontId:integer; Text:Unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
|
||||
Var
|
||||
T : Array of cardinal;
|
||||
@ -736,25 +736,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFontManager.MakeString (FontId:integer; Text:string; Size:integer) : TStringBitmaps;
|
||||
function TFontManager.MakeString (FontId:integer; Text:string; Size:real) : TStringBitmaps;
|
||||
|
||||
Var
|
||||
T : Array of Cardinal;
|
||||
C,I : Integer;
|
||||
U : UnicodeString;
|
||||
|
||||
begin
|
||||
CurFont := GetFont(FontID);
|
||||
InitMakeString (FontID, Size);
|
||||
c := length(text);
|
||||
U := UnicodeString(Text);
|
||||
c := length(U);
|
||||
result := TStringBitmaps.Create(c);
|
||||
result.FText := Text;
|
||||
SetLength(T,Length(Text));
|
||||
For I:=1 to Length(Text) do
|
||||
T[I-1]:=Ord(Text[i]);
|
||||
SetLength(T,c);
|
||||
For I:=1 to c do
|
||||
T[I-1]:=Ord(U[i]);
|
||||
DoMakeString(T,Result);
|
||||
end;
|
||||
|
||||
function TFontManager.MakeString (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
function TFontManager.MakeString (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
|
||||
Var
|
||||
T : Array of Cardinal;
|
||||
@ -853,14 +855,14 @@ begin
|
||||
ABitmaps.CalculateGlobals;
|
||||
end;
|
||||
|
||||
function TFontManager.GetString (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function TFontManager.GetString (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
// Black and white
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_MONO;
|
||||
result := MakeString (FontID, text, Size, angle);
|
||||
end;
|
||||
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:string; size:integer; angle:real) : TStringBitmaps;
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:string; size:real; angle:real) : TStringBitmaps;
|
||||
// Anti Aliased gray scale
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_NORMAL;
|
||||
@ -869,28 +871,28 @@ end;
|
||||
|
||||
{ Procedures without angle have own implementation to have better speed }
|
||||
|
||||
function TFontManager.GetString (FontId:integer; Text:string; Size:integer) : TStringBitmaps;
|
||||
function TFontManager.GetString (FontId:integer; Text:string; Size:real) : TStringBitmaps;
|
||||
// Black and white, following the direction of the font (left to right, top to bottom, ...)
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_MONO;
|
||||
result := MakeString (FontID, text, Size);
|
||||
end;
|
||||
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:string; Size:integer) : TStringBitmaps;
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:string; Size:real) : TStringBitmaps;
|
||||
// Anti Aliased gray scale, following the direction of the font (left to right, top to bottom, ...)
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_NORMAL;
|
||||
result := MakeString (FontID, text, Size);
|
||||
end;
|
||||
|
||||
function TFontManager.GetString (FontId:integer; Text:Unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function TFontManager.GetString (FontId:integer; Text:Unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
// Black and white
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_MONO;
|
||||
result := MakeString (FontID, text, Size, angle);
|
||||
end;
|
||||
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:Unicodestring; size:integer; angle:real) : TUnicodeStringBitmaps;
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:Unicodestring; size:real; angle:real) : TUnicodeStringBitmaps;
|
||||
// Anti Aliased gray scale
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_NORMAL;
|
||||
@ -899,14 +901,14 @@ end;
|
||||
|
||||
{ Procedures without angle have own implementation to have better speed }
|
||||
|
||||
function TFontManager.GetString (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
function TFontManager.GetString (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
// Black and white, following the direction of the font (left to right, top to bottom, ...)
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_MONO;
|
||||
result := MakeString (FontID, text, Size);
|
||||
end;
|
||||
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:Unicodestring; Size:integer) : TUnicodeStringBitmaps;
|
||||
function TFontManager.GetStringGray (FontId:integer; Text:Unicodestring; Size:real) : TUnicodeStringBitmaps;
|
||||
// Anti Aliased gray scale, following the direction of the font (left to right, top to bottom, ...)
|
||||
begin
|
||||
CurRenderMode := FT_RENDER_MODE_NORMAL;
|
||||
|
@ -25,7 +25,7 @@ uses sysutils, dynlibs;
|
||||
|
||||
|
||||
initialization
|
||||
InitializeFreetype(FreeTypeDLL);
|
||||
//InitializeFreetype(FreeTypeDLL); - do not load DLL in initialization, it is loaded when needed in ftfont.InitEngine
|
||||
|
||||
finalization
|
||||
ReleaseFreetype;
|
||||
|
@ -20,7 +20,7 @@ interface
|
||||
{$DEFINE DYNAMIC}
|
||||
|
||||
uses
|
||||
SysUtils, Classes, FPCanvas, fpimgcmn,
|
||||
SysUtils, Classes, FPCanvas, fpimgcmn, math,
|
||||
{$IFDEF DYNAMIC}freetypehdyn{$ELSE} freetypeh{$ENDIF},
|
||||
freetype;
|
||||
|
||||
@ -35,15 +35,18 @@ type
|
||||
FLastText : TBaseStringBitmaps;
|
||||
FIndex, FFontID : integer;
|
||||
FFace : PFT_Face;
|
||||
FRealSize: real;
|
||||
FAngle : real;
|
||||
procedure ClearLastText;
|
||||
protected
|
||||
procedure DrawLastText (atX,atY:integer);
|
||||
procedure DrawChar (x,y:integer; data:PByteArray; pitch, width, height:integer); virtual;
|
||||
procedure DrawCharBW (x,y:integer; data:PByteArray; pitch, width, height:integer); virtual;
|
||||
procedure SetAngle(const aAngle: real); virtual;
|
||||
procedure SetName (AValue:string); override;
|
||||
procedure SetIndex (AValue : integer);
|
||||
procedure SetSize (AValue : integer); override;
|
||||
procedure SetRealSize(ARealSize : real); virtual;
|
||||
function GetFlags (index:integer) : boolean; override;
|
||||
procedure SetFlags (index:integer; AValue:boolean); override;
|
||||
procedure DoAllocateResources; override;
|
||||
@ -61,12 +64,13 @@ type
|
||||
procedure GetText (aText:unicodestring);
|
||||
procedure GetFace;
|
||||
public
|
||||
constructor create; override;
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
property FontIndex : integer read FIndex write SetIndex;
|
||||
property Resolution : longword read FResolution write FResolution;
|
||||
property AntiAliased : boolean read FAntiAliased write FAntiAliased;
|
||||
property Angle : real read FAngle write FAngle;
|
||||
property Size : real read FRealSize write SetRealSize;
|
||||
property Angle : real read FAngle write SetAngle;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -98,6 +102,7 @@ begin
|
||||
FFontID := -1;
|
||||
FAntiAliased := True;
|
||||
FResolution := DefaultResolution;
|
||||
FRealSize := Size;
|
||||
end;
|
||||
|
||||
destructor TFreeTypeFont.Destroy;
|
||||
@ -128,6 +133,14 @@ begin
|
||||
FFontID := FontMgr.RequestFont(Name, FIndex);
|
||||
end;
|
||||
|
||||
procedure TFreeTypeFont.SetRealSize(ARealSize: real);
|
||||
begin
|
||||
if SameValue(FRealSize, ARealSize) then Exit;
|
||||
ClearLastText;
|
||||
inherited Size := Round(ARealSize);
|
||||
FRealSize := ARealSize;
|
||||
end;
|
||||
|
||||
procedure TFreeTypeFont.SetIndex (AValue : integer);
|
||||
begin
|
||||
FIndex := AValue;
|
||||
@ -140,6 +153,7 @@ procedure TFreeTypeFont.SetSize (AValue : integer);
|
||||
begin
|
||||
ClearLastText;
|
||||
inherited;
|
||||
FRealSize := inherited Size;
|
||||
end;
|
||||
|
||||
procedure TFreeTypeFont.ClearLastText;
|
||||
@ -254,7 +268,7 @@ var b : boolean;
|
||||
begin
|
||||
if assigned (FLastText) then
|
||||
begin
|
||||
if FLastText.InheritsFrom(TUnicodeStringBitmaps) or (CompareStr(TStringBitMaps(FLastText).Text,aText) <> 0) then
|
||||
if not (FLastText.InheritsFrom(TStringBitMaps) and (CompareStr(TStringBitMaps(FLastText).Text,aText) = 0)) then
|
||||
begin
|
||||
FLastText.Free;
|
||||
b := true;
|
||||
@ -275,9 +289,9 @@ begin
|
||||
begin
|
||||
FontMgr.Resolution := FResolution;
|
||||
if FAntiAliased then
|
||||
FLastText := FontMgr.GetStringGray (FFontId, aText, Size, Angle)
|
||||
FLastText := FontMgr.GetStringGray (FFontId, aText, FRealSize, Angle)
|
||||
else
|
||||
FLastText := FontMgr.GetString (FFontId, aText, Size, Angle);
|
||||
FLastText := FontMgr.GetString (FFontId, aText, FRealSize, Angle);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -286,7 +300,7 @@ var b : boolean;
|
||||
begin
|
||||
if assigned (FLastText) then
|
||||
begin
|
||||
if FLastText.InheritsFrom(TStringBitmaps) or (TUnicodeStringBitMaps(FLastText).Text<>aText) then
|
||||
if not (FLastText.InheritsFrom(TUnicodeStringBitMaps) and (TUnicodeStringBitMaps(FLastText).Text=aText)) then
|
||||
begin
|
||||
FLastText.Free;
|
||||
b := true;
|
||||
@ -307,12 +321,19 @@ begin
|
||||
begin
|
||||
FontMgr.Resolution := FResolution;
|
||||
if FAntiAliased then
|
||||
FLastText := FontMgr.GetStringGray (FFontId, aText, Size, Angle)
|
||||
FLastText := FontMgr.GetStringGray (FFontId, aText, FRealSize, Angle)
|
||||
else
|
||||
FLastText := FontMgr.GetString (FFontId, aText, Size, Angle);
|
||||
FLastText := FontMgr.GetString (FFontId, aText, FRealSize, Angle);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFreeTypeFont.SetAngle(const aAngle: real);
|
||||
begin
|
||||
if FAngle = aAngle then Exit;
|
||||
ClearLastText;
|
||||
FAngle := aAngle;
|
||||
end;
|
||||
|
||||
procedure TFreeTypeFont.DoDrawText (atX,atY:integer; atext:unicodestring);
|
||||
|
||||
begin
|
||||
|
@ -427,7 +427,7 @@ Var
|
||||
function InitializeFreetype(const LibraryName: UnicodeString = ''): Integer;
|
||||
function InitializeFreetype(const LibraryName: AnsiString):integer;
|
||||
function TryInitializeFreetype(const LibraryName: Unicodestring = ''): Integer;
|
||||
function ReleaseFreetype: Integer;
|
||||
procedure ReleaseFreetype;
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
@ -536,7 +536,7 @@ begin
|
||||
result:=InitializeFreetype(UnicodeString(LibraryName));
|
||||
end;
|
||||
|
||||
function ReleaseFreetype:integer;
|
||||
procedure ReleaseFreetype;
|
||||
begin
|
||||
if InterlockedDecrement(RefCount) <= 0 then
|
||||
begin
|
||||
|
@ -2163,7 +2163,7 @@ end;
|
||||
|
||||
{ TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.TPKeyEnumerator }
|
||||
|
||||
function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.TPKeyEnumerator.GetCurrent: TKey;
|
||||
function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.TPKeyEnumerator.GetCurrent: PKey;
|
||||
begin
|
||||
if FMainIndex = TCuckooCfg.D then
|
||||
Result := @(TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>(FDictionary).FQueue.FItems[FIndex].Pair.Value.Pair.Key)
|
||||
|
Loading…
Reference in New Issue
Block a user