[libGD] #210 [Task opened] gdImageStringFT(..., "Times-12",...) fails with gdFTUseFontConfig(1) for non-TTF

[email protected] Sun, 5 Jul 2009 23:40:10 +0200 (CEST)
Newsgroups php.gd.bugs
Message-ID <[email protected]>
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - Michael McTernan (MichaelMcTernan) 

Attached to Project - libGD
Summary - gdImageStringFT(..., "Times-12",...) fails with gdFTUseFontConfig(1) for non-TTF
Task Type - Bug Report
Category - General
Status - Unconfirmed
Assigned To - 
Operating System - Windows
Severity - Medium
Priority - Normal
Reported Version - 2.0.35
Due in Version - Undecided
Due Date - Undecided
Details - Hi,

I call gdFTUseFontConfig(1) and then gdImageStringFT() with a font name such as "Times-12" and the point size as 12.  I consistently get the error message "Could not set character size" back.

Tracking this into the lib, FT_Set_Char_Size is failing with FT_Err_Invalid_Pixel_Size.  Following it further, it looks like fontconfig picks something like /usr/share/fonts/75dpi/timR12.pcf.gz, which seems reasonable.  The problem is that freetype is then called by GD as follows:

FT_Set_Char_Size (face, 0, (FT_F26Dot6)(ptsize*64), METRIC_RES, METRIC_RES)

METRIC_RES = 300, and the FreeType PCF driver then does the following calculation in PCF_Size_Request(): FT_REQUEST_HEIGHT:

height = (req)->height * (req)->vertResolution + 36 ) / 72;

So the request to gdImageStringFT() ends up requiring the font to be (12 * 300 + 36) / 72 = 50 points high to give the requested 12 points at 300dpi.

At this point, since a PCF for 12-point was selected, PCF_Size_Request() fails since the font face doesn't match the required dpi height.

I think that gdImageStringFTEx() needs changing such that the passed width is compensated for the 300dpi requested, or the 300 is changed to 72 (by setting 0 and 0).  Then this function call can pass and rendering can work without requiring TTFs in every case.

More information can be found at the following URL:
http://bugs.libgd.org/?do=details&task_id=210

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.