1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = pango-Vertical-Text.html 27 * outPack = pango 28 * outFile = PgVertical 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = PgVertical 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - pango.PgMatrix 47 * structWrap: 48 * - PangoMatrix* -> PgMatrix 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module pango.PgVertical; 55 56 public import gtkc.pangotypes; 57 58 private import gtkc.pango; 59 private import glib.ConstructionException; 60 private import gobject.ObjectG; 61 62 private import pango.PgMatrix; 63 64 65 66 /** 67 * Since 1.16, Pango is able to correctly lay vertical text out. In fact, it can 68 * set layouts of mixed vertical and non-vertical text. This section describes 69 * the types used for setting vertical text parameters. 70 * 71 * The way this is implemented is through the concept of 72 * gravity. Gravity of normal Latin text is south. A 73 * gravity value of east means that glyphs will be rotated ninety degrees 74 * counterclockwise. So, to render vertical text one needs to set the gravity 75 * and rotate the layout using the matrix machinery already in place. This has 76 * the huge advantage that most algorithms working on a PangoLayout do not need 77 * any change as the assumption that lines run in the X direction and stack in 78 * the Y direction holds even for vertical text layouts. 79 * 80 * Applications should only need to set base gravity on PangoContext in use, and 81 * let Pango decide the gravity assigned to each run of text. This automatically 82 * handles text with mixed scripts. A very common use is to set the context base 83 * gravity to auto using pango_context_set_base_gravity() 84 * and rotate the layout normally. Pango will make sure that 85 * Asian languages take the right form, while other scripts are rotated normally. 86 * 87 * The correct way to set gravity on a layout is to set it on the context 88 * associated with it using pango_context_set_base_gravity(). The context 89 * of a layout can be accessed using pango_layout_get_context(). The currently 90 * set base gravity of the context can be accessed using 91 * pango_context_get_base_gravity() and the resolved 92 * gravity of it using pango_context_get_gravity(). The resolved gravity is 93 * the same as the base gravity for the most part, except that if the base 94 * gravity is set to PANGO_GRAVITY_AUTO, the resolved gravity will depend 95 * on the current matrix set on context, and is derived using 96 * pango_gravity_get_for_matrix(). 97 * 98 * The next thing an application may want to set on the context is the 99 * gravity hint. A PangoGravityHint instructs how 100 * different scripts should react to the set base gravity. 101 * 102 * Font descriptions have a gravity property too, that can be set using 103 * pango_font_description_set_gravity() and accessed using 104 * pango_font_description_get_gravity(). However, those are rarely useful 105 * from application code and are mainly used by PangoLayout internally. 106 * 107 * Last but not least, one can create PangoAttributes for gravity 108 * and gravity hint using pango_attr_gravity_new() and 109 * pango_attr_gravity_hint_new(). 110 */ 111 public class PgVertical 112 { 113 114 /** 115 */ 116 117 /** 118 * Finds the gravity that best matches the rotation component 119 * in a PangoMatrix. 120 * Since 1.16 121 * Params: 122 * matrix = a PangoMatrix 123 * Returns: the gravity of matrix, which will never be PANGO_GRAVITY_AUTO, or PANGO_GRAVITY_SOUTH if matrix is NULL 124 */ 125 public static PangoGravity gravityGetForMatrix(PgMatrix matrix) 126 { 127 // PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix); 128 return pango_gravity_get_for_matrix((matrix is null) ? null : matrix.getPgMatrixStruct()); 129 } 130 131 /** 132 * Based on the script, base gravity, and hint, returns actual gravity 133 * to use in laying out a single PangoItem. 134 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the 135 * preferred gravity of script. To get the preferred gravity of a script, 136 * pass PANGO_GRAVITY_AUTO and PANGO_GRAVITY_HINT_STRONG in. 137 * Since 1.16 138 * Params: 139 * script = PangoScript to query 140 * baseGravity = base gravity of the paragraph 141 * hint = orientation hint 142 * Returns: resolved gravity suitable to use for a run of text with script. 143 */ 144 public static PangoGravity gravityGetForScript(PangoScript script, PangoGravity baseGravity, PangoGravityHint hint) 145 { 146 // PangoGravity pango_gravity_get_for_script (PangoScript script, PangoGravity base_gravity, PangoGravityHint hint); 147 return pango_gravity_get_for_script(script, baseGravity, hint); 148 } 149 150 /** 151 * Based on the script, East Asian width, base gravity, and hint, 152 * returns actual gravity to use in laying out a single character 153 * or PangoItem. 154 * This function is similar to pango_gravity_get_for_script() except 155 * that this function makes a distinction between narrow/half-width and 156 * wide/full-width characters also. Wide/full-width characters always 157 * stand <emph>upright</emph>, that is, they always take the base gravity, 158 * whereas narrow/full-width characters are always rotated in vertical 159 * context. 160 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the 161 * preferred gravity of script. 162 * Since 1.26 163 * Params: 164 * script = PangoScript to query 165 * wide = TRUE for wide characters as returned by g_unichar_iswide() 166 * baseGravity = base gravity of the paragraph 167 * hint = orientation hint 168 * Returns: resolved gravity suitable to use for a run of text with script and wide. 169 */ 170 public static PangoGravity gravityGetForScriptAndWidth(PangoScript script, int wide, PangoGravity baseGravity, PangoGravityHint hint) 171 { 172 // PangoGravity pango_gravity_get_for_script_and_width (PangoScript script, gboolean wide, PangoGravity base_gravity, PangoGravityHint hint); 173 return pango_gravity_get_for_script_and_width(script, wide, baseGravity, hint); 174 } 175 176 /** 177 * Converts a PangoGravity value to its natural rotation in radians. 178 * gravity should not be PANGO_GRAVITY_AUTO. 179 * Note that pango_matrix_rotate() takes angle in degrees, not radians. 180 * So, to call pango_matrix_rotate() with the output of this function 181 * you should multiply it by (180. / G_PI). 182 * Since 1.16 183 * Params: 184 * gravity = gravity to query 185 * Returns: the rotation value corresponding to gravity. 186 */ 187 public static double gravityToRotation(PangoGravity gravity) 188 { 189 // double pango_gravity_to_rotation (PangoGravity gravity); 190 return pango_gravity_to_rotation(gravity); 191 } 192 }