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 module pango.PgMiscellaneous; 26 27 private import core.stdc.stdio; 28 private import glib.Str; 29 private import glib.StringG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 33 34 /** */ 35 public struct PgMiscellaneous 36 { 37 38 /** 39 * Do not use. Does not do anything. 40 * 41 * Params: 42 * key = Key to look up, in the form "SECTION/KEY". 43 * 44 * Returns: %NULL 45 */ 46 public static string configKeyGet(string key) 47 { 48 auto retStr = pango_config_key_get(Str.toStringz(key)); 49 50 scope(exit) Str.freeString(retStr); 51 return Str.toString(retStr); 52 } 53 54 /** 55 * Do not use. Does not do anything. 56 * 57 * Params: 58 * key = Key to look up, in the form "SECTION/KEY". 59 * 60 * Returns: %NULL 61 */ 62 public static string configKeyGetSystem(string key) 63 { 64 auto retStr = pango_config_key_get_system(Str.toStringz(key)); 65 66 scope(exit) Str.freeString(retStr); 67 return Str.toString(retStr); 68 } 69 70 /** 71 * Returns the name of the "pango" subdirectory of LIBDIR 72 * (which is set at compile time). 73 * 74 * Returns: the Pango lib directory. The returned string should 75 * not be freed. 76 */ 77 public static string getLibSubdirectory() 78 { 79 return Str.toString(pango_get_lib_subdirectory()); 80 } 81 82 /** 83 * Returns the name of the "pango" subdirectory of SYSCONFDIR 84 * (which is set at compile time). 85 * 86 * Returns: the Pango sysconf directory. The returned string should 87 * not be freed. 88 */ 89 public static string getSysconfSubdirectory() 90 { 91 return Str.toString(pango_get_sysconf_subdirectory()); 92 } 93 94 /** 95 * Checks @ch to see if it is a character that should not be 96 * normally rendered on the screen. This includes all Unicode characters 97 * with "ZERO WIDTH" in their name, as well as <firstterm>bidi</firstterm> formatting characters, and 98 * a few other ones. This is totally different from g_unichar_iszerowidth() 99 * and is at best misnamed. 100 * 101 * Params: 102 * ch = a Unicode character 103 * 104 * Returns: %TRUE if @ch is a zero-width character, %FALSE otherwise 105 * 106 * Since: 1.10 107 */ 108 public static bool isZeroWidth(dchar ch) 109 { 110 return pango_is_zero_width(ch) != 0; 111 } 112 113 /** 114 * This will return the bidirectional embedding levels of the input paragraph 115 * as defined by the Unicode Bidirectional Algorithm available at: 116 * 117 * http://www.unicode.org/reports/tr9/ 118 * 119 * If the input base direction is a weak direction, the direction of the 120 * characters in the text will determine the final resolved direction. 121 * 122 * Params: 123 * text = the text to itemize. 124 * length = the number of bytes (not characters) to process, or -1 125 * if @text is nul-terminated and the length should be calculated. 126 * pbaseDir = input base direction, and output resolved direction. 127 * 128 * Returns: a newly allocated array of embedding levels, one item per 129 * character (not byte), that should be freed using g_free. 130 * 131 * Since: 1.4 132 */ 133 public static ubyte* log2visGetEmbeddingLevels(string text, int length, PangoDirection* pbaseDir) 134 { 135 return pango_log2vis_get_embedding_levels(Str.toStringz(text), length, pbaseDir); 136 } 137 138 /** 139 * Look up all user defined aliases for the alias @fontname. 140 * The resulting font family names will be stored in @families, 141 * and the number of families in @n_families. 142 * 143 * Deprecated: This function is not thread-safe. 144 * 145 * Params: 146 * fontname = an ascii string 147 * families = will be set to an array of font family names. 148 * this array is owned by pango and should not be freed. 149 * nFamilies = will be set to the length of the @families array. 150 */ 151 public static void lookupAliases(string fontname, out string[] families) 152 { 153 char** outfamilies = null; 154 int nFamilies; 155 156 pango_lookup_aliases(Str.toStringz(fontname), &outfamilies, &nFamilies); 157 158 families = Str.toStringArray(outfamilies, nFamilies); 159 } 160 161 /** 162 * Parses an enum type and stores the result in @value. 163 * 164 * If @str does not match the nick name of any of the possible values for the 165 * enum and is not an integer, %FALSE is returned, a warning is issued 166 * if @warn is %TRUE, and a 167 * string representing the list of possible values is stored in 168 * @possible_values. The list is slash-separated, eg. 169 * "none/start/middle/end". If failed and @possible_values is not %NULL, 170 * returned string should be freed using g_free(). 171 * 172 * Params: 173 * type = enum type to parse, eg. %PANGO_TYPE_ELLIPSIZE_MODE. 174 * str = string to parse. May be %NULL. 175 * value = integer to store the result in, or %NULL. 176 * warn = if %TRUE, issue a g_warning() on bad input. 177 * possibleValues = place to store list of possible values on failure, or %NULL. 178 * 179 * Returns: %TRUE if @str was successfully parsed. 180 * 181 * Since: 1.16 182 */ 183 public static bool parseEnum(GType type, string str, out int value, bool warn, out string possibleValues) 184 { 185 char* outpossibleValues = null; 186 187 auto p = pango_parse_enum(type, Str.toStringz(str), &value, warn, &outpossibleValues) != 0; 188 189 possibleValues = Str.toString(outpossibleValues); 190 191 return p; 192 } 193 194 /** 195 * Parses a font stretch. The allowed values are 196 * "ultra_condensed", "extra_condensed", "condensed", 197 * "semi_condensed", "normal", "semi_expanded", "expanded", 198 * "extra_expanded" and "ultra_expanded". Case variations are 199 * ignored and the '_' characters may be omitted. 200 * 201 * Params: 202 * str = a string to parse. 203 * stretch = a #PangoStretch to store the 204 * result in. 205 * warn = if %TRUE, issue a g_warning() on bad input. 206 * 207 * Returns: %TRUE if @str was successfully parsed. 208 */ 209 public static bool parseStretch(string str, out PangoStretch stretch, bool warn) 210 { 211 return pango_parse_stretch(Str.toStringz(str), &stretch, warn) != 0; 212 } 213 214 /** 215 * Parses a font style. The allowed values are "normal", 216 * "italic" and "oblique", case variations being 217 * ignored. 218 * 219 * Params: 220 * str = a string to parse. 221 * style = a #PangoStyle to store the result 222 * in. 223 * warn = if %TRUE, issue a g_warning() on bad input. 224 * 225 * Returns: %TRUE if @str was successfully parsed. 226 */ 227 public static bool parseStyle(string str, out PangoStyle style, bool warn) 228 { 229 return pango_parse_style(Str.toStringz(str), &style, warn) != 0; 230 } 231 232 /** 233 * Parses a font variant. The allowed values are "normal" 234 * and "smallcaps" or "small_caps", case variations being 235 * ignored. 236 * 237 * Params: 238 * str = a string to parse. 239 * variant = a #PangoVariant to store the 240 * result in. 241 * warn = if %TRUE, issue a g_warning() on bad input. 242 * 243 * Returns: %TRUE if @str was successfully parsed. 244 */ 245 public static bool parseVariant(string str, out PangoVariant variant, bool warn) 246 { 247 return pango_parse_variant(Str.toStringz(str), &variant, warn) != 0; 248 } 249 250 /** 251 * Parses a font weight. The allowed values are "heavy", 252 * "ultrabold", "bold", "normal", "light", "ultraleight" 253 * and integers. Case variations are ignored. 254 * 255 * Params: 256 * str = a string to parse. 257 * weight = a #PangoWeight to store the result 258 * in. 259 * warn = if %TRUE, issue a g_warning() on bad input. 260 * 261 * Returns: %TRUE if @str was successfully parsed. 262 */ 263 public static bool parseWeight(string str, out PangoWeight weight, bool warn) 264 { 265 return pango_parse_weight(Str.toStringz(str), &weight, warn) != 0; 266 } 267 268 /** 269 * Quantizes the thickness and position of a line, typically an 270 * underline or strikethrough, to whole device pixels, that is integer 271 * multiples of %PANGO_SCALE. The purpose of this function is to avoid 272 * such lines looking blurry. 273 * 274 * Care is taken to make sure @thickness is at least one pixel when this 275 * function returns, but returned @position may become zero as a result 276 * of rounding. 277 * 278 * Params: 279 * thickness = pointer to the thickness of a line, in Pango units 280 * position = corresponding position 281 * 282 * Since: 1.12 283 */ 284 public static void quantizeLineGeometry(ref int thickness, ref int position) 285 { 286 pango_quantize_line_geometry(&thickness, &position); 287 } 288 289 /** 290 * Reads an entire line from a file into a buffer. Lines may 291 * be delimited with '\n', '\r', '\n\r', or '\r\n'. The delimiter 292 * is not written into the buffer. Text after a '#' character is treated as 293 * a comment and skipped. '\' can be used to escape a # character. 294 * '\' proceeding a line delimiter combines adjacent lines. A '\' proceeding 295 * any other character is ignored and written into the output buffer 296 * unmodified. 297 * 298 * Params: 299 * stream = a stdio stream 300 * str = #GString buffer into which to write the result 301 * 302 * Returns: 0 if the stream was already at an %EOF character, otherwise 303 * the number of lines read (this is useful for maintaining 304 * a line number counter which doesn't combine lines with '\') 305 */ 306 public static int readLine(FILE* stream, out StringG str) 307 { 308 GString* outstr = gMalloc!GString(); 309 310 auto p = pango_read_line(stream, outstr); 311 312 str = new StringG(outstr, true); 313 314 return p; 315 } 316 317 /** 318 * Scans an integer. 319 * Leading white space is skipped. 320 * 321 * Params: 322 * pos = in/out string position 323 * output = an int into which to write the result 324 * 325 * Returns: %FALSE if a parse error occurred. 326 */ 327 public static bool scanInt(ref string pos, out int output) 328 { 329 char* outpos = Str.toStringz(pos); 330 331 auto p = pango_scan_int(&outpos, &output) != 0; 332 333 pos = Str.toString(outpos); 334 335 return p; 336 } 337 338 /** 339 * Scans a string into a #GString buffer. The string may either 340 * be a sequence of non-white-space characters, or a quoted 341 * string with '"'. Instead a quoted string, '\"' represents 342 * a literal quote. Leading white space outside of quotes is skipped. 343 * 344 * Params: 345 * pos = in/out string position 346 * output = a #GString into which to write the result 347 * 348 * Returns: %FALSE if a parse error occurred. 349 */ 350 public static bool scanString(ref string pos, out StringG output) 351 { 352 char* outpos = Str.toStringz(pos); 353 GString* outoutput = gMalloc!GString(); 354 355 auto p = pango_scan_string(&outpos, outoutput) != 0; 356 357 pos = Str.toString(outpos); 358 output = new StringG(outoutput, true); 359 360 return p; 361 } 362 363 /** 364 * Scans a word into a #GString buffer. A word consists 365 * of [A-Za-z_] followed by zero or more [A-Za-z_0-9] 366 * Leading white space is skipped. 367 * 368 * Params: 369 * pos = in/out string position 370 * output = a #GString into which to write the result 371 * 372 * Returns: %FALSE if a parse error occurred. 373 */ 374 public static bool scanWord(ref string pos, out StringG output) 375 { 376 char* outpos = Str.toStringz(pos); 377 GString* outoutput = gMalloc!GString(); 378 379 auto p = pango_scan_word(&outpos, outoutput) != 0; 380 381 pos = Str.toString(outpos); 382 output = new StringG(outoutput, true); 383 384 return p; 385 } 386 387 /** 388 * Skips 0 or more characters of white space. 389 * 390 * Params: 391 * pos = in/out string position 392 * 393 * Returns: %FALSE if skipping the white space leaves 394 * the position at a '\0' character. 395 */ 396 public static bool skipSpace(ref string pos) 397 { 398 char* outpos = Str.toStringz(pos); 399 400 auto p = pango_skip_space(&outpos) != 0; 401 402 pos = Str.toString(outpos); 403 404 return p; 405 } 406 407 /** 408 * Splits a %G_SEARCHPATH_SEPARATOR-separated list of files, stripping 409 * white space and substituting ~/ with $HOME/. 410 * 411 * Params: 412 * str = a %G_SEARCHPATH_SEPARATOR separated list of filenames 413 * 414 * Returns: a list of 415 * strings to be freed with g_strfreev() 416 */ 417 public static string[] splitFileList(string str) 418 { 419 auto retStr = pango_split_file_list(Str.toStringz(str)); 420 421 scope(exit) Str.freeStringArray(retStr); 422 return Str.toStringArray(retStr); 423 } 424 425 /** 426 * Trims leading and trailing whitespace from a string. 427 * 428 * Params: 429 * str = a string 430 * 431 * Returns: A newly-allocated string that must be freed with g_free() 432 */ 433 public static string trimString(string str) 434 { 435 auto retStr = pango_trim_string(Str.toStringz(str)); 436 437 scope(exit) Str.freeString(retStr); 438 return Str.toString(retStr); 439 } 440 }