Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, March 2008
QFont::freetypeFace() under windows


Message 1 in thread

Hey guys,

I recently tried to compile one of my projects under windows and got
compilation errors when trying to use QFont::freetypeFace().

Seems that it is not available under windows, the documentation however
does not state so.

Works fine under linux.

I absolutely cannot live without that function as I need it to gain
access to the outline data of the fonts. Or, I need an alternate way to
do it under windows (though that'd be my least preferred method, I'd
rather stick to one solution fits all).

Is there maybe a flag I can recompile Qt with under windows to gain that
function or anything else I can do?

Thanks,

Stephan




--
 [ signature omitted ] 

Message 2 in thread

On 14.03.08 22:02:48, Stephan Rose wrote:
> Hey guys,
> 
> I recently tried to compile one of my projects under windows and got
> compilation errors when trying to use QFont::freetypeFace().
> 
> Seems that it is not available under windows, the documentation however
> does not state so.
> 
> Works fine under linux.

Because Linux uses the freetype library.

> I absolutely cannot live without that function as I need it to gain
> access to the outline data of the fonts. Or, I need an alternate way to
> do it under windows (though that'd be my least preferred method, I'd
> rather stick to one solution fits all).

As the above is Linux-only API, you'll have to dig into the win32 API
documentation for HFONT. You can get an HFONT structure from
QFont::handle() and I guess from there you can probably find out the
needed information under Windows too.

Thats the price you pay if you use non-cross-platform API's ;)

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

On 15 Mar 2008, at 9:31 am, Andreas Pakulat wrote:

> On 14.03.08 22:02:48, Stephan Rose wrote:
>> Hey guys,
>>
>> I recently tried to compile one of my projects under windows and got
>> compilation errors when trying to use QFont::freetypeFace().
>>
>> Seems that it is not available under windows, the documentation  
>> however
>> does not state so.
>>
>> Works fine under linux.
>
> Because Linux uses the freetype library.
>
>> I absolutely cannot live without that function as I need it to gain
>> access to the outline data of the fonts. Or, I need an alternate  
>> way to
>> do it under windows (though that'd be my least preferred method, I'd
>> rather stick to one solution fits all).
>
> As the above is Linux-only API, you'll have to dig into the win32 API
> documentation for HFONT. You can get an HFONT structure from
> QFont::handle() and I guess from there you can probably find out the
> needed information under Windows too.
>
> Thats the price you pay if you use non-cross-platform API's ;)

Although QFont on Win32 may not use Freetype internally, Freetype  
itself works fine on Windows. So it should be possible to link your  
app with FT and instantiate an FT_Face yourself, provided you can  
locate the right font file to pass to FT_New_Face(). From there on,  
you'd be able to use the same code on both platforms.

JK

--
 [ signature omitted ] 

Message 4 in thread

On Sat, 2008-03-15 at 10:35 +0000, Jonathan Kew wrote:
> On 15 Mar 2008, at 9:31 am, Andreas Pakulat wrote:
> 
> > On 14.03.08 22:02:48, Stephan Rose wrote:
> >> Hey guys,
> >>
> >> I recently tried to compile one of my projects under windows and
got
> >> compilation errors when trying to use QFont::freetypeFace().
> >>
> >> Seems that it is not available under windows, the documentation  
> >> however
> >> does not state so.
> >>
> >> Works fine under linux.
> >
> > Because Linux uses the freetype library.
> >
> >> I absolutely cannot live without that function as I need it to gain
> >> access to the outline data of the fonts. Or, I need an alternate  
> >> way to
> >> do it under windows (though that'd be my least preferred method,
I'd
> >> rather stick to one solution fits all).
> >
> > As the above is Linux-only API, you'll have to dig into the win32
API
> > documentation for HFONT. You can get an HFONT structure from
> > QFont::handle() and I guess from there you can probably find out the
> > needed information under Windows too.
> >
> > Thats the price you pay if you use non-cross-platform API's ;)
> 
> Although QFont on Win32 may not use Freetype internally, Freetype  
> itself works fine on Windows. So it should be possible to link your  
> app with FT and instantiate an FT_Face yourself, provided you can  
> locate the right font file to pass to FT_New_Face(). From there on,  
> you'd be able to use the same code on both platforms.

Two problems with that:

1. QFont doesn't provide a path to the font file (that I know of).

2. Vista is likely to throw a hissy fit and cry for billy if I try to
access a font file directly as it's likely going to be located in the
windows directory tree.

I have used freetype successfully though but only with supplying my own
font files. I'd rather not need to do that though as that's really going
to limit choices for the user.


Thanks,

Stephan




--
 [ signature omitted ] 

Message 5 in thread

On 15.03.08 09:36:21, Stephan Rose wrote:
> 2. Vista is likely to throw a hissy fit and cry for billy if I try to
> access a font file directly as it's likely going to be located in the
> windows directory tree.

Well, this is probably over-simplyfying things, but I suspect most of
the time you face two types of users (wrt. all those "shall X access Y"
message boxes): Those that know how to turn them off once and for all
(and do so) and those that don't who simply click yes anyway as they
know else the program won't function properly (due to past experience).
So while the message box is annoying to 70% of your target audience, it
won't keep them from using your application ;)

Andreas

-- 
 [ signature omitted ] 

Message 6 in thread

On 15 Mar 2008, at 1:35 pm, Stephan Rose wrote:

>>
>> Although QFont on Win32 may not use Freetype internally, Freetype
>> itself works fine on Windows. So it should be possible to link your
>> app with FT and instantiate an FT_Face yourself, provided you can
>> locate the right font file to pass to FT_New_Face(). From there on,
>> you'd be able to use the same code on both platforms.
>
> Two problems with that:
>
> 1. QFont doesn't provide a path to the font file (that I know of).
>
> 2. Vista is likely to throw a hissy fit and cry for billy if I try to
> access a font file directly as it's likely going to be located in the
> windows directory tree.
>
> I have used freetype successfully though but only with supplying my  
> own
> font files. I'd rather not need to do that though as that's really  
> going
> to limit choices for the user.

I suppose you could try getting the font data from GDI with  
GetFontData (pass 0 for dwTable to get the whole file) and then  
handing that to FT_New_Memory_Face.

JK

--
 [ signature omitted ] 

Message 7 in thread

On Sat, 2008-03-15 at 10:31 +0100, Andreas Pakulat wrote:
> On 14.03.08 22:02:48, Stephan Rose wrote:
> > Hey guys,
> > 
> > I recently tried to compile one of my projects under windows and got
> > compilation errors when trying to use QFont::freetypeFace().
> > 
> > Seems that it is not available under windows, the documentation however
> > does not state so.
> > 
> > Works fine under linux.
> 
> Because Linux uses the freetype library.
> 
> > I absolutely cannot live without that function as I need it to gain
> > access to the outline data of the fonts. Or, I need an alternate way to
> > do it under windows (though that'd be my least preferred method, I'd
> > rather stick to one solution fits all).
> 
> As the above is Linux-only API, you'll have to dig into the win32 API
> documentation for HFONT. You can get an HFONT structure from
> QFont::handle() and I guess from there you can probably find out the
> needed information under Windows too.

Freetype works under windows just fine. There is no reason not to be
able to use it.

> 
> Thats the price you pay if you use non-cross-platform API's ;)


Well, the documentation in Qt needs to mark functions as such.

QFont::hfont is marked as being non-portable.

QFont::freetypeface is NOT marked as such.

So either, there is an error in the documentation or there has to be a
way for me to make that function available. The latter would be
preferable. =)

Stephan




--
 [ signature omitted ] 

Message 8 in thread

On Sat, Mar 15, 2008 at 2:49 PM, Stephan Rose <kermos@xxxxxxxxxx> wrote:
>  Well, the documentation in Qt needs to mark functions as such.
>
>  QFont::hfont is marked as being non-portable.
>
>  QFont::freetypeface is NOT marked as such.
>
>  So either, there is an error in the documentation or there has to be a
>  way for me to make that function available. The latter would be
>  preferable. =)

Well, the method is portable :), it's just that freetype isn't used by
default on Windows. But I concur that documentation should state that
this method is only available on freetype builds which isn't default
on Windows, and not MacOSX either I think.

-- 
 [ signature omitted ] 

Message 9 in thread

On 15.03.08 15:06:48, Robin Helgelin wrote:
> On Sat, Mar 15, 2008 at 2:49 PM, Stephan Rose <kermos@xxxxxxxxxx> wrote:
> >  Well, the documentation in Qt needs to mark functions as such.
> >
> >  QFont::hfont is marked as being non-portable.
> >
> >  QFont::freetypeface is NOT marked as such.
> >
> >  So either, there is an error in the documentation or there has to be a
> >  way for me to make that function available. The latter would be
> >  preferable. =)
> 
> Well, the method is portable :), it's just that freetype isn't used by
> default on Windows. But I concur that documentation should state that
> this method is only available on freetype builds which isn't default
> on Windows, and not MacOSX either I think.

Almost right, freetypeFace is limited to X11 and QWS systems as those
are the ones where Qt uses FreeType to render fonts. On Windows it
naturally uses the native API for rendering fonts (I have 0 idea about
MacOSX but the qfont.h header indicates it uses some kind of id).

So Stephan you're only options are:

a) hack the qt sources to build freetype support on win32 and ship your
own Qt builds

b) use the native windows API.

Andreas

-- 
 [ signature omitted ] 

Message 10 in thread

On Sunday 16 March 2008 07:06:15 am Andreas Pakulat wrote:
> So Stephan you're only options are:
>
> a) hack the qt sources to build freetype support on win32 and ship your
> own Qt builds
>
> b) use the native windows API.

You could ask the trolls to add a method to get a QPainterPath of the 
(hinted?) outline.

Brad

--
 [ signature omitted ] 

Message 11 in thread

On Sun, 2008-03-16 at 11:56 +1100, Brad Hards wrote:
> On Sunday 16 March 2008 07:06:15 am Andreas Pakulat wrote:
> > So Stephan you're only options are:
> >
> > a) hack the qt sources to build freetype support on win32 and ship your
> > own Qt builds
> >
> > b) use the native windows API.
> 
> You could ask the trolls to add a method to get a QPainterPath of the 
> (hinted?) outline.

Now that would just be absolutely sexy! Matter of fact, I'd absolutely
love to see that in Qt. The outline is the very reason why I need access
to the freetype face. :)

Trolls, consider yourself asked. =P

Stephan




--
 [ signature omitted ] 

Message 12 in thread

On Sunday 16 March 2008 01:45:38 Stephan Rose wrote:
> Now that would just be absolutely sexy! Matter of fact, I'd absolutely
> love to see that in Qt. The outline is the very reason why I need access
> to the freetype face. :)
Does this not help?

http://doc.trolltech.com/4.3/qpainterpath.html#addText

Sean

--
 [ signature omitted ] 

Message 13 in thread

Hi,

> Trolls, consider yourself asked. =P

Unfortunately it doesn't work that way. You have to ask support or send a 
feature request here:
	http://trolltech.com/bugreport-form

Product management and developers don't necessarily monitor all messages on 
this mailing list.

--
 [ signature omitted ] 

Message 14 in thread

Stephan Rose wrote:

> I recently tried to compile one of my projects under windows and got
> compilation errors when trying to use QFont::freetypeFace().
> 
> Seems that it is not available under windows, the documentation however
> does not state so.
> 
> Works fine under linux.

Sure, because it's part of the underlying font handling infrastructure on
Linux, but not on Windows.

> I absolutely cannot live without that function as I need it to gain
> access to the outline data of the fonts. Or, I need an alternate way to
> do it under windows (though that'd be my least preferred method, I'd
> rather stick to one solution fits all).
> 
> Is there maybe a flag I can recompile Qt with under windows to gain that
> function or anything else I can do?

Have you considered adding text to painter paths and getting information
that way, or doesn't that provide the kind of information you need?

David
-- 
 [ signature omitted ]