Solved

Font charset in D2

Posted on 1997-07-04
7
495 Views
Last Modified: 2013-12-02
Is it possible to change font charset in D2? I know than in D3 TFont has this property, but I don't have one ;-(
0
Comment
Question by:xire
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:mheacock
ID: 1338209
The charset is a unicode feature...the 32-bit character set.

I don't think that D2's TFont supports unicode, thus I don't
think it is possible.
0
 

Author Comment

by:xire
ID: 1338210
Well, when I read about D2 new features unicode was noticed as as
new feature. Recently I checked D2 VCL sources and found that  charset is there, but it always is set to CHARSET_DEFAULT.
Any ideas?

0
 
LVL 3

Expert Comment

by:mheacock
ID: 1338211
Ideas...I'll see if I can find some time to look at the source
for TFont...

In the meantime, maybe you can look too and tell me this...
what is the property CharSet defined as...or where...is
it protected?  Private?

If it is protected, you can derive a new class from TFont
and move CharSet to the public section, thus giving you access
to it...

I would suspect though that Delphi does not support unicode
in the TFont class.  I know Delphi 2 supports unicode in
its string types (widestring), but if they didn't add this
support to TFont, then you are out of luck...I would suggest
looking for a 3rd party component that supports it...or
derive a new component (as per above) or get Delphi 3.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Gabor
ID: 1338212
I'm afraid you have to recompile your Delphi library, with your modified Graphics.pas unit. I've already made some modification on the original source, and after it I had to recompile... So it isn't so easy. It's worth more than 100 points.
0
 

Author Comment

by:xire
ID: 1338213
Ok. How much do you want for information on how to recompile Delphi library? I alredy tried to do it but failed.
0
 
LVL 1

Accepted Solution

by:
Gabor earned 100 total points
ID: 1338214
I was thinking and I found an easier way for you (maybe it isn't the easiest).

1. The next units have to be copied to your local dir from Delphi\Source\VCL.
     Dialogs
     Extctrls
     Graphics
     Printers
     Controls
     Menus
     Forms

2. Rename all these units to X... (ex. Graphics to XGraphics)!
   Don't forget to change the unit name (unit XGraphics ...)!

3. Add all these units to your project!

4. At 'Project options'->'Directories/Conditionals' add the following text to 'Unit Aliases'
   'Graphics=XGraphics;Controls=XControls;Forms=XForms;Printers=XPrinters;Menus=XMenus;Dialogs=XDialogs;Stdctrls=XStdctrls;Extctrls=XExtctrls'

5. Make the following modifications on XGraphics.pas!

  TFontData = record
    Handle: HFont;
    Height: Integer;
    Pitch: TFontPitch;
    Style: TFontStyles;
    Name: TFontName;
    CharSet: Integer;           {<-insert this field}
  end;
  ...
  {Add these methods to the protected part of TFont}
    function GetCharSet: Integer;
    procedure SetCharSet(cs: Integer);
  ...
  {Add this property to the published part of TFont}
    property CharSet: Integer read GetCharSet write SetCharSet;
  ...
  {At the implementation part / TFont part}
    var
      DefFontData: TFontData = (
        Handle: 0;
        Height: 0;
        Pitch: fpDefault;
        Style: [];
        Name: 'MS Sans Serif';
        CharSet: DEFAULT_CHARSET);      {<-insert this value}
    ...
    {Modify the TFont.GetHandle method}
    ...
            lfCharSet := Font.CharSet;
    ...
    {And the two methods}
    function TFont.GetCharSet: Integer;
    begin
      Result := FResource^.Font.CharSet;
    end;

    procedure TFont.SetCharSet(Value: Integer);
    var
      FontData: TFontData;
    begin
      GetData(FontData);
      FontData.CharSet := Value;
      SetData(FontData);
    end;

OK. I think this will be good for you.
Good luck!

0
 

Author Comment

by:xire
ID: 1338215
ok, i'll try
thanks
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question