Re: Embedded font problems

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
On 03/13/2017 05:09 AM, jsmith4332--- via reportlab-users wrote:
> Hello,
>
> Does anyone have troubleshooting tips for figuring out why an embedded
> TTF font does not work in reportlab (just shows rectangles)? I'm trying
> to use https://grandzebu.net/informatique/codbar/code128.ttf (yes, I
> would like to use a barcode font instead of the built in barcode
> generator due to quality issues when printing on a low DPI printer)
>
> The relevant code is:
>
> stylesheet = StyleSheet1()
>
> stylesheet.add(
>     ParagraphStyle(
>         name='Normal',
>         fontName='Helvetica',
>         fontSize=12,
>         leading=16,
>         spaceBefore=8,
>         spaceAfter=8,
>     )
> )
>
> stylesheet.add(
>     ParagraphStyle(
>         name='Barcode',
>         fontName='128',
>         fontSize=12,
>     )
> )
>
>
> pdfmetrics.registerFont(TTFont('128', os.path.join(os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))), 'code128.ttf')))
>
> # story definition omitted...
>
> story.append(Paragraph('helloworld'), stylesheet['Barcode']))
>
>
> Unfortunately, the resulting PDF has a bunch of squares instead of using the barcode font. When I switch to a different ttf, things seem to work. Furthermore, the code128 font referenced above seems to work fine in applications like Microsoft Word/Excel.
>
>
> Any ideas?

Look at this page:

http://grandzebu.net/informatique/codbar-en/code128.htm

There seems to be a translation process between the original string and 
the string the font needs to see. The example being:

'3745 KV 75' --> 'ÒEMÍ KV 756Ó'

There are some programs at the bottom that do that. I tried the Python 
one, but it does not work. I did manage to get the Postgres plpgsql 
function to work.

>
>
> Thanks!
>
>
>
> _______________________________________________
> reportlab-users mailing list
> [email protected]
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>


-- 
Adrian Klaver
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.