Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Ticket #35 (closed defect: fixed)

Opened 16 years ago

Last modified 16 years ago

pango-Cairo isn't wrapped at all. Pango can't be used for rendering.

Reported by: kaarna Assigned to: Mike Wey
Priority: major Milestone: Pre-release 9
Component: gtkd - classes Version: TRUNK
Keywords: pangocairo Cc:

Description

Currently we can't use Pango for just about anything. Yet, it's almost fully wrapped and sitting there looking like it's working. But I'm quite sure that there is only one .html of functions that are left to wrap, so that we can get better font rendering with Pango and Cairo.

In APILookupPango.txt there's these mysterious lines:

#file: pango-Cairo-Rendering.html
#struct: PangoCairoFontMap
#class: PgCairoFontMap
#prefix: pango_cairo_font_map_
#strictPrefix: Yes
#outFile: PgCairoFontMap

#class: PgCairo
#prefix: pango_cairo_
#noprefix: pango_cairo_font_map_
#outFile: PgCairo

It looks like someone has started to wrap it at some point. I think it's propably easy to add the missing lines there and wrap those things inside a pango.PgCairo?.d file. It seems that it has got many classes that are needed, and I'm not sure if that's possible with gtkDwrap. (If it isn't possible yet, then the PgCairoFontMap? and PgCairoFont? classes should just be ignored for the time being.) All of the functions in class PgCairo? are going to be static.

All the Cairo text examples on the net tell us that we mustn't use the cairo.Context.showText() method, because that's the "toy API" for rendering text. Yet, all those same examples use it anyway. I was able to find one C example of how to use Pango and Cairo together. Here's an approximate D version that might actually work, after the wrap has been made:

import cairo.Context;
import pango.PgLayout;
import pango.PgFontDescription;
import pango.PgCairo;

void pangoCairoText( Context cr, char[] set_text )
{

	PgLayout pLayout = PgCairo.createLayout(cr);
	PgFontDescription pDesc = new PgFontDescription();
	
	pDesc.setAbsoluteSize(120.0);
	pDesc.setFamily("DejaVu LGC Sans Mono");
	pDesc.setWeight( PangoWeight.SEMIBOLD );//NORMAL
	pDesc.setStyle( PangoStyle.NORMAL );
	pLayout.setFontDescription( pDesc );
	
	pLayout.setText( set_text );
	
	//cr.setOperator( cairo_operator_t.OVER );
	cr.setLineWidth( 0.0025f );
	cr.moveTo( 0.1f, 0.5f );
	
	PgCairo.layoutPath( cr, pLayout );
	
	cr.setSourceRgba( 0.0f, 0.0f, 0.0f, 1.0f );
	cr.fill();
	
}

So, please. Somebody wrap PangoCairo?!

Change History

06/27/08 19:20:52 changed by Mike Wey

  • owner changed from JJR to Mike Wey.
  • status changed from new to assigned.
  • milestone set to Pre-release 9.

I'll probably will try to wrap this saturday or sunday.

06/28/08 13:58:56 changed by Mike Wey

  • status changed from assigned to closed.
  • resolution set to fixed.

Wraped in svn r508.