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.PgContext; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gtkc.pango; 32 public import gtkc.pangotypes; 33 private import pango.PgAttributeIterator; 34 private import pango.PgAttributeList; 35 private import pango.PgFont; 36 private import pango.PgFontDescription; 37 private import pango.PgFontFamily; 38 private import pango.PgFontMap; 39 private import pango.PgFontMetrics; 40 private import pango.PgFontset; 41 private import pango.PgGlyphString; 42 private import pango.PgItem; 43 private import pango.PgLanguage; 44 private import pango.PgMatrix; 45 46 47 /** 48 * The #PangoContext structure stores global information 49 * used to control the itemization process. 50 */ 51 public class PgContext : ObjectG 52 { 53 /** the main Gtk struct */ 54 protected PangoContext* pangoContext; 55 56 /** Get the main Gtk struct */ 57 public PangoContext* getPgContextStruct() 58 { 59 return pangoContext; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)pangoContext; 66 } 67 68 protected override void setStruct(GObject* obj) 69 { 70 pangoContext = cast(PangoContext*)obj; 71 super.setStruct(obj); 72 } 73 74 /** 75 * Sets our main struct and passes it to the parent class. 76 */ 77 public this (PangoContext* pangoContext, bool ownedRef = false) 78 { 79 this.pangoContext = pangoContext; 80 super(cast(GObject*)pangoContext, ownedRef); 81 } 82 83 84 /** */ 85 public static GType getType() 86 { 87 return pango_context_get_type(); 88 } 89 90 /** 91 * Creates a new #PangoContext initialized to default values. 92 * 93 * This function is not particularly useful as it should always 94 * be followed by a pango_context_set_font_map() call, and the 95 * function pango_font_map_create_context() does these two steps 96 * together and hence users are recommended to use that. 97 * 98 * If you are using Pango as part of a higher-level system, 99 * that system may have it's own way of create a #PangoContext. 100 * For instance, the GTK+ toolkit has, among others, 101 * gdk_pango_context_get_for_screen(), and 102 * gtk_widget_get_pango_context(). Use those instead. 103 * 104 * Return: the newly allocated #PangoContext, which should 105 * be freed with g_object_unref(). 106 * 107 * Throws: ConstructionException GTK+ fails to create the object. 108 */ 109 public this() 110 { 111 auto p = pango_context_new(); 112 113 if(p is null) 114 { 115 throw new ConstructionException("null returned by new"); 116 } 117 118 this(cast(PangoContext*) p, true); 119 } 120 121 /** 122 * Forces a change in the context, which will cause any #PangoLayout 123 * using this context to re-layout. 124 * 125 * This function is only useful when implementing a new backend 126 * for Pango, something applications won't do. Backends should 127 * call this function if they have attached extra data to the context 128 * and such data is changed. 129 * 130 * Since: 1.32.4 131 */ 132 public void changed() 133 { 134 pango_context_changed(pangoContext); 135 } 136 137 /** 138 * Retrieves the base direction for the context. See 139 * pango_context_set_base_dir(). 140 * 141 * Return: the base direction for the context. 142 */ 143 public PangoDirection getBaseDir() 144 { 145 return pango_context_get_base_dir(pangoContext); 146 } 147 148 /** 149 * Retrieves the base gravity for the context. See 150 * pango_context_set_base_gravity(). 151 * 152 * Return: the base gravity for the context. 153 * 154 * Since: 1.16 155 */ 156 public PangoGravity getBaseGravity() 157 { 158 return pango_context_get_base_gravity(pangoContext); 159 } 160 161 /** 162 * Retrieve the default font description for the context. 163 * 164 * Return: a pointer to the context's default font 165 * description. This value must not be modified or freed. 166 */ 167 public PgFontDescription getFontDescription() 168 { 169 auto p = pango_context_get_font_description(pangoContext); 170 171 if(p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 177 } 178 179 /** 180 * Gets the #PangoFontMap used to look up fonts for this context. 181 * 182 * Return: the font map for the #PangoContext. 183 * This value is owned by Pango and should not be unreferenced. 184 * 185 * Since: 1.6 186 */ 187 public PgFontMap getFontMap() 188 { 189 auto p = pango_context_get_font_map(pangoContext); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 197 } 198 199 /** 200 * Retrieves the gravity for the context. This is similar to 201 * pango_context_get_base_gravity(), except for when the base gravity 202 * is %PANGO_GRAVITY_AUTO for which pango_gravity_get_for_matrix() is used 203 * to return the gravity from the current context matrix. 204 * 205 * Return: the resolved gravity for the context. 206 * 207 * Since: 1.16 208 */ 209 public PangoGravity getGravity() 210 { 211 return pango_context_get_gravity(pangoContext); 212 } 213 214 /** 215 * Retrieves the gravity hint for the context. See 216 * pango_context_set_gravity_hint() for details. 217 * 218 * Return: the gravity hint for the context. 219 * 220 * Since: 1.16 221 */ 222 public PangoGravityHint getGravityHint() 223 { 224 return pango_context_get_gravity_hint(pangoContext); 225 } 226 227 /** 228 * Retrieves the global language tag for the context. 229 * 230 * Return: the global language tag. 231 */ 232 public PgLanguage getLanguage() 233 { 234 auto p = pango_context_get_language(pangoContext); 235 236 if(p is null) 237 { 238 return null; 239 } 240 241 return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) p, true); 242 } 243 244 /** 245 * Gets the transformation matrix that will be applied when 246 * rendering with this context. See pango_context_set_matrix(). 247 * 248 * Return: the matrix, or %NULL if no matrix has 249 * been set (which is the same as the identity matrix). The returned 250 * matrix is owned by Pango and must not be modified or freed. 251 * 252 * Since: 1.6 253 */ 254 public PgMatrix getMatrix() 255 { 256 auto p = pango_context_get_matrix(pangoContext); 257 258 if(p is null) 259 { 260 return null; 261 } 262 263 return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) p); 264 } 265 266 /** 267 * Get overall metric information for a particular font 268 * description. Since the metrics may be substantially different for 269 * different scripts, a language tag can be provided to indicate that 270 * the metrics should be retrieved that correspond to the script(s) 271 * used by that language. 272 * 273 * The #PangoFontDescription is interpreted in the same way as 274 * by pango_itemize(), and the family name may be a comma separated 275 * list of figures. If characters from multiple of these families 276 * would be used to render the string, then the returned fonts would 277 * be a composite of the metrics for the fonts loaded for the 278 * individual families. 279 * 280 * Params: 281 * desc = a #PangoFontDescription structure. %NULL means that the 282 * font description from the context will be used. 283 * language = language tag used to determine which script to get 284 * the metrics for. %NULL means that the language tag from the context 285 * will be used. If no language tag is set on the context, metrics 286 * for the default language (as determined by pango_language_get_default()) 287 * will be returned. 288 * 289 * Return: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref() 290 * when finished using the object. 291 */ 292 public PgFontMetrics getMetrics(PgFontDescription desc, PgLanguage language) 293 { 294 auto p = pango_context_get_metrics(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 295 296 if(p is null) 297 { 298 return null; 299 } 300 301 return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true); 302 } 303 304 /** 305 * Returns the current serial number of @context. The serial number is 306 * initialized to an small number larger than zero when a new context 307 * is created and is increased whenever the context is changed using any 308 * of the setter functions, or the #PangoFontMap it uses to find fonts has 309 * changed. The serial may wrap, but will never have the value 0. Since it 310 * can wrap, never compare it with "less than", always use "not equals". 311 * 312 * This can be used to automatically detect changes to a #PangoContext, and 313 * is only useful when implementing objects that need update when their 314 * #PangoContext changes, like #PangoLayout. 315 * 316 * Return: The current serial number of @context. 317 * 318 * Since: 1.32.4 319 */ 320 public uint getSerial() 321 { 322 return pango_context_get_serial(pangoContext); 323 } 324 325 /** 326 * List all families for a context. 327 * 328 * Params: 329 * families = location to store a pointer to 330 * an array of #PangoFontFamily *. This array should be freed 331 * with g_free(). 332 * nFamilies = location to store the number of elements in @descs 333 */ 334 public void listFamilies(out PgFontFamily[] families) 335 { 336 PangoFontFamily** outfamilies = null; 337 int nFamilies; 338 339 pango_context_list_families(pangoContext, &outfamilies, &nFamilies); 340 341 families = new PgFontFamily[nFamilies]; 342 for(size_t i = 0; i < nFamilies; i++) 343 { 344 families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]); 345 } 346 } 347 348 /** 349 * Loads the font in one of the fontmaps in the context 350 * that is the closest match for @desc. 351 * 352 * Params: 353 * desc = a #PangoFontDescription describing the font to load 354 * 355 * Return: the newly allocated #PangoFont 356 * that was loaded, or %NULL if no font matched. 357 */ 358 public PgFont loadFont(PgFontDescription desc) 359 { 360 auto p = pango_context_load_font(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct()); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true); 368 } 369 370 /** 371 * Load a set of fonts in the context that can be used to render 372 * a font matching @desc. 373 * 374 * Params: 375 * desc = a #PangoFontDescription describing the fonts to load 376 * language = a #PangoLanguage the fonts will be used for 377 * 378 * Return: the newly allocated 379 * #PangoFontset loaded, or %NULL if no font matched. 380 */ 381 public PgFontset loadFontset(PgFontDescription desc, PgLanguage language) 382 { 383 auto p = pango_context_load_fontset(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 384 385 if(p is null) 386 { 387 return null; 388 } 389 390 return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p, true); 391 } 392 393 /** 394 * Sets the base direction for the context. 395 * 396 * The base direction is used in applying the Unicode bidirectional 397 * algorithm; if the @direction is %PANGO_DIRECTION_LTR or 398 * %PANGO_DIRECTION_RTL, then the value will be used as the paragraph 399 * direction in the Unicode bidirectional algorithm. A value of 400 * %PANGO_DIRECTION_WEAK_LTR or %PANGO_DIRECTION_WEAK_RTL is used only 401 * for paragraphs that do not contain any strong characters themselves. 402 * 403 * Params: 404 * direction = the new base direction 405 */ 406 public void setBaseDir(PangoDirection direction) 407 { 408 pango_context_set_base_dir(pangoContext, direction); 409 } 410 411 /** 412 * Sets the base gravity for the context. 413 * 414 * The base gravity is used in laying vertical text out. 415 * 416 * Params: 417 * gravity = the new base gravity 418 * 419 * Since: 1.16 420 */ 421 public void setBaseGravity(PangoGravity gravity) 422 { 423 pango_context_set_base_gravity(pangoContext, gravity); 424 } 425 426 /** 427 * Set the default font description for the context 428 * 429 * Params: 430 * desc = the new pango font description 431 */ 432 public void setFontDescription(PgFontDescription desc) 433 { 434 pango_context_set_font_description(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct()); 435 } 436 437 /** 438 * Sets the font map to be searched when fonts are looked-up in this context. 439 * This is only for internal use by Pango backends, a #PangoContext obtained 440 * via one of the recommended methods should already have a suitable font map. 441 * 442 * Params: 443 * fontMap = the #PangoFontMap to set. 444 */ 445 public void setFontMap(PgFontMap fontMap) 446 { 447 pango_context_set_font_map(pangoContext, (fontMap is null) ? null : fontMap.getPgFontMapStruct()); 448 } 449 450 /** 451 * Sets the gravity hint for the context. 452 * 453 * The gravity hint is used in laying vertical text out, and is only relevant 454 * if gravity of the context as returned by pango_context_get_gravity() 455 * is set %PANGO_GRAVITY_EAST or %PANGO_GRAVITY_WEST. 456 * 457 * Params: 458 * hint = the new gravity hint 459 * 460 * Since: 1.16 461 */ 462 public void setGravityHint(PangoGravityHint hint) 463 { 464 pango_context_set_gravity_hint(pangoContext, hint); 465 } 466 467 /** 468 * Sets the global language tag for the context. The default language 469 * for the locale of the running process can be found using 470 * pango_language_get_default(). 471 * 472 * Params: 473 * language = the new language tag. 474 */ 475 public void setLanguage(PgLanguage language) 476 { 477 pango_context_set_language(pangoContext, (language is null) ? null : language.getPgLanguageStruct()); 478 } 479 480 /** 481 * Sets the transformation matrix that will be applied when rendering 482 * with this context. Note that reported metrics are in the user space 483 * coordinates before the application of the matrix, not device-space 484 * coordinates after the application of the matrix. So, they don't scale 485 * with the matrix, though they may change slightly for different 486 * matrices, depending on how the text is fit to the pixel grid. 487 * 488 * Params: 489 * matrix = a #PangoMatrix, or %NULL to unset any existing 490 * matrix. (No matrix set is the same as setting the identity matrix.) 491 * 492 * Since: 1.6 493 */ 494 public void setMatrix(PgMatrix matrix) 495 { 496 pango_context_set_matrix(pangoContext, (matrix is null) ? null : matrix.getPgMatrixStruct()); 497 } 498 499 /** 500 * Determines the normative bidirectional character type of a 501 * character, as specified in the Unicode Character Database. 502 * 503 * A simplified version of this function is available as 504 * pango_unichar_direction(). 505 * 506 * Params: 507 * ch = a Unicode character 508 * 509 * Return: the bidirectional character type, as used in the 510 * Unicode bidirectional algorithm. 511 * 512 * Since: 1.22 513 */ 514 public static PangoBidiType bidiTypeForUnichar(dchar ch) 515 { 516 return pango_bidi_type_for_unichar(ch); 517 } 518 519 /** 520 * Determines possible line, word, and character breaks 521 * for a string of Unicode text with a single analysis. For most 522 * purposes you may want to use pango_get_log_attrs(). 523 * 524 * Params: 525 * text = the text to process 526 * length = length of @text in bytes (may be -1 if @text is nul-terminated) 527 * analysis = #PangoAnalysis structure from pango_itemize() 528 * attrs = an array to store character 529 * information in 530 * attrsLen = size of the array passed as @attrs 531 */ 532 public static void pangoBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr[] attrs) 533 { 534 pango_break(Str.toStringz(text), length, analysis, attrs.ptr, cast(int)attrs.length); 535 } 536 537 /** 538 * This is the default break algorithm, used if no language 539 * engine overrides it. Normally you should use pango_break() 540 * instead. Unlike pango_break(), 541 * @analysis can be %NULL, but only do that if you know what 542 * you're doing. If you need an analysis to pass to pango_break(), 543 * you need to pango_itemize(). In most cases however you should 544 * simply use pango_get_log_attrs(). 545 * 546 * Params: 547 * text = text to break 548 * length = length of text in bytes (may be -1 if @text is nul-terminated) 549 * analysis = a #PangoAnalysis for the @text 550 * attrs = logical attributes to fill in 551 * attrsLen = size of the array passed as @attrs 552 */ 553 public static void defaultBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen) 554 { 555 pango_default_break(Str.toStringz(text), length, analysis, attrs, attrsLen); 556 } 557 558 /** 559 * Searches a string the first character that has a strong 560 * direction, according to the Unicode bidirectional algorithm. 561 * 562 * Params: 563 * text = the text to process 564 * length = length of @text in bytes (may be -1 if @text is nul-terminated) 565 * 566 * Return: The direction corresponding to the first strong character. 567 * If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned. 568 * 569 * Since: 1.4 570 */ 571 public static PangoDirection findBaseDir(string text, int length) 572 { 573 return pango_find_base_dir(Str.toStringz(text), length); 574 } 575 576 /** 577 * Locates a paragraph boundary in @text. A boundary is caused by 578 * delimiter characters, such as a newline, carriage return, carriage 579 * return-newline pair, or Unicode paragraph separator character. The 580 * index of the run of delimiters is returned in 581 * @paragraph_delimiter_index. The index of the start of the paragraph 582 * (index after all delimiters) is stored in @next_paragraph_start. 583 * 584 * If no delimiters are found, both @paragraph_delimiter_index and 585 * @next_paragraph_start are filled with the length of @text (an index one 586 * off the end). 587 * 588 * Params: 589 * text = UTF-8 text 590 * length = length of @text in bytes, or -1 if nul-terminated 591 * paragraphDelimiterIndex = return location for index of 592 * delimiter 593 * nextParagraphStart = return location for start of next 594 * paragraph 595 */ 596 public static void findParagraphBoundary(string text, int length, out int paragraphDelimiterIndex, out int nextParagraphStart) 597 { 598 pango_find_paragraph_boundary(Str.toStringz(text), length, ¶graphDelimiterIndex, &nextParagraphStart); 599 } 600 601 /** 602 * Computes a #PangoLogAttr for each character in @text. The @log_attrs 603 * array must have one #PangoLogAttr for each position in @text; if 604 * @text contains N characters, it has N+1 positions, including the 605 * last position at the end of the text. @text should be an entire 606 * paragraph; logical attributes can't be computed without context 607 * (for example you need to see spaces on either side of a word to know 608 * the word is a word). 609 * 610 * Params: 611 * text = text to process 612 * length = length in bytes of @text 613 * level = embedding level, or -1 if unknown 614 * language = language tag 615 * logAttrs = array with one #PangoLogAttr 616 * per character in @text, plus one extra, to be filled in 617 * attrsLen = length of @log_attrs array 618 */ 619 public static void getLogAttrs(string text, int length, int level, PgLanguage language, PangoLogAttr[] logAttrs) 620 { 621 pango_get_log_attrs(Str.toStringz(text), length, level, (language is null) ? null : language.getPgLanguageStruct(), logAttrs.ptr, cast(int)logAttrs.length); 622 } 623 624 /** 625 * If @ch has the Unicode mirrored property and there is another Unicode 626 * character that typically has a glyph that is the mirror image of @ch's 627 * glyph, puts that character in the address pointed to by @mirrored_ch. 628 * 629 * Use g_unichar_get_mirror_char() instead; the docs for that function 630 * provide full details. 631 * 632 * Params: 633 * ch = a Unicode character 634 * mirroredCh = location to store the mirrored character 635 * 636 * Return: %TRUE if @ch has a mirrored character and @mirrored_ch is 637 * filled in, %FALSE otherwise 638 */ 639 public static bool getMirrorChar(dchar ch, dchar* mirroredCh) 640 { 641 return pango_get_mirror_char(ch, mirroredCh) != 0; 642 } 643 644 /** 645 * Breaks a piece of text into segments with consistent 646 * directional level and shaping engine. Each byte of @text will 647 * be contained in exactly one of the items in the returned list; 648 * the generated list of items will be in logical order (the start 649 * offsets of the items are ascending). 650 * 651 * @cached_iter should be an iterator over @attrs currently positioned at a 652 * range before or containing @start_index; @cached_iter will be advanced to 653 * the range covering the position just after @start_index + @length. 654 * (i.e. if itemizing in a loop, just keep passing in the same @cached_iter). 655 * 656 * Params: 657 * context = a structure holding information that affects 658 * the itemization process. 659 * text = the text to itemize. 660 * startIndex = first byte in @text to process 661 * length = the number of bytes (not characters) to process 662 * after @start_index. 663 * This must be >= 0. 664 * attrs = the set of attributes that apply to @text. 665 * cachedIter = Cached attribute iterator, or %NULL 666 * 667 * Return: a #GList of #PangoItem 668 * structures. The items should be freed using pango_item_free() 669 * probably in combination with g_list_foreach(), and the list itself 670 * using g_list_free(). 671 */ 672 public static ListG itemize(PgContext context, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter) 673 { 674 auto p = pango_itemize((context is null) ? null : context.getPgContextStruct(), Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct()); 675 676 if(p is null) 677 { 678 return null; 679 } 680 681 return new ListG(cast(GList*) p, true); 682 } 683 684 /** 685 * Like pango_itemize(), but the base direction to use when 686 * computing bidirectional levels (see pango_context_set_base_dir ()), 687 * is specified explicitly rather than gotten from the #PangoContext. 688 * 689 * Params: 690 * context = a structure holding information that affects 691 * the itemization process. 692 * baseDir = base direction to use for bidirectional processing 693 * text = the text to itemize. 694 * startIndex = first byte in @text to process 695 * length = the number of bytes (not characters) to process 696 * after @start_index. This must be >= 0. 697 * attrs = the set of attributes that apply to @text. 698 * cachedIter = Cached attribute iterator, or %NULL 699 * 700 * Return: a #GList of 701 * #PangoItem structures. The items should be freed using 702 * pango_item_free() probably in combination with 703 * g_list_foreach(), and the list itself using g_list_free(). 704 * 705 * Since: 1.4 706 */ 707 public static ListG itemizeWithBaseDir(PgContext context, PangoDirection baseDir, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter) 708 { 709 auto p = pango_itemize_with_base_dir((context is null) ? null : context.getPgContextStruct(), baseDir, Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct()); 710 711 if(p is null) 712 { 713 return null; 714 } 715 716 return new ListG(cast(GList*) p, true); 717 } 718 719 /** 720 * From a list of items in logical order and the associated 721 * directional levels, produce a list in visual order. 722 * The original list is unmodified. 723 * 724 * Params: 725 * logicalItems = a #GList of #PangoItem in logical order. 726 * 727 * Return: a #GList 728 * of #PangoItem structures in visual order. 729 * 730 * (Please open a bug if you use this function. 731 * It is not a particularly convenient interface, and the code 732 * is duplicated elsewhere in Pango for that reason.) 733 */ 734 public static ListG reorderItems(ListG logicalItems) 735 { 736 auto p = pango_reorder_items((logicalItems is null) ? null : logicalItems.getListGStruct()); 737 738 if(p is null) 739 { 740 return null; 741 } 742 743 return new ListG(cast(GList*) p, true); 744 } 745 746 /** 747 * Given a segment of text and the corresponding 748 * #PangoAnalysis structure returned from pango_itemize(), 749 * convert the characters into glyphs. You may also pass 750 * in only a substring of the item from pango_itemize(). 751 * 752 * It is recommended that you use pango_shape_full() instead, since 753 * that API allows for shaping interaction happening across text item 754 * boundaries. 755 * 756 * Params: 757 * text = the text to process 758 * length = the length (in bytes) of @text 759 * analysis = #PangoAnalysis structure from pango_itemize() 760 * glyphs = glyph string in which to store results 761 */ 762 public static void shape(string text, int length, PangoAnalysis* analysis, PgGlyphString glyphs) 763 { 764 pango_shape(Str.toStringz(text), length, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 765 } 766 767 /** 768 * Given a segment of text and the corresponding 769 * #PangoAnalysis structure returned from pango_itemize(), 770 * convert the characters into glyphs. You may also pass 771 * in only a substring of the item from pango_itemize(). 772 * 773 * This is similar to pango_shape(), except it also can optionally take 774 * the full paragraph text as input, which will then be used to perform 775 * certain cross-item shaping interactions. If you have access to the broader 776 * text of which @item_text is part of, provide the broader text as 777 * @paragraph_text. If @paragraph_text is %NULL, item text is used instead. 778 * 779 * Params: 780 * itemText = valid UTF-8 text to shape. 781 * itemLength = the length (in bytes) of @item_text. -1 means nul-terminated text. 782 * paragraphText = text of the paragraph (see details). May be %NULL. 783 * paragraphLength = the length (in bytes) of @paragraph_text. -1 means nul-terminated text. 784 * analysis = #PangoAnalysis structure from pango_itemize(). 785 * glyphs = glyph string in which to store results. 786 * 787 * Since: 1.32 788 */ 789 public static void shapeFull(string itemText, int itemLength, string paragraphText, int paragraphLength, PangoAnalysis* analysis, PgGlyphString glyphs) 790 { 791 pango_shape_full(Str.toStringz(itemText), itemLength, Str.toStringz(paragraphText), paragraphLength, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 792 } 793 794 /** 795 * Determines the inherent direction of a character; either 796 * %PANGO_DIRECTION_LTR, %PANGO_DIRECTION_RTL, or 797 * %PANGO_DIRECTION_NEUTRAL. 798 * 799 * This function is useful to categorize characters into left-to-right 800 * letters, right-to-left letters, and everything else. If full 801 * Unicode bidirectional type of a character is needed, 802 * pango_bidi_type_for_unichar() can be used instead. 803 * 804 * Params: 805 * ch = a Unicode character 806 * 807 * Return: the direction of the character. 808 */ 809 public static PangoDirection unicharDirection(dchar ch) 810 { 811 return pango_unichar_direction(ch); 812 } 813 }