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 63 private import pango.PgMatrix; 64 65 66 67 68 /** 69 * Description 70 * Since 1.16, Pango is able to correctly lay vertical text out. In fact, it can 71 * set layouts of mixed vertical and non-vertical text. This section describes 72 * the types used for setting vertical text parameters. 73 * The way this is implemented is through the concept of 74 * gravity. Gravity of normal Latin text is south. A 75 * gravity value of east means that glyphs will be rotated ninety degrees 76 * counterclockwise. So, to render vertical text one needs to set the gravity 77 * and rotate the layout using the matrix machinery already in place. This has 78 * the huge advantage that most algorithms working on a PangoLayout do not need 79 * any change as the assumption that lines run in the X direction and stack in 80 * the Y direction holds even for vertical text layouts. 81 * Applications should only need to set base gravity on PangoContext in use, and 82 * let Pango decide the gravity assigned to each run of text. This automatically 83 * handles text with mixed scripts. A very common use is to set the context base 84 * gravity to auto using pango_context_set_base_gravity() 85 * and rotate the layout normally. Pango will make sure that 86 * Asian languages take the right form, while other scripts are rotated normally. 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 * The next thing an application may want to set on the context is the 98 * gravity hint. A PangoGravityHint instructs how 99 * different scripts should react to the set base gravity. 100 * Font descriptions have a gravity property too, that can be set using 101 * pango_font_description_set_gravity() and accessed using 102 * pango_font_description_get_gravity(). However, those are rarely useful 103 * from application code and are mainly used by PangoLayout internally. 104 * Last but not least, one can create PangoAttributes for gravity 105 * and gravity hint using pango_attr_gravity_new() and 106 * pango_attr_gravity_hint_new(). 107 */ 108 public class PgVertical 109 { 110 111 /** 112 */ 113 114 /** 115 * Finds the gravity that best matches the rotation component 116 * in a PangoMatrix. 117 * Since 1.16 118 * Params: 119 * matrix = a PangoMatrix 120 * Returns: the gravity of matrix, which will never be PANGO_GRAVITY_AUTO, or PANGO_GRAVITY_SOUTH if matrix is NULL 121 */ 122 public static PangoGravity gravityGetForMatrix(PgMatrix matrix) 123 { 124 // PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix); 125 return pango_gravity_get_for_matrix((matrix is null) ? null : matrix.getPgMatrixStruct()); 126 } 127 128 /** 129 * Based on the script, base gravity, and hint, returns actual gravity 130 * to use in laying out a single PangoItem. 131 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the 132 * preferred gravity of script. To get the preferred gravity of a script, 133 * pass PANGO_GRAVITY_AUTO and PANGO_GRAVITY_HINT_STRONG in. 134 * Since 1.16 135 * Params: 136 * script = PangoScript to query 137 * baseGravity = base gravity of the paragraph 138 * hint = orientation hint 139 * Returns: resolved gravity suitable to use for a run of text with script. 140 */ 141 public static PangoGravity gravityGetForScript(PangoScript script, PangoGravity baseGravity, PangoGravityHint hint) 142 { 143 // PangoGravity pango_gravity_get_for_script (PangoScript script, PangoGravity base_gravity, PangoGravityHint hint); 144 return pango_gravity_get_for_script(script, baseGravity, hint); 145 } 146 147 /** 148 * Based on the script, East Asian width, base gravity, and hint, 149 * returns actual gravity to use in laying out a single character 150 * or PangoItem. 151 * This function is similar to pango_gravity_get_for_script() except 152 * that this function makes a distinction between narrow/half-width and 153 * wide/full-width characters also. Wide/full-width characters always 154 * stand <emph>upright</emph>, that is, they always take the base gravity, 155 * whereas narrow/full-width characters are always rotated in vertical 156 * context. 157 * If base_gravity is PANGO_GRAVITY_AUTO, it is first replaced with the 158 * preferred gravity of script. 159 * Since 1.26 160 * Params: 161 * script = PangoScript to query 162 * wide = TRUE for wide characters as returned by g_unichar_iswide() 163 * baseGravity = base gravity of the paragraph 164 * hint = orientation hint 165 * Returns: resolved gravity suitable to use for a run of text with script and wide. 166 */ 167 public static PangoGravity gravityGetForScriptAndWidth(PangoScript script, int wide, PangoGravity baseGravity, PangoGravityHint hint) 168 { 169 // PangoGravity pango_gravity_get_for_script_and_width (PangoScript script, gboolean wide, PangoGravity base_gravity, PangoGravityHint hint); 170 return pango_gravity_get_for_script_and_width(script, wide, baseGravity, hint); 171 } 172 173 /** 174 * Converts a PangoGravity value to its natural rotation in radians. 175 * gravity should not be PANGO_GRAVITY_AUTO. 176 * Note that pango_matrix_rotate() takes angle in degrees, not radians. 177 * So, to call pango_matrix_rotate() with the output of this function 178 * you should multiply it by (180. / G_PI). 179 * Since 1.16 180 * Params: 181 * gravity = gravity to query 182 * Returns: the rotation value corresponding to gravity. 183 */ 184 public static double gravityToRotation(PangoGravity gravity) 185 { 186 // double pango_gravity_to_rotation (PangoGravity gravity); 187 return pango_gravity_to_rotation(gravity); 188 } 189 }