mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 16:39:15 +02:00
Moves FreeType font creation into CreateFontIndirect in LCL-CustomDrawn non-native text
git-svn-id: trunk@35690 -
This commit is contained in:
parent
6ade22b5c6
commit
96193a39b6
@ -40,8 +40,10 @@ uses
|
|||||||
{$ifdef WinCE}aygshell,{$endif}
|
{$ifdef WinCE}aygshell,{$endif}
|
||||||
// Widgetset
|
// Widgetset
|
||||||
customdrawnproc,
|
customdrawnproc,
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
// LazFreeType
|
// LazFreeType
|
||||||
LazFreeTypeIntfDrawer, LazFreeType, EasyLazFreeType,
|
LazFreeTypeIntfDrawer, LazFreeType, EasyLazFreeType,
|
||||||
|
{$endif}
|
||||||
// LCL
|
// LCL
|
||||||
customdrawn_common, customdrawncontrols, customdrawndrawers,
|
customdrawn_common, customdrawncontrols, customdrawndrawers,
|
||||||
lazcanvas, lazregions, lazdeviceapis,
|
lazcanvas, lazregions, lazdeviceapis,
|
||||||
@ -84,6 +86,17 @@ type
|
|||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{ TLazCDCustomFont }
|
||||||
|
|
||||||
|
TLazCDCustomFont = class(TFPCustomFont)
|
||||||
|
public
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
FTFont: TFreeTypeFont;
|
||||||
|
{$endif}
|
||||||
|
constructor Create; override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCDWidgetSet }
|
{ TCDWidgetSet }
|
||||||
|
|
||||||
TCDWidgetSet = class(TWidgetSet)
|
TCDWidgetSet = class(TWidgetSet)
|
||||||
@ -382,6 +395,25 @@ const
|
|||||||
{$ifdef CD_Cocoa}
|
{$ifdef CD_Cocoa}
|
||||||
const
|
const
|
||||||
CDBackendNativeHandle = nhtCocoaNSWindow;
|
CDBackendNativeHandle = nhtCocoaNSWindow;
|
||||||
|
|
||||||
|
{ TLazCDCustomFont }
|
||||||
|
|
||||||
|
constructor TLazCDCustomFont.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
FTFont := TFreeTypeFont.Create;
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TLazCDCustomFont.Destroy;
|
||||||
|
begin
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
FTFont.Free;
|
||||||
|
{$endif}
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
{$define CD_HasNativeFormHandle}
|
{$define CD_HasNativeFormHandle}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TCDWidgetSet.CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT;
|
function TCDWidgetSet.CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT;
|
||||||
var
|
var
|
||||||
lFont: TFPCustomFont;
|
lFont: TLazCDCustomFont;
|
||||||
// FamilyName: string;
|
// FamilyName: string;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseCDDrawing}
|
{$ifdef VerboseCDDrawing}
|
||||||
@ -546,9 +546,16 @@ begin
|
|||||||
[LongFontName, LogFont.lfHeight]));
|
[LongFontName, LogFont.lfHeight]));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
lFont := TFPCustomFont.Create;
|
lFont := TLazCDCustomFont.Create;
|
||||||
Result := HFONT(lFont);
|
Result := HFONT(lFont);
|
||||||
|
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
lFont.ftFont.Name := BackendGetFontPath(LogFont, LongFontName);
|
||||||
|
lFont.ftFont.Hinted := true;
|
||||||
|
lFont.ftFont.ClearType := true;
|
||||||
|
lFont.ftFont.Quality := grqHighQuality;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
(*const
|
(*const
|
||||||
QStyleStategy: array [DEFAULT_QUALITY..CLEARTYPE_NATURAL_QUALITY] of QFontStyleStrategy = (
|
QStyleStategy: array [DEFAULT_QUALITY..CLEARTYPE_NATURAL_QUALITY] of QFontStyleStrategy = (
|
||||||
{ DEFAULT_QUALITY } QFontPreferDefault,
|
{ DEFAULT_QUALITY } QFontPreferDefault,
|
||||||
@ -2192,17 +2199,12 @@ begin
|
|||||||
// Preparations finished, draw it using LazFreeType
|
// Preparations finished, draw it using LazFreeType
|
||||||
|
|
||||||
FTDrawer := TIntfFreeTypeDrawer.Create(lDestIntfImage);
|
FTDrawer := TIntfFreeTypeDrawer.Create(lDestIntfImage);
|
||||||
ftFont := TFreeTypeFont.Create; //only one font at once for now...
|
ftFont := TFreeTypeFont(lDestCanvas.ExtraFontData);
|
||||||
try
|
try
|
||||||
ftFont.Name := BackendGetFontPath(DC);
|
|
||||||
ftFont.Hinted := true;
|
|
||||||
ftFont.ClearType := true;
|
|
||||||
ftFont.Quality := grqHighQuality;
|
|
||||||
RealX := X + lDestCanvas.WindowOrg.X + lDestCanvas.BaseWindowOrg.X;
|
RealX := X + lDestCanvas.WindowOrg.X + lDestCanvas.BaseWindowOrg.X;
|
||||||
RealY := Y + lDestCanvas.WindowOrg.Y + lDestCanvas.BaseWindowOrg.Y;
|
RealY := Y + lDestCanvas.WindowOrg.Y + lDestCanvas.BaseWindowOrg.Y + lFontSize;
|
||||||
FTDrawer.DrawText(Str, ftFont, RealX, RealY, colBlack, 255);
|
FTDrawer.DrawText(Str, ftFont, RealX, RealY, colBlack, 255);
|
||||||
finally
|
finally
|
||||||
ftFont.Free;
|
|
||||||
FTDrawer.Free;
|
FTDrawer.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5308,6 +5310,9 @@ begin
|
|||||||
Result := HGDIOBJ(TLazCanvas(DC).AssignedFont);
|
Result := HGDIOBJ(TLazCanvas(DC).AssignedFont);
|
||||||
TLazCanvas(DC).AssignFontData(lFont); // := doesn't work and Assign() raises exceptions
|
TLazCanvas(DC).AssignFontData(lFont); // := doesn't work and Assign() raises exceptions
|
||||||
TLazCanvas(DC).AssignedFont := lFont;
|
TLazCanvas(DC).AssignedFont := lFont;
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
TLazCanvas(DC).ExtraFontData := TLazCDCustomFont(lFont).FTFont;
|
||||||
|
{$endif}
|
||||||
end
|
end
|
||||||
else if aObject is TFPCustomPen then
|
else if aObject is TFPCustomPen then
|
||||||
begin
|
begin
|
||||||
|
@ -156,9 +156,16 @@ begin
|
|||||||
if LogFont.lfStrikeOut>0 then Include(cf.Style, cfs_Strikeout);
|
if LogFont.lfStrikeOut>0 then Include(cf.Style, cfs_Strikeout);
|
||||||
cf.Antialiased:=logFont.lfQuality>=ANTIALIASED_QUALITY;
|
cf.Antialiased:=logFont.lfQuality>=ANTIALIASED_QUALITY;
|
||||||
Result:=HFONT(cf);
|
Result:=HFONT(cf);
|
||||||
end;
|
end;*)
|
||||||
|
|
||||||
function Create32BitAlphaBitmap(ABitmap, AMask: TCocoaBitmap): TCocoaBitmap;
|
{$ifndef CD_UseNativeText}
|
||||||
|
function TCDWidgetSet.BackendGetFontPath(const LogFont: TLogFont; const LongFontName: string): string;
|
||||||
|
begin
|
||||||
|
Result := '/Library/Fonts/Arial.ttf';
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
(*function Create32BitAlphaBitmap(ABitmap, AMask: TCocoaBitmap): TCocoaBitmap;
|
||||||
var
|
var
|
||||||
ARawImage: TRawImage;
|
ARawImage: TRawImage;
|
||||||
Desc: TRawImageDescription absolute ARawimage.Description;
|
Desc: TRawImageDescription absolute ARawimage.Description;
|
||||||
@ -384,11 +391,6 @@ begin
|
|||||||
lazdc := TLazCanvas(DC);
|
lazdc := TLazCanvas(DC);
|
||||||
lazdc.AlphaBlend(ScreenDC, X, Y, 0, 0, ScreenBitmapWidth, ScreenBitmapHeight);
|
lazdc.AlphaBlend(ScreenDC, X, Y, 0, 0, ScreenBitmapWidth, ScreenBitmapHeight);
|
||||||
end;
|
end;
|
||||||
{$else}
|
|
||||||
function TCDWidgetSet.BackendGetFontPath(DC: HDC): string;
|
|
||||||
begin
|
|
||||||
Result := '/Library/Fonts/Arial.ttf';
|
|
||||||
end;
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
(*{------------------------------------------------------------------------------
|
(*{------------------------------------------------------------------------------
|
||||||
|
@ -628,9 +628,16 @@ begin
|
|||||||
Result := HCURSOR(TQtCursor.Create(APixmap, IconInfo^.xHotspot, IconInfo^.yHotspot));
|
Result := HCURSOR(TQtCursor.Create(APixmap, IconInfo^.xHotspot, IconInfo^.yHotspot));
|
||||||
QPixmap_destroy(APixmap);
|
QPixmap_destroy(APixmap);
|
||||||
end;
|
end;
|
||||||
end;
|
end;*)
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{$ifndef CD_UseNativeText}
|
||||||
|
function TCDWidgetSet.BackendGetFontPath(const LogFont: TLogFont; const LongFontName: string): string;
|
||||||
|
begin
|
||||||
|
Result := '/Library/Fonts/Arial.ttf';
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
(*{------------------------------------------------------------------------------
|
||||||
Function: CreatePatternBrush
|
Function: CreatePatternBrush
|
||||||
Params: HBITMAP
|
Params: HBITMAP
|
||||||
Returns: HBRUSH
|
Returns: HBRUSH
|
||||||
@ -2084,11 +2091,6 @@ begin
|
|||||||
|
|
||||||
Result := True; }
|
Result := True; }
|
||||||
end;
|
end;
|
||||||
{$else}
|
|
||||||
function TCDWidgetSet.BackendGetFontPath(DC: HDC): string;
|
|
||||||
begin
|
|
||||||
Result := '/Library/Fonts/Arial.ttf';
|
|
||||||
end;
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
(*{------------------------------------------------------------------------------
|
(*{------------------------------------------------------------------------------
|
||||||
|
@ -63,6 +63,9 @@ function CreateCompatibleDC(DC: HDC): HDC; override;
|
|||||||
//function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override;
|
//function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override;
|
||||||
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
|
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
|
||||||
function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override;
|
function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override;
|
||||||
|
{$ifndef CD_UseNativeText}
|
||||||
|
function BackendGetFontPath(const LogFont: TLogFont; const LongFontName: string): string;
|
||||||
|
{$endif}
|
||||||
function CreateIconIndirect(IconInfo: PIconInfo): HICON; override;
|
function CreateIconIndirect(IconInfo: PIconInfo): HICON; override;
|
||||||
//function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override;
|
//function CreatePatternBrush(ABitmap: HBITMAP): HBRUSH; override;
|
||||||
function CreatePenIndirect(const LogPen: TLogPen): HPEN; override;
|
function CreatePenIndirect(const LogPen: TLogPen): HPEN; override;
|
||||||
@ -91,9 +94,6 @@ function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExPr
|
|||||||
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
|
||||||
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;*)
|
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;*)
|
||||||
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||||
{$ifndef CD_UseNativeText}
|
|
||||||
function BackendGetFontPath(DC: HDC): string;
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
||||||
//function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
//function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user