Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:34:55+00:00 2026-06-06T20:34:55+00:00

I’m updating some properties in a component. In order to avoid missing property errors

  • 0

I’m updating some properties in a component. In order to avoid missing property errors I’m using DefineProperties to read the old properties from the stream. Most properties work fine e.g. Integer, but I can’t get properties based on TPersistent to work. The ReadProperty(TPersistent) procedure in TReader is protected, not public and requires a hack to access it. Even then, the ReadFontProperty procedure is never called and the missing property exception occurs.

How do I read the TFont property?

Here’s some sample code of how I’m trying to do it.

...

type
  TMyComponent = class(TComponent)
  strict private
    // Removed 
    //FIntegerProperty: Integer;
    //FFontProperty: TFont;

    // New
    FNewIntegerProperty: Integer;
    FNewFontProperty: TFont;

    procedure ReadIntegerProperty(Reader: TReader);
    procedure ReadFontProperty(Reader: TReader);
  protected
    procedure DefineProperties(Filer: TFiler); override;
  published
    // Removed properties
    //property IntegerProperty: Integer read FIntegerProperty write FIntegerProperty;
    //property FontProperty: TFont read FFontProperty write SetFontProperty;

    // New properties
    property NewIntegerProperty: Integer read FNewIntegerProperty write FNewIntegerProperty;
    property NewFontProperty: TFont read FNewFontProperty write SetNewFontProperty;
  end;

implementation

procedure TMyComponent.DefineProperties(Filer: TFiler);
begin
  inherited;

  // This works
  Filer.DefineProperty('IntegerProperty', ReadIntegerProperty, nil, FALSE);

  // This doesn't
  Filer.DefineProperty('FontProperty', ReadFontProperty, nil, FALSE);
end;

procedure TMyComponent.ReadIntegerProperty(Reader: TReader);
begin
  FNewIntegerProperty:= Reader.ReadInteger;
end;

type
  THackReader = class(TReader);

procedure TMyComponent.ReadFontProperty(Reader: TReader);
begin
  { TODO : This doesn't work. How do we read fonts? }
  THackReader(Reader).ReadProperty(FNewFontProperty);
end;

...

Update 1

Tried David’s suggestion using the following code:

Filer.DefineProperty('Font.CharSet', ReadFontCharSet, nil, False);

…

procedure TMyComponent.ReadFontCharSet(Reader: TReader);
begin
  Reader.ReadInteger;
end;

I get an Invalid Property Value error. I guess it’s something to do with Charset being of type TFontCharset (= System.UITypes.TFontCharset = 0..255). How do I read this type of property?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:34:57+00:00Added an answer on June 6, 2026 at 8:34 pm

    In order to do this you need to work with each individual published property of TFont and you will need to use fully qualified names.

    Filer.DefineProperty('FontProperty.Name', ReadFontName, nil, False);
    Filer.DefineProperty('FontProperty.Height', ReadFontHeight, nil, False);
    Filer.DefineProperty('FontProperty.Size', ReadFontSize, nil, False);
    // and so on for all the other published properties of TFont
    

    ReadFontName, ReadFontHeight etc. should read the old property values into the newly named component.

    procedure TMyComponent.ReadFontName(Reader: TReader);
    begin
      FNewFontProperty.Name := Reader.ReadString;
    end;
    
    // etc. etc.
    

    Update

    You ask how to read the Charset property. This is complex because it can be written either as a textual identifier (see the FontCharsets constant in Graphics.pas), or as a plain integer value. Here is some rapidly hacked together code that will read your Charset.

    procedure TMyComponent.ReadFontCharset(Reader: TReader);
    
      function ReadIdent: string;
      var
        L: Byte;
        LResult: AnsiString;
      begin
        Reader.Read(L, SizeOf(Byte));
        SetString(LResult, PAnsiChar(nil), L);
        Reader.Read(LResult[1], L);
        Result := UTF8ToString(LResult);
      end;
    
      function ReadInt8: Shortint;
      begin
        Reader.Read(Result, SizeOf(Result));
      end;
    
      function ReadInt16: Smallint;
      begin
        Reader.Read(Result, SizeOf(Result));
      end;
    
    var
      Ident: string;
      CharsetOrdinal: Integer;
    
    begin
      Beep;
      case Reader.ReadValue of
      vaIdent:
        begin
          Ident := ReadIdent;
          if not IdentToCharset(Ident, CharsetOrdinal) then begin
            raise EReadError.Create('Could not read MyFont.Charset');
          end;
          FNewFontProperty.Charset := CharsetOrdinal;
        end;
      vaInt8:
        FNewFontProperty.Charset := ReadInt8;
      vaInt16:
        FNewFontProperty.Charset := ReadInt16;
      else
        raise EReadError.Create('Could not read FontProperty.Charset');
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.