The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Pango

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Pango Posted: May 3, 2007 9:07 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Pango
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

A sister project to the Cairo project is the Pango project. Among other things, the documentation states...

"...The integration of Pango with Cairo (http://cairographics.org) provides a complete solution with high quality text handling and graphics rendering...."

I used Cairo to render my presentation on Cairo completely. But it didn't take long before I got frustrated with doing all the text drawing with the low level text APIs Cairo provides. So on a lark, I thought I'd see how hard it would be to bind at least enough of Pango to make text rendering for my slides easier. It was a gamble that paid off well. It took about 1.5 hours to do a mapping that I was able to use for everything I needed in the slides. It has been published as Pango package in the Open Repository. There's much more that could and should be wrapped. With the Cairo binding being capable of quite a bit and basically complete, I'll be moving my efforts there to round out the Pango binding.

The part mapped so far is the high level "layout" API. It shows up as a Smalltalk object called Layout (think "Text Layout"). Semantically, Pango Layout's fill the same role as Smalltalk-80's Blue Book Paragraph object (a better name for what eventually was renamed ComposedText. You create one by sending a newLayout message to a Cairo context (cr). Once you have aLayout, you use text: to set it's string. You can use an expression like alignment: Alignment center. And fontDesciptionString: to set the font and size. There's a reference in the docs that shows how flexible the fontDescrptionString can be. I haven't mapped Smalltalk Text attributes directly to Pango's text atribute structures yet, but you can use the markup: API to set the text and markup simultaneously (see this page for description of supported markup). Once you have one built, you can use pixelExtent, pixelHeight, and pixelWidth to help figure out where to put them. Use a Cairo moveTo: to position where the top-left of the layout goes. And finally a showOn: sent to the Layout with the cr as it's argument to render it.

One of the highlights of the Smalltalk Solutions conference, was that it was held in conjunction with LinuxWorld, in the town (Toronto) where the chief Pango maintainer (Behdad Esfahbod) lives. And I got to spend about 45 minutes with him. Not nearly enough. My thanks to him for spending some time with me. It was invaluable. He pointed out an example of how to do text layout along a baseline path. Got me excited about the upcoming "user font" API (a mechanism where the user can define hooks for programatically drawn font glyphs). And gave me some insight about the best parts of Pango to bind. Thanks Behdad!

Read: Pango

Topic: Widgetry 0.6 Previous Topic   Next Topic Topic: The $100 laptop (plus $75)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use