Forum > LazUtils

[LazFreeType] Resource Font

<< < (2/5) > >>

circular:
You may be right. Can you tell me where you've taken the parts that you've put together in your function ? From which files ?

Vladimyr:
well, that's everything i learned.
when an instance of TFreeTypeFont is initializing,
the following procedures are being called
(I put module names in curved brackets):

_SetName {EazyLazFreeType.pas}
  \________UpdateFace {EazyLazFreeType.pas}
     \______TT_Open_Face {LazFreeType.pas}
        \____TT_Open_Stream {TTFile.pas}
           \__Stream_New {TTFile.pas}
            |_Stream_Activate (here are the file access operations!) {TTFile.pas}
           /__Cache_New {TTCache.pas}
           \__cache.clazz^.init {TTCache.pas}
            \_Face_Create (called indirectly, via "cache.clazz^.init") {TTObjs.pas}
             \_Cache_Create {TTCache.pas}
             |_Load_TrueType_Header * {TTLoad.pas}
             |_Load_TrueType_MaxProfile * {TTLoad.pas}
             |_Load_TrueType_Locations * {TTLoad.pas}
             |_Load_TrueType_CMap * {TTLoad.pas}
             |_Load_TrueType_CVT * {TTLoad.pas}
             |_Load_TrueType_Metrics_Header * {TTLoad.pas}
             |_Load_TrueType_Programs * {TTLoad.pas}
             |_Load_TrueType_Gasp * {TTLoad.pas}
             |_Load_TrueType_Names * {TTLoad.pas}
             |_Load_TrueType_OS2 * {TTLoad.pas}
             |_Load_TrueType_Hdmx * {TTLoad.pas}
             |_Load_TrueType_Postscript * {TTLoad}
             |_Load_TrueType_Metrics_Header * {TTLoad.pas}

* - these are the procedures I joined into LoadFromRecource function.
Each of these ones contain "TT_Seek_File", "TT_Access_Frame", etc. {TTFile.pas}

I'm shocked as tangled are these procedures!
Looks like it was ported from C, its limbs stick out of everywhere.  %)

circular:
Yes it's a mess. I totally agree. I tried to put some it into classes, but there is still much to do.

I understand. In fact, I would like to rewrite completely the file access. I don't like those calls TT_Seek etc. outside of an object. So we could both add loading from resources, and also improve the way the library is written.

Thanks a lot for this description. It will be useful for this purpose.

Ask:

--- Quote --- I would like to rewrite completely the file access.
--- End quote ---
If you do that, please also try to reduce the amount of range check errors --
that code is written in true C style, with buffer overruns everywhere :)

circular:
Here is a patch for file access. It goes now through a TFreeTypeStream class, and TFreeTypeFont has a AccessFromStream function to load the font from any stream. There is a AStreamOwner parameter to specify that the stream must be freed by the font.

So for example, to load from a file, you can do that if you want :

--- Code: ---    stream:= TFileStream.Create('arial.ttf',fmOpenRead);
    ftFont := TFreeTypeFont.Create;
    ftFont.AccessFromStream(stream,True{will be freed});
--- End code ---

Instead of doing this :

--- Code: ---ftFont := TFreeTypeFont.Create;
    ftFont.Name := 'arial.ttf';  [/quote]

About range check errors, I do not know what you're talking about Ask.
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version