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