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