Recent

Author Topic: [LazFreeType] Resource Font  (Read 24868 times)

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [LazFreeType] Resource Font
« Reply #15 on: February 08, 2013, 07:51:48 pm »
Thanks for testing.  :)

excuse me, but one question is left: can it work with BGRATextFX?
Ok. I've updated BGRABitmap on subversion, now in TBGRAFreeTypeDrawer, you have a CreateTextEffect function.

Quote
but even if i set font collection, how to select one font between the other ones?
or the font from resource stream still can be used somehow?
Ok. Here is a patch to add a font from a stream into a font collection.

Can you give it a try ?
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [LazFreeType] Resource Font
« Reply #16 on: February 08, 2013, 07:53:34 pm »
@ask:

Ok now I got some range check errors, when running LazUtils with range check option.

It appears that variable types are not consistent with loading instruction from the frame buffer.
Conscience is the debugger of the mind

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [LazFreeType] Resource Font
« Reply #17 on: February 08, 2013, 09:22:51 pm »
Quote
I tested it with some files.
Can you post your test program?

Quote
Ok. Here is a patch to add a font from a stream into a font collection.
Hm. Note that:
1) Init procedure is redundant, since class members are auto-zeroed on construction.
2) TFreeTypeFontCollection.AddStream has 90% common code with AddFile.

I could fix both problems myself, but I need a test :)

Quote
very strange commit.... the patch uploaded here does not contain 'A Count'
Sorry about that.


circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [LazFreeType] Resource Font
« Reply #18 on: February 09, 2013, 10:27:50 am »
Here is test program for AddStream.

Note that you need to copy in timesi.ttf (Times New Roman Italic) and arial.ttf (Arial Regular).
Conscience is the debugger of the mind

Vladimyr

  • New member
  • *
  • Posts: 7
Re: [LazFreeType] Resource Font
« Reply #19 on: February 09, 2013, 02:59:32 pm »
Finally, I got everything working.

Correct approach was to create a default font collection,
add several fonts into it from resource stream, set this
collection as default one, and select each font via
Code: [Select]
xxx.FontNamereferring to its internal name (not file name nor resource name).

Also, too many ways to draw text make things a bit complicated
for beginners. These ones are:
Code: [Select]
BGRABitmap.TextOut (...)
BGRAFreeTypeDrawer.DrawText (...)
BGRAVectorizedFontRenderer.TextOut (...)
BGRATextEffect.Draw (...)

Now I use the 4th variant, but it could be interesting to learn
the difference. What I discovered for now:
1) can draw shadow, can't use stream font;
2) can't draw shadow, can use stream font;
3) can draw shadow, can't use stream font;
4) can draw shadow, can use stream font.

Hope it will be useful to know that for somebody.
Thank you again for your inestimable work!  8)
« Last Edit: February 09, 2013, 03:23:25 pm by Vladimyr »

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [LazFreeType] Resource Font
« Reply #20 on: February 09, 2013, 10:42:04 pm »
Hello, you're right, it's too complicated.

I've simplified by adding access to effects from the font renderer.

Now it's very simple. Here is a tutorial about it :
http://wiki.freepascal.org/BGRABitmap_tutorial_Font_rendering

I've also added explanations in BGRAText, BGRATextFX, BGRAVectorize and BGRAFreeType units.
« Last Edit: February 09, 2013, 11:12:47 pm by circular »
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018