freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use "autofitter" with TTF


From: Devesh Sharma (M20AIE233)
Subject: Re: How to use "autofitter" with TTF
Date: Wed, 28 Jun 2023 13:25:35 +0530



On Wed, Jun 28, 2023 at 11:46 AM Werner LEMBERG <wl@gnu.org> wrote:

>> What exactly do you want to achieve?  If FreeType gets linked with
>> HarfBuzz (which you should always do), the `glyph-to-script-map`
>> property should be correctly set automatically – for SFNT-based
>> font formats, that is, which is both used by TTFs and CFFs.
>> However, you won't find any other font formats today that can be
>> universally used on all platforms.
>
> I want pygame->freetype->render_to() interface to render devnagari
> text with autofitting.  That is not happening currently, and I am
> traversing the entire stack to get it done properly.  I am not sure
> where the gap is?  If you can give me any example code in the
> freetype code base which details the usage of "autofitter", that
> would be great.

If you have Devanagari text as input and you want correctly rendered
Devanagari as output, using FreeType directly is a bad idea.  I
strongly suggest that you use a higher-level library, at least
HarfBuzz, or probably even one more level higher, that is, Pango or
ICU. 
Thanks a lot for the directions. I would try Pango, During my exploration I came across Pango, HarfBuzz, Cairo, Pangocairo, I paused the trail because those are becoming too many without the knowledge of the right sequence of usage. I shall resume that trail again. 
I'm not sure whether you are aware of the intricate technical
problems related to the rendering of complex scripts like Devanagari
and frieds, but handling them directly by yourself is like reinventing
the wheel.
I am not aware explicitly, but I can imagine that there may be multiple rounds of adjusting the glyphs as per the placement rules and availability of glyphs. Few are rendered left to right while others right to left the list must be long.

Irrespective of that, you should give more details on your setup, in
particular, which font you are using.  Normally, if you load a glyph
with the `FT_LOAD_FORCE_AUTOHINT` flag set, the auto-hinter kicks in
while `FT_Load_Glyph` is called the first time.  It uses HarfBuzz to
set up the glyph-to-script mapping, then checking whether the
necessary glyphs for the blue strings are available (see file
`afblue.dat`) so that the blue zones are correctly set up.
I did not have much insight on the above steps; however, I will build the lib in debug-mode and try to check what is happening when pygame is initiating the rendering.

Maybe you are just missing `FT_LOAD_FORCE_AUTOHINT`?  You could also
compile FreeType with debugging support and set the `FT2_DEBUG`
environment variable to get more information.  See file `docs/DEBUG`
for more information.
That's the plan! I shall get back with more debug data.
Best Regards
Devesh


   Werner

reply via email to

[Prev in Thread] Current Thread [Next in Thread]