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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
|
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-pangocontext">
<refnamediv>
<refname>pango.Context</refname>
<refpurpose>stores global information used to control
rendering.</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>pango.Context</classname></ooclass>
<ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-pangocontext">pango.Context</link></methodname>
<methodparam></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-pangocontext--get-font-map">get_font_map</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-pangocontext--set-font-map">set_font_map</link></methodname>
<methodparam><parameter role="keyword">font_map</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--list-families">list_families</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--load-font">load_font</link></methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--load-fontset">load_fontset</link></methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--get-metrics">get_metrics</link></methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--set-font-description">set_font_description</link></methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--get-font-description">get_font_description</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--get-language">get_language</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--set-language">set_language</link></methodname>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--set-base-dir">set_base_dir</link></methodname>
<methodparam><parameter
role="keyword">direction</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-pangocontext--get-base-dir">get_base_dir</link></methodname>
<methodparam></methodparam> </methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-pangocontext">pango.Context</link>
</synopsis>
</refsect1>
<refsect1>
<title>Description</title>
<para>A <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
object contains global information used to control the rendering
process. The information accessible using the <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
methods includes:</para>
<itemizedlist>
<listitem>
<simpara>the default <link linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link></simpara>
</listitem>
<listitem>
<simpara>the default <link linkend="class-pangolanguage"><classname>pango.Language</classname></link></simpara>
</listitem>
<listitem>
<simpara>the base direction of the text</simpara>
</listitem>
</itemizedlist>
<para>A <link
linkend="class-pangocontext"><classname>pango.Context</classname></link> can
be created with the <link
linkend="method-gtkwidget--create-pango-context"><methodname>gtk.Widget.create_pango_context</methodname>()</link>
method. The <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
associated with a <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> is
retrieved using the <link
linkend="method-gtkwidget--get-pango-context"><methodname>gtk.Widget.get_pango_context</methodname>()</link>)
method.</para>
</refsect1>
<refsect1 id="constructor-pangocontext">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>pango.Context</methodname>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new <link linkend="class-pangocontext"><classname>pango.Context</classname></link>
<emphasis>without</emphasis> an associated font map</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>Constructor is available in PyGTK 2.16 and above.</para>
</note>
<para>Creates a new PangoContext initialized to default values.</para>
<para>This constructor is not particularly useful as it should always be followed by a
call to <link linkend="method-pangocontext--set-font-map">set_font_map</link>
method. Method <link linkend="method-pangofontmap--create-context">pango.FontMap.create_context</link>
does these two steps together and hence users are recommended to use that.</para>
<para>If you are using Pango as part of a higher-level system, that system may have
it's own way of create a <link linkend="class-pangocontext">pango.Context</link>.
For instance, the GTK+ toolkit has, among others,
<link linkend="function-gdk--pango-context-get-for-screen">gtk.gdk.pango_context_get_for_screen</link>
and <link linkend="method-gtkwidget--get-pango-context">gtk.Widget.get_pango_context</link>.
Use those instead.
</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-pangocontext--get-font-map">
<title>pango.Context.get_font_map</title>
<programlisting><methodsynopsis language="python">
<methodname>get_font_map</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the font map for the
<link linkend="class-pangocontext"><classname>pango.Context</classname></link>.</simpara></listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2 id="method-pangocontext--set-font-map">
<title>pango.Context.get_font_map</title>
<programlisting><methodsynopsis language="python">
<methodname>set_font_map</methodname>
<methodparam><parameter role="keyword">font_map</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">font_map</parameter> :</term>
<listitem><simpara>the <link linkend="class-pangofontmap"><classname>pango.FontMap</classname>
to set</link> object</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.16 and above.</para>
</note>
<para>Sets the font map to be searched when fonts are looked-up in this
context. This is only for internal use by Pango backends,
a <link linkend="class-pangocontext"><classname>pango.Context</classname></link>
obtained via one of the recommended methods should already have a suitable font
map.</para>
</refsect2>
<refsect2 id="method-pangocontext--list-families">
<title>pango.Context.list_families</title>
<programlisting><methodsynopsis language="python">
<methodname>list_families</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a tuple containing a set of <link
linkend="class-pangofontfamily"><classname>pango.FontFamily</classname></link>
objects.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>list_families</methodname>() method returns a
tuple containing the list of all the <link
linkend="class-pangofontfamily"><classname>pango.FontFamily</classname></link>
objects for a context.</para>
</refsect2>
<refsect2 id="method-pangocontext--load-font">
<title>pango.Context.load_font</title>
<programlisting><methodsynopsis language="python">
<methodname>load_font</methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">desc</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
describing the font to load</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the <link
linkend="class-pangofont"><classname>pango.Font</classname></link> loaded,
or <literal>None</literal> if no font matched.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>load_font</methodname>() method loads and
returns the <link
linkend="class-pangofont"><classname>pango.Font</classname></link> from one
of the fontmaps in the context that is the closest match for the <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
specified by <parameter>desc</parameter>.</para>
</refsect2>
<refsect2 id="method-pangocontext--load-fontset">
<title>pango.Context.load_fontset</title>
<programlisting><methodsynopsis language="python">
<methodname>load_fontset</methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">desc</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
describing the fonts to load</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">language</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
the fonts will be used for</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the <link
linkend="class-pangofontset"><classname>pango.FontSet</classname></link>, or
<literal>None</literal> if no font matched.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>load_fontset</methodname>() method loads and
returns a set of fonts (in a <link
linkend="class-pangofontset"><classname>pango.FontSet</classname></link>)
from the context that can be used to render a font matching the <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
specified by <parameter>desc</parameter> with the <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
specified by <parameter>language</parameter>.</para>
</refsect2>
<refsect2 id="method-pangocontext--get-metrics">
<title>pango.Context.get_metrics</title>
<programlisting><methodsynopsis language="python">
<methodname>get_metrics</methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">desc</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
object</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">language</parameter> :</term>
<listitem><simpara>the <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
that determines the script to get the metrics for, or
<literal>None</literal> to get the metrics for the entire
font.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a <link
linkend="class-pangofontmetrics"><classname>pango.FontMetrics</classname></link>
object.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_metrics</methodname>() method returns the
overall metric information for the font described by the <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
specified by <parameter>desc</parameter>. Since the metrics may be
substantially different for different scripts, a <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
(specified by <parameter>language</parameter>) can be provided to indicate
that the metrics should correspond to the script(s) used by that language.
If the value of <parameter>language</parameter> is <literal>None</literal>,
the returned <link
linkend="class-pangofontmetrics"><classname>pango.FontMetrics</classname></link>
covers the entire font.</para>
<para>The family name in the <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
may be a comma separated list of families. If characters from multiple of
these families would be used to render the string, then the returned fonts
would be a composite of the metrics for the fonts loaded for the individual
families.</para>
</refsect2>
<refsect2 id="method-pangocontext--set-font-description">
<title>pango.Context.set_font_description</title>
<programlisting><methodsynopsis language="python">
<methodname>set_font_description</methodname>
<methodparam><parameter
role="keyword">desc</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">desc</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
object</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_font_description</methodname>() method sets
the default <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
(specified by <parameter>desc</parameter>) for the context.</para>
</refsect2>
<refsect2 id="method-pangocontext--get-font-description">
<title>pango.Context.get_font_description</title>
<programlisting><methodsynopsis language="python">
<methodname>get_font_description</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the default font description of the
context.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_font_description</methodname>() method
returns the default <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>
for the context.</para>
</refsect2>
<refsect2 id="method-pangocontext--get-language">
<title>pango.Context.get_language</title>
<programlisting><methodsynopsis language="python">
<methodname>get_language</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the global <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_language</methodname>() method returns the
global <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
for the context.</para>
</refsect2>
<refsect2 id="method-pangocontext--set-language">
<title>pango.Context.set_language</title>
<programlisting><methodsynopsis language="python">
<methodname>set_language</methodname>
<methodparam><parameter
role="keyword">language</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">language</parameter> :</term>
<listitem><simpara>a <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_language</methodname>() method sets the
global <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
for the context to the value specified by
<parameter>language</parameter>.</para>
</refsect2>
<refsect2 id="method-pangocontext--set-base-dir">
<title>pango.Context.set_base_dir</title>
<programlisting><methodsynopsis language="python">
<methodname>set_base_dir</methodname>
<methodparam><parameter
role="keyword">direction</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">direction</parameter> :</term>
<listitem><simpara>the new base direction</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_base_dir</methodname>() method sets the base
text direction for the context to the value specified by
<parameter>direction</parameter>. The value of
<parameter>direction</parameter> must be one of:</para>
<variablelist>
<varlistentry>
<term><literal>pango.DIRECTION_LTR</literal></term>
<listitem>
<simpara>The text is written left-to-right</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>pango.DIRECTION_RTL</literal></term>
<listitem>
<simpara>The text is written right-to-left</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>pango.DIRECTION_TTB_LTR</literal></term>
<listitem>
<simpara>The text is written vertically top-to-bottom, with the
rows ordered from left to right.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>pango.DIRECTION_TTB_RTL</literal></term>
<listitem>
<simpara>The text is written vertically top-to-bottom, with the
rows ordered from right to left.</simpara>
</listitem>
</varlistentry>
</variablelist>
<para></para>
</refsect2>
<refsect2 id="method-pangocontext--get-base-dir">
<title>pango.Context.get_base_dir</title>
<programlisting><methodsynopsis language="python">
<methodname>get_base_dir</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the base direction for the
context.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_base_dir</methodname>() method returns the
base text direction for the context. See the <link
linkend="method-pangocontext--set-base-dir"><methodname>set_base_dir</methodname>()</link>
method for more information.</para>
</refsect2>
</refsect1>
</refentry>
|