Linuxuser1234 1 Posted November 2, 2022 im trying to add a custom font 'DSEG' which is basically a seven segment display does anyone have any code examples i can use i have tried some before but i couldn't get the code working Share this post Link to post
Dave Nottage 557 Posted November 2, 2022 You mean without having to install the font? Which version of Delphi are you using? Share this post Link to post
Linuxuser1234 1 Posted November 2, 2022 @Dave Nottage i am using Delphi 10.4 Community Edition Share this post Link to post
Dave Nottage 557 Posted November 2, 2022 3 minutes ago, Linuxuser1234 said: i am using Delphi 10.4 Community Edition I asked because of an issue that was fixed in 11.2, but there's a patch for 10.4: https://quality.embarcadero.com/browse/RSP-17030 I'm working on some code that should make it convenient to load fonts at runtime (on Windows), but for Delphi 10.4, that patch will be required. Share this post Link to post
vfbb 285 Posted November 2, 2022 Another option that works in XE7+ and cross-platform is use the Skia4delphi as your app render. Then you only need to add the follow code in the app initialization: initialization TSkTypefaceManager.RegisterTypeface('Material Design Icons Desktop.ttf'); 1 Share this post Link to post
Linuxuser1234 1 Posted November 2, 2022 @vfbb with skia4delphi can i also use that library to make a text rendering engine where i want to have a 2d troundrect with a shadow on to my viewport 3d to display wind data/temperature data and have the text change color based on the temp or wind data is that possible with skia4delphi Share this post Link to post
Linuxuser1234 1 Posted November 2, 2022 @vfbb i also get a undeclared identifier errors initialization TSkTypefaceManager.RegisterTypeface('C:\Boltgui\Popups\Font\DSEG14ClassicMini-Bold.ttf'); end. Share this post Link to post
Linuxuser1234 1 Posted November 2, 2022 here is the full unit file code unit Unit7; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListBox, FMX.Effects, FMX.Edit, FMX.ComboEdit, FMX.Media, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdMessage, IdAttachment, IdAuthentication; type TForm7 = class(TForm) ArcDial1: TArcDial; Rectangle1: TRectangle; Label1: TLabel; Label2: TLabel; Label4: TLabel; Label5: TLabel; ShadowEffect1: TShadowEffect; ComboEdit1: TComboEdit; Image1: TImage; Button1: TButton; Image2: TImage; Label3: TLabel; Button2: TButton; Image3: TImage; Image4: TImage; RoundRect1: TRoundRect; Line1: TLine; Rectangle2: TRectangle; Rectangle3: TRectangle; GlowEffect1: TGlowEffect; Label6: TLabel; MediaPlayer1: TMediaPlayer; IdHTTP1: TIdHTTP; Label7: TLabel; Label8: TLabel; RoundRect2: TRoundRect; Label9: TLabel; procedure Button1Click(Sender: TObject); procedure IdHTTP1Authorization(Sender: TObject; Authentication: TIdAuthentication; var Handled: Boolean); private { Private declarations } public { Public declarations } end; var Form7: TForm7; implementation {$R *.fmx} procedure TForm7.Button1Click(Sender: TObject); //This Button Connects to weatherusa radio server and change //a few labels caption begin Label2.Text := '162.550 MHz'; Label6.Text := 'Status: Connected'; Label5.Text := 'KEC61'; //default Wx radio Station Label7.Text := 'AL'; //default state Label8.Text := 'Mobile'; Button1.Text := 'Click to disconnect from weatherusa.net'; end; procedure TForm7.IdHTTP1Authorization(Sender: TObject; Authentication: TIdAuthentication; var Handled: Boolean); begin // connect to weatherusa end; initialization TSkTypefaceManager.RegisterTypeface('C:\Boltgui\Popups\Font\DSEG14ClassicMini-Bold.ttf'); end. Share this post Link to post
dwrbudr 8 Posted November 2, 2022 I'm not familiar with FMX internals, but won't that work? AddFontResourceEx(AFileName, FR_PRIVATE, nil); Share this post Link to post
vfbb 285 Posted November 2, 2022 @Linuxuser1234 To be clearer, follow the steps: Install Skia4Delphi via GetIt or by downloading the installer from github. Enable the use of Skia in your project: right click on the project > "Enable Skia" Open your project's dpr to enable Skia as your app's renderer and to register the custom font you want: uses System.StartUpCopy, FMX.Forms, Skia, // << Skia.FMX, // << Unit1 in 'Unit1.pas' {Form1}; {$R *.res} begin GlobalUseSkia := True; // << TSkTypefaceManager.RegisterTypeface('C:\Boltgui\Popups\Font\DSEG14ClassicMini-Bold.ttf'); // << Application.Initialize; ... Share this post Link to post
Linuxuser1234 1 Posted November 2, 2022 @vfbb ok so i added that to my dbr project file so in my unit7 file how would i apply that font to TLabel2 Share this post Link to post
vfbb 285 Posted November 2, 2022 51 minutes ago, Linuxuser1234 said: @vfbb ok so i added that to my dbr project file so in my unit7 file how would i apply that font to TLabel2 You should use the font family name (which is not necessarily the same as the file name) in family property of controls. One problem you will face is that this property in designtime only lists the fonts registered on your system, so you must install the font on your system (by double clicking on it), and reopen your IDE, so that you can select your font on the Family property. Note: only you will install the font on the system (to be able to select it inside the IDE), your clients will not need it. Share this post Link to post
XylemFlow 8 Posted November 3, 2022 I have a custom font in my Windows app. I created the font as a .ttf file. It gets installed under Windows with the app using Inno Setup. It can then be used like any other font within the app. You can do something similar for other platforms. Share this post Link to post