Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-10

freetype unit + unicode

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Emerson

I am using the freetype unit (with linux) and would like to display some interesting unicode characters. However when I pass a string containing say U+2265 to GetStringGray, it doesn't display the unicode character at all; it shows 3 other characters in its place. What to do?

btw I'm still using fpc 2.4.2 in case this is an issue that has been recently addressed

Thanks,
David

Reply by email

Graeme Geldenhuys
to David Emerson
David Emerson wrote
I am using the freetype unit (with linux) and would like to display some interesting unicode characters. However when I pass a string containing say U+2265 to GetStringGray, it doesn't display the unicode character at all; it shows 3 other characters in its place. What to do?

What freetype API function are you calling? Not sure if it applies to freetype, but with Xft (as implemented and used in fpGUI), there are various versions of the same API. You need to call the correct one based on the encoding type of you text.

procedure XftDrawStringUtf8(...); cdecl; external libXft;
procedure XftDrawString8(...); cdecl; external libXft;
procedure XftDrawString16(...); cdecl; external libXft;

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

David Emerson
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
On 03/10/2011 21:51, David Emerson wrote: > I am using the freetype unit (with linux) and would like to display some > interesting unicode characters. However when I pass a string containing say > U+2265 to GetStringGray, it doesn't display the unicode character at all; it > shows 3 other characters in its place. What to do? What freetype API function are you calling? Not sure if it applies to freetype, but with Xft (as implemented and used in fpGUI), there are various versions of the same API. You need to call the correct one based on the encoding type of you text.

freetype.GetStringGray

I've tried tweaking all kinds of things but the sad truth is that I am really pathetic at figuring out libraries when no documentation is given, and I sure can't find any documentation.

I see that the fpgui helloworld program handles unicode nicely. I guess I'll try and imitate whatever's happening there.

Thanks again, Graeme!

~D.

Show quoted text 17 lines
procedure XftDrawStringUtf8(...); cdecl; external libXft; procedure XftDrawString8(...); cdecl; external libXft; procedure XftDrawString16(...); cdecl; external libXft; Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

David Emerson
to David Emerson
Show quoted text 13 lines
> What freetype API function are you calling? Not sure if it applies to > freetype, but with Xft (as implemented and used in fpGUI), there are > various versions of the same API. You need to call the correct one based > on the encoding type of you text. freetype.GetStringGray I've tried tweaking all kinds of things but the sad truth is that I am really pathetic at figuring out libraries when no documentation is given, and I sure can't find any documentation. I see that the fpgui helloworld program handles unicode nicely. I guess I'll try and imitate whatever's happening there.

Easier said than done... the reason I've been using freetype.GetStringGray (oops, excuse me -- freetype.TFontManager.GetStringGray) is that it returns TStringBitmaps, which I can use within my framework. It looks like the behavior of XftDrawStringUtf8 is to draw something on the screen, whereas I need to access the individual character glyphs and do the drawing later. hum.

Is there some secret, hidden documentation for fpc's freetype unit? (and so many other units?) :P

~David.

Show quoted text 12 lines
> procedure XftDrawStringUtf8(...); cdecl; external libXft; > procedure XftDrawString8(...); cdecl; external libXft; > procedure XftDrawString16(...); cdecl; external libXft; > > > Regards, > - Graeme - > > -- > fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal > http://fpgui.sourceforge.net/ >

Reply by email

Unknown author
to David Emerson
David Emerson wrote 22 lines
>> What freetype API function are you calling? Not sure if it applies to >> freetype, but with Xft (as implemented and used in fpGUI), there are >> various versions of the same API. You need to call the correct one based >> on the encoding type of you text. > > freetype.GetStringGray > > I've tried tweaking all kinds of things but the sad truth is that I am really > pathetic at figuring out libraries when no documentation is given, and I sure > can't find any documentation. > > I see that the fpgui helloworld program handles unicode nicely. I guess I'll > try and imitate whatever's happening there. Easier said than done... the reason I've been using freetype.GetStringGray (oops, excuse me -- freetype.TFontManager.GetStringGray) is that it returns TStringBitmaps, which I can use within my framework. It looks like the behavior of XftDrawStringUtf8 is to draw something on the screen, whereas I need to access the individual character glyphs and do the drawing later. hum. Is there some secret, hidden documentation for fpc's freetype unit? (and so many other units?) :P

No.

But you are in luck: this is open source, and the Lazarus IDE lets you jump and look around in the FPC code very easily :-)

If you need some UTF8 extensions to the freetype unit, feel free to make some suggestions, and we'll see what we can do.

When the unit was made, unicode support was a thing of the distant future. (a future which of course crept up on us faster than we imagined)

Michael.

Reply by email

David Emerson
to Unknown author
Show quoted text 13 lines
> Is there some secret, hidden documentation for fpc's freetype unit? (and so > many other units?) :P No. But you are in luck: this is open source, and the Lazarus IDE lets you jump and look around in the FPC code very easily :-) If you need some UTF8 extensions to the freetype unit, feel free to make some suggestions, and we'll see what we can do. When the unit was made, unicode support was a thing of the distant future. (a future which of course crept up on us faster than we imagined)

Ah, this is the answer I was looking for! Well this looks like a place where I might actually be able to contribute some code to the fpc project, which is something I've been wanting to be able to do for a long time. We'll see how that goes.

Of course the first task is to get fpc and lazarus configured to use the svn version, something I've attempted and abandoned countless times. Hmmm.

~David.

Reply by email

David Emerson
to Unknown author: No. But you are in luck: this is open source, and the Lazarus IDE lets you jump and look…
Show quoted text 5 lines
If you need some UTF8 extensions to the freetype unit, feel free to make some suggestions, and we'll see what we can do. When the unit was made, unicode support was a thing of the distant future. (a future which of course crept up on us faster than we imagined)

attached is a patch, which (if applied correctly...) seems to work, yay! Here is a picture:
http://david9.freepgs.com/i/spline-unicode-text.png

I copied a few UTF8 string functions from the LCLProc unit, so that is kind of sloppy but there it is. I'm not sure if analogs exist within fpc.

Surprisingly little needed to be changed!

Reply by email

Unknown author
to David Emerson
David Emerson wrote 15 lines
On Tue 4 Oct 2011, wrote: > If you need some UTF8 extensions to the freetype unit, feel free to make > some suggestions, and we'll see what we can do. > > When the unit was made, unicode support was a thing of the distant future. > (a future which of course crept up on us faster than we imagined) attached is a patch, which (if applied correctly...) seems to work, yay! Here is a picture: http://david9.freepgs.com/i/spline-unicode-text.png I copied a few UTF8 string functions from the LCLProc unit, so that is kind of sloppy but there it is. I'm not sure if analogs exist within fpc. Surprisingly little needed to be changed!

Yes, but the problem with this is that it only works with UTF-8 now.

So I would have preferred it if you had created an overloaded or even differently named version of the existing functions, and left the existing functions intact. The way it is now, we'd force everyone to use UTF-8.

I'll see if I can modify the patch.

Michael.

Reply by email

David Emerson
to Unknown author
Show quoted text 9 lines
On Wed, 5 Oct 2011, David Emerson wrote: > On Tue 4 Oct 2011, wrote: >> If you need some UTF8 extensions to the freetype unit, feel free to make >> some suggestions, and we'll see what we can do. > > I copied a few UTF8 string functions from the LCLProc unit, so that is kind > of sloppy but there it is. I'm not sure if analogs exist within fpc. Yes, but the problem with this is that it only works with UTF-8 now.

indeed my inexperience shows (and american mindset!)

Show quoted text 7 lines
So I would have preferred it if you had created an overloaded or even differently named version of the existing functions, and left the existing functions intact. The way it is now, we'd force everyone to use UTF-8. I'll see if I can modify the patch. Michael.

I'd be happy to help in this regard if you want to give me some sort of instructions to go by. Now that you bring up the issue, numerous solutions come to mind. Of course the task is not that big, but I'm eager to help if it would save you any trouble (although tonight it's past my bedtime now...)

~David.

Reply by email