1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
<refentry id="libgnomeprint-Pango-Integration">
<refmeta>
<refentrytitle role="top_of_page" id="libgnomeprint-Pango-Integration.top_of_page">Pango Integration</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>LIBGNOMEPRINT Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Pango Integration</refname>
<refpurpose>Using gnome-print with Pango</refpurpose>
</refnamediv>
<refsynopsisdiv id="libgnomeprint-Pango-Integration.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>
<synopsis><link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> * <link linkend="gnome-print-pango-font-map-new">gnome_print_pango_font_map_new</link> (void);
<link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> * <link linkend="gnome-print-pango-get-default-font-map">gnome_print_pango_get_default_font_map</link>
(void);
<link linkend="PangoContext"><returnvalue>PangoContext</returnvalue></link> * <link linkend="gnome-print-pango-create-context">gnome_print_pango_create_context</link> (<link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> *fontmap);
<link linkend="void"><returnvalue>void</returnvalue></link> <link linkend="gnome-print-pango-update-context">gnome_print_pango_update_context</link> (<link linkend="PangoContext"><returnvalue>PangoContext</returnvalue></link> *context,
<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc);
<link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> * <link linkend="gnome-print-pango-create-layout">gnome_print_pango_create_layout</link> (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc);
<link linkend="void"><returnvalue>void</returnvalue></link> <link linkend="gnome-print-pango-glyph-string">gnome_print_pango_glyph_string</link> (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoFont"><returnvalue>PangoFont</returnvalue></link> *font,
<link linkend="PangoGlyphString"><returnvalue>PangoGlyphString</returnvalue></link> *glyphs);
<link linkend="void"><returnvalue>void</returnvalue></link> <link linkend="gnome-print-pango-layout-line">gnome_print_pango_layout_line</link> (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayoutLine"><returnvalue>PangoLayoutLine</returnvalue></link> *line);
<link linkend="void"><returnvalue>void</returnvalue></link> <link linkend="gnome-print-pango-layout">gnome_print_pango_layout</link> (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> *layout);
<link linkend="void"><returnvalue>void</returnvalue></link> <link linkend="gnome-print-pango-layout-print">gnome_print_pango_layout_print</link> (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> *pl);
</synopsis>
</refsynopsisdiv>
<refsect1 id="libgnomeprint-Pango-Integration.description" role="desc">
<title role="desc.title">Description</title>
<para>
The functions in this section allow you to use gnome-print to
draw text using the sophisticated layout and internationalization
capabilities of the Pango library. In general, for a GNOME
application, these are the text APIs you should be using.
</para>
<para>
There are a number of different types of objects involved in
using <link linkend="Pango"><type>Pango</type></link> with gnome-print.
</para>
<variablelist>
<varlistentry>
<term><link linkend="PangoFontMap">PangoFontMap</link></term>
<listitem>
<para>
A <link linkend="PangoFontMap">PangoFontMap</link> contains
the information necessary to resolve abstract font names
to particular fonts on the system. A font map appropriate
for use with gnome-print is created using
<link
linkend="gnome-print-pango-font-map-new"><function><link linkend="gnome-print-pango-font-map-new"><function>gnome_print_pango_font_map_new()</function></link></function></link>.
Normally instead of creating a new font map, you can just
use the global default font map returned by
<link
linkend="gnome-print-pango-get-default-font-map"><function><link linkend="gnome-print-pango-get-default-font-map"><function>gnome_print_pango_get_default_font_map()</function></link></function></link>.
The only exception to this is if you need to use lower level
Pango APIs to customize how the font name to font lookup is
done, since modifying the global default font map isn't allowed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link linkend="PangoContext">PangoContext</link></term>
<listitem>
<para>
Information about doing layout for a particular output device
with a particular set of options is
encapsulated into a <link
linkend="PangoContext">PangoContext</link>. Contexts for
gnome-print are created using
<link
linkend="gnome-print-pango-create-context"><function><link linkend="gnome-print-pango-create-context"><function>gnome_print_pango_create_context()</function></link></function></link>
</para>
<para>
A Pango context created in this way is not specific to a
particular <link
linkend="GnomePrintContext">GnomePrintContext</link> but
before using a Pango context to do layout for a gnome-print
context, it's necessary to call
<link
linkend="gnome-print-pango-update-context"><function><link linkend="gnome-print-pango-update-context"><function>gnome_print_pango_update_context()</function></link></function></link>.
This function also needs to be called if when the current
transformation matrix changes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link linkend="PangoLayout">PangoLayout</link></term>
<listitem>
<para>
A <link linkend="PangoLayout">PangoLayout</link> holds one or more paragraphs of text
and encapsulates all the necessary logic needed to
line wrap and lay out the text. Once you have a
<link linkend="PangoContext"><type>PangoContext</type></link>, you can create a layout using
<link linkend="pango_layout_new"><function><link linkend="pango-layout-new"><function>pango_layout_new()</function></link></function></link>.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
In the normal case, a <link linkend="PangoFontMap">PangoFontMap</link>
created directly with <link
linkend="gnome-print-pango-create-layout"><function><link linkend="gnome-print-pango-create-layout"><function>gnome_print_pango_create_layout()</function></link></function></link>
is all that is needed. A simple example that uses Pango to draw a string centered
in a page looks like:
</para>
<informalexample><programlisting>
static void
draw_hello_world (GnomePrintContext *gpc,
double page_width,
double page_height)
{
PangoLayout *layout = gnome_print_pango_create_layout (gpc);
int pango_width, pango_height;
double width, height;
pango_layout_set_text (layout, "Hello World");
pango_layout_get_size (layout, &pango_width, &pango_height);
width = (double) pango_width / PANGO_SCALE;
height = (double) pango_height / PANGO_SCALE;
gnome_print_moveto (gpc,
(page_width - width) / 2,
(page_width - height)/ 2);
gnome_print_pango_layout (gpc, layout);
g_object_unref (layout);
}
</programlisting></informalexample>
<para>
Note the need to convert from Pango units to the floating point
units that gnome-print uses by dividing by
<link linkend="PANGO-SCALE-CAPS"><literal>PANGO_SCALE</literal></link>.
</para>
</refsect1>
<refsect1 id="libgnomeprint-Pango-Integration.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="gnome-print-pango-font-map-new" role="function">
<title>gnome_print_pango_font_map_new ()</title>
<indexterm zone="gnome-print-pango-font-map-new"><primary>gnome_print_pango_font_map_new</primary></indexterm>
<programlisting><link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> * gnome_print_pango_font_map_new (void);</programlisting>
<para>
Creates a new <link linkend="PangoFontMap"><type>PangoFontMap</type></link> object suitable for use with
gnome-print. In most cases, you probably want to use
<link linkend="gnome-print-pango-get-default-font-map"><function>gnome_print_pango_get_default_font_map()</function></link> instead.</para>
<variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> a newly created <link linkend="PangoFontMap"><type>PangoFontMap</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-get-default-font-map" role="function">
<title>gnome_print_pango_get_default_font_map ()</title>
<indexterm zone="gnome-print-pango-get-default-font-map"><primary>gnome_print_pango_get_default_font_map</primary></indexterm>
<programlisting><link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> * gnome_print_pango_get_default_font_map
(void);</programlisting>
<para>
Gets a singleton <link linkend="PangoFontMap"><type>PangoFontMap</type></link> object suitable for
use with gnome-print.</para>
<variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the default <link linkend="PangoFontMap"><type>PangoFontMap</type></link> object for gnome-print. The
returned object is owned by gnome-print and should not be modified.
(If you need to set custom options, create a new font map with
<link linkend="gnome-print-pango-font-map-new"><function>gnome_print_pango_font_map_new()</function></link>.) The reference count is
<emphasis>not</emphasis> increased.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-create-context" role="function">
<title>gnome_print_pango_create_context ()</title>
<indexterm zone="gnome-print-pango-create-context"><primary>gnome_print_pango_create_context</primary></indexterm>
<programlisting><link linkend="PangoContext"><returnvalue>PangoContext</returnvalue></link> * gnome_print_pango_create_context (<link linkend="PangoFontMap"><returnvalue>PangoFontMap</returnvalue></link> *fontmap);</programlisting>
<para>
Creates a new <link linkend="PangoContext"><type>PangoContext</type></link> object for the specified fontmap.</para>
<variablelist role="params">
<varlistentry><term><parameter>fontmap</parameter> :</term>
<listitem><simpara> a <link linkend="PangoFontMap"><type>PangoFontMap</type></link> from <link linkend="gnome-print-pango-get-default-font-map"><function>gnome_print_pango_get_default_font_map()</function></link>
or <link linkend="gnome-print-pango-create-font-map"><function>gnome_print_pango_create_font_map()</function></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> a newly created <link linkend="PangoContext"><type>PangoContext</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-update-context" role="function">
<title>gnome_print_pango_update_context ()</title>
<indexterm zone="gnome-print-pango-update-context"><primary>gnome_print_pango_update_context</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link> gnome_print_pango_update_context (<link linkend="PangoContext"><returnvalue>PangoContext</returnvalue></link> *context,
<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc);</programlisting>
<para>
Update a context so that layout done with it reflects the
current state of <parameter>gpc</parameter>. In general, every time you use a
<link linkend="PangoContext"><type>PangoContext</type></link> with a different <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>, or
you change the transformation matrix of the <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
(other than pure translations) you should call this function.
You also need to call <link linkend="pango-layout-context-changed"><function>pango_layout_context_changed()</function></link> for any
<link linkend="PangoLayout"><type>PangoLayout</type></link> objects that exit for the <link linkend="PangoContext"><type>PangoContext</type></link>.
</para>
<para>
This function currently does nothing and that isn't expected
to change for gnome-print. The main benefit of calling it
is that your code will be properly prepared for conversion
to use with future rendering systems such as Cairo where
the corresponding operation will actually do something.</para>
<variablelist role="params">
<varlistentry><term><parameter>context</parameter> :</term>
<listitem><simpara> a <link linkend="PangoContext"><type>PangoContext</type></link> from <link linkend="gnome-print-pango-create-context"><function>gnome_print_pango_create_context()</function></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-create-layout" role="function">
<title>gnome_print_pango_create_layout ()</title>
<indexterm zone="gnome-print-pango-create-layout"><primary>gnome_print_pango_create_layout</primary></indexterm>
<programlisting><link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> * gnome_print_pango_create_layout (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc);</programlisting>
<para>
Convenience function that creates a new <link linkend="PangoContext"><type>PangoContext</type></link>, updates
it for rendering to <parameter>gpc</parameter>, and then creates a <link linkend="PangoLayout"><type>PangoLayout</type></link> for
that <link linkend="PangoContext"><type>PangoContext</type></link>. Generally this function suffices for
most usage of gnome-print with Pango and you don't need to
deal with the <link linkend="PangoContext"><type>PangoContext</type></link> directly.</para>
<variablelist role="params">
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara> the newly created <link linkend="PangoLayout"><type>PangoLayout</type></link>. Free with
<link linkend="g-object-unref"><function>g_object_unref()</function></link> when you are done with it.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-glyph-string" role="function">
<title>gnome_print_pango_glyph_string ()</title>
<indexterm zone="gnome-print-pango-glyph-string"><primary>gnome_print_pango_glyph_string</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link> gnome_print_pango_glyph_string (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoFont"><returnvalue>PangoFont</returnvalue></link> *font,
<link linkend="PangoGlyphString"><returnvalue>PangoGlyphString</returnvalue></link> *glyphs);</programlisting>
<para>
Draws the glyphs in <parameter>glyphs</parameter> into the specified <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>.
Positioning information in <parameter>glyphs</parameter> is transformed by the current
transformation matrix, the glyphs are drawn in the current color,
and the glyphs are positioned so that the left edge of the baseline
is at the current point.</para>
<variablelist role="params">
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>font</parameter> :</term>
<listitem><simpara> the <link linkend="PangoFont"><type>PangoFont</type></link> that the glyphs in <parameter>glyphs</parameter> are from
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>glyphs</parameter> :</term>
<listitem><simpara> a <link linkend="PangoGlyphString"><type>PangoGlyphString</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-layout-line" role="function">
<title>gnome_print_pango_layout_line ()</title>
<indexterm zone="gnome-print-pango-layout-line"><primary>gnome_print_pango_layout_line</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link> gnome_print_pango_layout_line (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayoutLine"><returnvalue>PangoLayoutLine</returnvalue></link> *line);</programlisting>
<para>
Draws the text in <parameter>line</parameter> into the specified <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>. The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the current point.</para>
<variablelist role="params">
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>line</parameter> :</term>
<listitem><simpara> a <link linkend="PangoLayoutLine"><type>PangoLayoutLine</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-layout" role="function">
<title>gnome_print_pango_layout ()</title>
<indexterm zone="gnome-print-pango-layout"><primary>gnome_print_pango_layout</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link> gnome_print_pango_layout (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> *layout);</programlisting>
<para>
Draws the text in <parameter>layout</parameter> into the specified <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>. The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the current point.</para>
<variablelist role="params">
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>layout</parameter> :</term>
<listitem><simpara> a <link linkend="PangoLayout"><type>PangoLayout</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gnome-print-pango-layout-print" role="function">
<title>gnome_print_pango_layout_print ()</title>
<indexterm zone="gnome-print-pango-layout-print"><primary>gnome_print_pango_layout_print</primary></indexterm>
<programlisting><link linkend="void"><returnvalue>void</returnvalue></link> gnome_print_pango_layout_print (<link linkend="GnomePrintContext"><returnvalue>GnomePrintContext</returnvalue></link> *gpc,
<link linkend="PangoLayout"><returnvalue>PangoLayout</returnvalue></link> *pl);</programlisting>
<para>
Draws the text in <parameter>pl</parameter> into the specified <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>. The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the point (0, 0). This function
is obsolete; use <link linkend="gnome-print-pango-layout"><function>gnome_print_pango_layout()</function></link> instead.</para>
<variablelist role="params">
<varlistentry><term><parameter>gpc</parameter> :</term>
<listitem><simpara> a <link linkend="GnomePrintContext"><type>GnomePrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pl</parameter> :</term>
<listitem><simpara> the <link linkend="PangoLayout"><type>PangoLayout</type></link> to print
</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>
</refentry>
|