[reportlab-users] Built-in versus embedded fonts

Glenn Linderman v+python at g.nevcal.com
Mon Jun 22 05:03:07 EDT 2015


On 6/22/2015 1:16 AM, Marius Gedminas wrote:
> On Sat, Jun 20, 2015 at 06:16:37PM -0700, Glenn Linderman wrote:
>> As an outgrowth of the "Helvetica" reference (and I've got working code to
>> avoid it now, but would like the Canvas parameter for initial_fontname in
>> time, thanks), I found some code that is using "Times-Roman" (also built in)
>> to determine which string is longer... The strings are _actually_ placed in
>> the document using "Times New Roman" (TTF)... but...
>>
>> 1) pdfmetrics.stringWidth doesn't seem to work for TTF fonts.
>> 2) I couldn't find an obvious way to obtain the information for TTF fonts.
>> 3) If kerning gets implemented, the stringWidth should reflect that.
>>
>> I vaguely recall implementing this "proxy for reality" late one night in a
>> coding frenzy... is there an easy way to obtain stringWidth for a TTF font?
> This works fine with all kinds of fonts:
>
>      canvas.stringWidth(text, font_name, font_size)

Thanks for the response, but it doesn't work with my TTFont ones, as far 
as I can tell... I get the same errors as reported in my last message, 
but with a slightly different call stack.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20150622/cde39658/attachment.html>


More information about the reportlab-users mailing list