📄 vertical.xml
字号:
<refentry id="pango-Vertical-Text"><refmeta><refentrytitle role="top_of_page" id="pango-Vertical-Text.top_of_page">Vertical Text</refentrytitle><manvolnum>3</manvolnum><refmiscinfo>PANGO Library</refmiscinfo></refmeta><refnamediv><refname>Vertical Text</refname><refpurpose>Laying text out in vertical directions</refpurpose><!--[<xref linkend="desc" endterm="desc.title"/>]--></refnamediv><refsynopsisdiv id="pango-Vertical-Text.synopsis" role="synopsis"><title role="synopsis.title">Synopsis</title><synopsis>enum <link linkend="PangoGravity">PangoGravity</link>;#define <link linkend="PANGO-TYPE-GRAVITY:CAPS">PANGO_TYPE_GRAVITY</link>enum <link linkend="PangoGravityHint">PangoGravityHint</link>;#define <link linkend="PANGO-TYPE-GRAVITY-HINT:CAPS">PANGO_TYPE_GRAVITY_HINT</link>#define <link linkend="PANGO-GRAVITY-IS-VERTICAL:CAPS">PANGO_GRAVITY_IS_VERTICAL</link> (gravity)<link linkend="PangoGravity">PangoGravity</link> <link linkend="pango-gravity-get-for-matrix">pango_gravity_get_for_matrix</link> (const <link linkend="PangoMatrix">PangoMatrix</link> *matrix);<link linkend="PangoGravity">PangoGravity</link> <link linkend="pango-gravity-get-for-script">pango_gravity_get_for_script</link> (<link linkend="PangoScript">PangoScript</link> script, <link linkend="PangoGravity">PangoGravity</link> base_gravity, <link linkend="PangoGravityHint">PangoGravityHint</link> hint);<link linkend="double">double</link> <link linkend="pango-gravity-to-rotation">pango_gravity_to_rotation</link> (<link linkend="PangoGravity">PangoGravity</link> gravity);</synopsis></refsynopsisdiv><refsect1 id="pango-Vertical-Text.description" role="desc"><title role="desc.title">Description</title><para>Since 1.16, Pango is able to correctly lay vertical text out. In fact, it canset layouts of mixed vertical and non-vertical text. This section describesthe types used for setting vertical text parameters.</para><para>The way this is implemented is through the concept of<firstterm>gravity</firstterm>. Gravity of normal Latin text is south. Agravity value of east means that glyphs will be rotated ninety degreescounterclockwise. So, to render vertical text one needs to set the gravityand rotate the layout using the matrix machinery already in place. This hasthe huge advantage that most algorithms working on a <link linkend="PangoLayout"><type>PangoLayout</type></link> do not needany change as the assumption that lines run in the X direction and stack inthe Y direction holds even for vertical text layouts.</para><para>Applications should only need to set base gravity on <link linkend="PangoContext"><type>PangoContext</type></link> in use, andlet Pango decide the gravity assigned to each run of text. This automaticallyhandles text with mixed scripts. A very common use is to set the context basegravity to auto using <link linkend="pango-context-set-base-gravity"><function>pango_context_set_base_gravity()</function></link>and rotate the layout normally. Pango will make sure thatAsian languages take the right form, while other scripts are rotated normally.</para><para>The correct way to set gravity on a layout is to set it on the contextassociated with it using <link linkend="pango-context-set-base-gravity"><function>pango_context_set_base_gravity()</function></link>. The contextof a layout can be accessed using <link linkend="pango-layout-get-context"><function>pango_layout_get_context()</function></link>. The currentlyset base gravity of the context can be accessed using<link linkend="pango-context-get-base-gravity"><function>pango_context_get_base_gravity()</function></link> and the <firstterm>resolved</firstterm>gravity of it using <link linkend="pango-context-get-gravity"><function>pango_context_get_gravity()</function></link>. The resolved gravity isthe same as the base gravity for the most part, except that if the basegravity is set to <link linkend="PANGO-GRAVITY-AUTO:CAPS"><literal>PANGO_GRAVITY_AUTO</literal></link>, the resolved gravity will dependon the current matrix set on context, and is derived using<link linkend="pango-gravity-get-for-matrix"><function>pango_gravity_get_for_matrix()</function></link>.</para><para>The next thing an application may want to set on the context is the<firstterm>gravity hint</firstterm>. A <link linkend="PangoGravityHint"><type>PangoGravityHint</type></link> instructs howdifferent scripts should react to the set base gravity.</para><para>Font descriptions have a gravity property too, that can be set using<link linkend="pango-font-description-set-gravity"><function>pango_font_description_set_gravity()</function></link> and accessed using<link linkend="pango-font-description-get-gravity"><function>pango_font_description_get_gravity()</function></link>. However, those are rarely usefulfrom application code and are mainly used by <link linkend="PangoLayout"><type>PangoLayout</type></link> internally.</para><para>Last but not least, one can create <link linkend="PangoAttribute"><type>PangoAttribute</type></link><!---->s for gravityand gravity hint using <link linkend="pango-attr-gravity-new"><function>pango_attr_gravity_new()</function></link> and<link linkend="pango-attr-gravity-hint-new"><function>pango_attr_gravity_hint_new()</function></link>.</para></refsect1><refsect1 id="pango-Vertical-Text.details" role="details"><title role="details.title">Details</title><refsect2 id="PangoGravity" role="enum" condition="since:1.16"><title>enum PangoGravity</title><indexterm zone="PangoGravity" role="1.16"><primary>PangoGravity</primary></indexterm><programlisting>typedef enum { PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_EAST, PANGO_GRAVITY_NORTH, PANGO_GRAVITY_WEST, PANGO_GRAVITY_AUTO} PangoGravity;</programlisting><para>The <link linkend="PangoGravity"><type>PangoGravity</type></link> type represents the orientation of glyphs in a segmentof text. This is useful when rendering vertical text layouts. Inthose situations, the layout is rotated using a non-identity PangoMatrix,and then glyph orientation is controlled using <link linkend="PangoGravity"><type>PangoGravity</type></link>.Not every value in this enumeration makes sense for every usage of<link linkend="PangoGravity"><type>PangoGravity</type></link>; for example, <link linkend="PANGO-GRAVITY-AUTO:CAPS"><literal>PANGO_GRAVITY_AUTO</literal></link> only can be passed to<link linkend="pango-context-set-base-gravity"><function>pango_context_set_base_gravity()</function></link> and can only be returned by<link linkend="pango-context-get-base-gravity"><function>pango_context_get_base_gravity()</function></link>.</para><para>See also: <link linkend="PangoGravityHint"><type>PangoGravityHint</type></link></para><para></para><variablelist role="enum"><varlistentry id="PANGO-GRAVITY-SOUTH:CAPS" role="constant"><term><literal>PANGO_GRAVITY_SOUTH</literal></term><listitem><simpara> Glyphs stand upright (default)</simpara></listitem></varlistentry><varlistentry id="PANGO-GRAVITY-EAST:CAPS" role="constant"><term><literal>PANGO_GRAVITY_EAST</literal></term><listitem><simpara> Glyphs are rotated 90 degrees clockwise</simpara></listitem></varlistentry><varlistentry id="PANGO-GRAVITY-NORTH:CAPS" role="constant"><term><literal>PANGO_GRAVITY_NORTH</literal></term><listitem><simpara> Glyphs are upside-down</simpara></listitem></varlistentry><varlistentry id="PANGO-GRAVITY-WEST:CAPS" role="constant"><term><literal>PANGO_GRAVITY_WEST</literal></term><listitem><simpara> Glyphs are rotated 90 degrees counter-clockwise</simpara></listitem></varlistentry><varlistentry id="PANGO-GRAVITY-AUTO:CAPS" role="constant"><term><literal>PANGO_GRAVITY_AUTO</literal></term><listitem><simpara> Gravity is resolved from the context matrix</simpara></listitem></varlistentry></variablelist><para role="since">Since 1.16</para></refsect2><refsect2 id="PANGO-TYPE-GRAVITY:CAPS" role="macro"><title>PANGO_TYPE_GRAVITY</title><indexterm zone="PANGO-TYPE-GRAVITY:CAPS"><primary>PANGO_TYPE_GRAVITY</primary></indexterm><programlisting>#define PANGO_TYPE_GRAVITY (pango_gravity_get_type())</programlisting><para>The <link linkend="GObject"><type>GObject</type></link> type for <link linkend="PangoGravity"><type>PangoGravity</type></link>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -