[haiku-appserver] Re: BFont ServerFont implementation, GetHasGlyphs()

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Wed, 20 Jul 2005 00:06:41 +0200

Hi Jérôme,

> I tried to have GetHasGlyphs working and went through several issues :
> 
> * how a BFont is identified server side : should there be a ServerFont
> object for every BFont ? If not, a lot of BFont properties have to be
> sent server side for most FT computations. Is this the way to go ?

From the code I have read so far, I think ServerFont is created on the fly 
or used however one sees fit. There is no direct connection to the BFont 
objects that are floating arround on client side. I have no idea if that is 
good or bad. So until we have made up our minds on this, you need to put 
all data necessary into the message in order to have enough information for 
the correct result of a given BFont call.

> * BFont is using a Encoding()/SetEncoding() scheme, which makes me think
> methods can accept character string in a non utf8 encoding. What are we
> supposed to do ? (convert_to_utf8 client side, server side, let FT know
> the encoding and handle) (the last point implies we pass a complete
> character string to FT)

For the code I have written, I worried only about UTF8. I have not looked 
far enough into the FreeType API yet, to know how encodings are controlled 
and used during glyph retrieval.

> * ServerFont is sometimes implemented with this kind of code, which is
> wrong :
> for (int i = 0; i < numChars; i++) {
>    ...
>    FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP);
> }
> 
> nth char of charArray isn't charArray[i]. I would go with a
> next_utf8_char() if we were sure about the UTF8 encoding.

Some of the newer code already has this. For example, you pointed out how 
the BPoint version of GetEscapements() was wrong. The UTF8 aware version is 
the float (width) version of the same call. One would have to simply copy 
over the code or think of a way to refactor this, so that the UTF8 -> glyph 
index conversion is in one place.
 
> * GetHasGlyphs needs to know when a glyph is available for a character :
> do I have to call FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP);
> and check for the return value ?

Yes. NULL means that there was no glyph for the given glyph index. For now, 
you could just copy the implementation in the GetEscapements float version. 
One thing to be aware of: When I messed arround in StringWidth() (which is 
UTF8 aware as well), I noticed that the Painter version is way faster. I 
know that in Painter (AGGTextRenderer), I'm using the AGG glyph cache. It 
appears that the native FT glyph cache is not turned on, or not working 
when using ServerFont and therefor FT directly. Maybe we can think of 
moving the AGG font engine to a more central place and use it not only for 
rendering.

Best regards,
-Stephan

Other related posts: