Proper use of TFont

Howdy Folks

I have made a VCL forms application and I wish to use certain fonts for the screen and for printing to PDF. I want the font to be global, so I make a global font variable such as GCommentFont for displaying comments. I don't think I am doing it correctly, as the spacing and character shapes don't reflect the font characteristics.

var

GCommentFont: TFont;

....


GCommentFont:=TFont.Create;
GCommentFont.Name:='Gill Sans MT Pro Condensed';
GCommentFont.Size:=22;

....in printing to Canvas:
  Canvas.Font.Assign(GCommentFont)
  Canvas.DrawText(...
  Canvas.TextOut(...


GCommentFont.Free

Does anyone have a good example? 

By assigning a font name to a newly created font, does this assign all of the fon't attributes (weight, escapement, etc.) to the newly created font?

I would like to do this perfectly, (i.e., create/free) because I do a great deal of font writing and I need highly precise font placement.

Thanks in advance.
0
Doulgas
7/14/2015 11:42:43 AM
embarcadero.delphi.graphics 928 articles. 0 followers. Follow

1 Replies
817 Views

Similar Articles

[PageSpeed] 54

TFont has a PixelsPerInch property that affects the calculation of the 
font height (pixels). A PDF or printer will typically have a DPI of 300 
or even higher compared to the screen DPI of 96 or 120. When you use 
Assign you end up setting the PixelsPerInch as well.

You could change the PPI setting on your global font but it would be 
easier to just do:

Canvas.Font.Name := GCommentFont.Name ;
Canvas.Font.Size := GCommentFont.Size ;

Mitch Wolberg,
RockWare, Inc.



On 7/14/2015 5:42 AM, Doulgas Keene wrote:
> Howdy Folks
>
> I have made a VCL forms application and I wish to use certain fonts for the screen and for printing to PDF. I want the font to be global, so I make a global font variable such as GCommentFont for displaying comments. I don't think I am doing it correctly, as the spacing and character shapes don't reflect the font characteristics.
>
> var
>
> GCommentFont: TFont;
>
> ...
>
>
> GCommentFont:=TFont.Create;
> GCommentFont.Name:='Gill Sans MT Pro Condensed';
> GCommentFont.Size:=22;
>
> ...in printing to Canvas:
>    Canvas.Font.Assign(GCommentFont)
>    Canvas.DrawText(...
>    Canvas.TextOut(...
>
>
> GCommentFont.Free
>
> Does anyone have a good example?
>
> By assigning a font name to a newly created font, does this assign all of the fon't attributes (weight, escapement, etc.) to the newly created font?
>
> I would like to do this perfectly, (i.e., create/free) because I do a great deal of font writing and I need highly precise font placement.
>
> Thanks in advance.
>
0
Mitch
7/14/2015 3:22:52 PM
Reply:

Similar Artilces:

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

How to properly use PeekMessage and WM_QUIT in a single threaded Delphi App [Edit]
Hi, I just want to make sure that this test code I wrote, which seems to work properly, isn't failing to do something that Delphi needs type TfrmMain = class(TForm) btnStart: TButton; procedure FormCreate(Sender: TObject); procedure btnStartClick(Sender: TObject); private { Private declarations } FStop : boolean; public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure Yield; var Msg : TMSG; begin // THIS is the piece of code I want to make sure is "Delphi" fr...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Need info on Game type graphics using Win 7 64 and Delphi XE
Hi all, I'm trying to educate myself from the bottom up on Game design and programming with Delphi XE, its capabilities and comparison to other languages. Specifically I would like to find a way to incorporate the maps for large sandbox environments into a utility feature that would allow owners of a game to load maps up and move about them, navigating and seeing them exactly as they appear in the original game. Such would be useful for commanders to plan team assaults in games like CoD or Battlefield. Unfortunately I haven't had much luck in my research so far. E...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

How design a COM using Delphi and Using in PB7?
I need some component, So, we want using DELPHI5 to develop a COM or Activex. What type of knowege or Skill I must know it. Can anyone tell us? from DRAOGN Can you explain what type of component you want to create? You may not need to a) build your own, or b) use Delphi. If the component should be used from within a PB application, you ought to use PB to develop it unless it is something that PB does not let you do. regards, Bill DRAGON wrote: > I need some component, So, we want using DELPHI5 to develop a COM or > Activex. > What type of knowege or Skill I ...

can i use delphi 2007 bpls in delphi 2009
can i use delphi 2007 bpls in delphi 2009 ? "Gaetan SIRY" skrev i meddelelsen news:8703@forums.codegear.com... > can i use delphi 2007 bpls in delphi 2009 ? No. -- Finn Tolderlund The compatiblity between D2006 and D2007 was unique. Normaly they can't be compatible because new version enhance/change the API. And D2009 defines String = Unicode where older version has String = Ansistring so D200x/Dx-BPL are 200% incompatible with D2009. ...

How to use a delphi XE3 obj file in delphi 2007?
Hi, I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project. I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007. In D200...

If you use Delphi...
If you use Delphi for .NET with ASA, please vote for this: http://qc.borland.com/wc/qcmain.aspx?d=31677 ...

How to use a .dmp file for a system which crashes using a delphi app
Hi, I put this post here because I am not sure of the best location. I have been given a memory dump (.dmp) file by a client who thinks that a Delphi 7 application is causing their system to blue screen from time to time. Does anyone know how I can use this .dmp file to locate the problem in the delphi app? The build the client is using has debug symbols turned on. I have downloaded Microsoft Debugging Tools for windows and have dupmchk.exe (and kd.exe) but I would really appreciate some help with how these or any other useful tools should be used? Many thanks Ben > I have down...

How to use AppModeler to generate Delphi forms using Cached Updates
<HTML> <TT>A beginner's question regarding AppModeler 6.1, Delphi 3, and Interbase 5.x...</TT> <P><TT>While I am impressed with the amount of thought and work that has gone into AppModeler, I have nonetheless been surprised to discover that the Delphi application generated by AppModeler is not suitable for real-world situations because of the "fly-away" problem afflicting newly-entered records.</TT> <P><TT>When I enter a record on an AppModeler-generated Delphi form, the record disappears ("flies away") immedia...

When to use ( and when to use ((?
I'm just not getting it. When do you use ( in a statement, when do you need to use ((, and is the space after either or both mandatory? For example, I coded this statement: if (( $_ eq $bad_guys_ip )) { more_stuff_here }; Why the two (( in an if? And why does it seem to not work when I miss the space after the ((? Thanx! Mark me as... /Corn-fused|Dense/ > I'm just not getting it. >=20 > When do you use ( in a statement, when do you need to use ((, and is > the space after either or both mandatory? >=20 > For example, I coded this sta...

MOVED: Use Delphi XE TLB importer in Delphi 2007?
....to the ActiveX group: https://forums.embarcadero.com/thread.jspa?threadID=47170 -- Craig Stuntz · Vertex Systems Corp. · Columbus, OH Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/ ...

how to use Graphics-Simple-0.04 > Graphics::Simple
--0-1785423463-1308404988=:74633 Content-Type: text/plain; charset=us-ascii Hi, After successfully installing Tuomas J. Lukka > Graphics-Simple-0.04 > Graphics::Simple I do not know how to use the module. I tried the simple script below but it wont work and produce error msgs. Can someone teach me how to use the module to produce simple graph. Thanks ##### script below ###### #!/usr/bin/perl use Graphics::Simple; line 100,100,200,200; --0-1785423463-1308404988=:74633-- At 6:49 AM -0700 6/18/11, eventual wrote: >Hi, >After successfully installing >Tuomas J...

Web resources about - Proper use of TFont - embarcadero.delphi.graphics

Proper - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Grammarly Celebrates 1M Facebook Likes With (What Else?) Proper Grammar
Reaching 1 million likes on Facebook ain’t nothing to sneeze at, and automated proofreader Grammarly celebrated the achievement by sharing some ...

Army ponders proper shape, size of cyber workforce - FederalNewsRadio.com
The Army still doesn't know whether its new and growing force of soldiers dedicated to cyber missions is large enough for the task. But it's ...

Without Proper Recruiter Search, Monster’s BeKnown Facebook Professional Networking App Lacks Value
Late Saturday, employment website Monster.com launched a professional networking app on Facebook called BeKnown . Users can import work history ...

Ellen Proper (@EllenProper) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

All sizes - U.S. Navy SEALs train with Special Boat Team (SBT) 12 on the proper techniques of how to ...
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Patton Oswalt Discusses the Proper Way to Watch Star Wars Movies - Late Night with Seth Meyers - YouTube ...
Patton Oswalt highly recommends the "Machete Order" viewing procedure. » Subscribe to Late Night: http://bit.ly/LateNightSeth » Get more Late ...

On the Proper Size of the Public Sector, and the Proper Level of Public Debt in the Twenty-First Century ...
**J. Bradford DeLong** ###On the Proper Size of the Public Sector, and the Proper Level of Public Debt in the Twenty-First Century **Introduction** ...

Startup employees: Here is the proper way to value your stock options
There's a lot of angst brewing among startup types over Katie Benner's excellent story on Good Technology in the New York Times today. Good ...

Big Ten: Refs used proper mechanics on Nebraska-Michigan State TD
... by a Michigan State defender on Nebraska's game-winning touchdown down the sideline. The Big Ten said Sunday that officials used “proper officiating ...

Resources last updated: 1/8/2016 3:26:26 AM