1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gdk-Fonts.html 27 * outPack = gdk 28 * outFile = Font 29 * strct = GdkFont 30 * realStrct= 31 * ctorStrct= 32 * clss = Font 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_font_ 41 * - gdk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gdk.Display 49 * - pango.PgFontDescription 50 * structWrap: 51 * - GdkDisplay* -> Display 52 * - GdkFont* -> Font 53 * - PangoFontDescription* -> PgFontDescription 54 * module aliases: 55 * local aliases: 56 * overrides: 57 */ 58 59 module gdk.Font; 60 61 public import gtkc.gdktypes; 62 63 private import gtkc.gdk; 64 private import glib.ConstructionException; 65 private import gobject.ObjectG; 66 67 68 private import glib.Str; 69 private import gdk.Display; 70 private import pango.PgFontDescription; 71 72 73 74 75 /** 76 * Description 77 * The GdkFont data type represents a font for drawing on 78 * the screen. These functions provide support for 79 * loading fonts, and also for determining the dimensions 80 * of characters and strings when drawn with a particular 81 * font. 82 * Fonts in X are specified by a 83 * X Logical Font Description. 84 * The following description is considerably simplified. 85 * For definitive information about XLFD's see the 86 * X reference documentation. A X Logical Font Description (XLFD) 87 * consists of a sequence of fields separated (and surrounded by) '-' 88 * characters. For example, Adobe Helvetica Bold 12 pt, has the 89 * full description: 90 * $(DDOC_COMMENT example) 91 * The fields in the XLFD are: 92 * Foundry 93 * the company or organization where the font originated. 94 * Family 95 * the font family (a group of related font designs). 96 * Weight 97 * A name for the font's typographic weight 98 * For example, 'bold' or 'medium'). 99 * Slant 100 * The slant of the font. Common values are 'R' for Roman, 101 * 'I' for italoc, and 'O' for oblique. 102 * Set Width 103 * A name for the width of the font. For example, 104 * 'normal' or 'condensed'. 105 * Add Style 106 * Additional information to distinguish a font from 107 * other fonts of the same family. 108 * Pixel Size 109 * The body size of the font in pixels. 110 * Point Size 111 * The body size of the font in 10ths of a point. 112 * (A point is 1/72.27 inch) 113 * Resolution X 114 * The horizontal resolution that the font was designed for. 115 * Resolution Y 116 * The vertical resolution that the font was designed for . 117 * Spacing 118 * The type of spacing for the font - can be 'p' for proportional, 119 * 'm' for monospaced or 'c' for charcell. 120 * Average Width 121 * The average width of a glyph in the font. For monospaced 122 * and charcell fonts, all glyphs in the font have this width 123 * Charset Registry 124 * The registration authority that owns the encoding for 125 * the font. Together with the Charset Encoding field, this 126 * defines the character set for the font. 127 * Charset Encoding 128 * An identifier for the particular character set encoding. 129 * When specifying a font via a X logical Font Description, 130 * '*' can be used as a wildcard to match any portion of 131 * the XLFD. For instance, the above example could 132 * also be specified as 133 * $(DDOC_COMMENT example) 134 * It is generally a good idea to use wildcards for any 135 * portion of the XLFD that your program does not care 136 * about specifically, since that will improve the 137 * chances of finding a matching font. 138 * A fontset is a list of fonts 139 * that is used for drawing international text that may 140 * contain characters from a number of different character 141 * sets. It is represented by a list of XLFD's. 142 * The font for a given character set is determined by going 143 * through the list of XLFD's in order. For each one, if 144 * the registry and and encoding fields match the desired 145 * character set, then that font is used, otherwise if 146 * the XLFD contains wild-cards for the registry and encoding 147 * fields, the registry and encoding for the desired character 148 * set are substituted in and a lookup is done. If a match is found 149 * that font is used. Otherwise, processing continues 150 * on to the next font in the list. 151 * The functions for determining the metrics of a string 152 * come in several varieties that can take a number 153 * of forms of string input: 154 * 8-bit string 155 * When using functions like gdk_string_width() that 156 * take a gchar *, if the font is of type 157 * GDK_FONT_FONT and is an 8-bit font, then each 158 * gchar indexes the glyphs in the font directly. 159 * 16-bit string 160 * For functions taking a gchar *, if the 161 * font is of type GDK_FONT_FONT, and is a 16-bit 162 * font, then the gchar * argument is 163 * interpreted as a guint16 * cast to 164 * a gchar * and each guint16 165 * indexes the glyphs in the font directly. 166 * Multibyte string 167 * For functions taking a gchar *, if the 168 * font is of type GDK_FONT_FONTSET, then the input 169 * string is interpreted as a multibyte 170 * encoded according to the current locale. (A multibyte 171 * string is one in which each character may consist 172 * of one or more bytes, with different lengths for different 173 * characters in the string). They can be converted to and 174 * from wide character strings (see below) using 175 * gdk_wcstombs() and gdk_mbstowcs().) The string will 176 * be rendered using one or more different fonts from 177 * the fontset. 178 * Wide character string 179 * For a number of the text-measuring functions, GDK 180 * provides a variant (such as gdk_text_width_wc()) which 181 * takes a GdkWChar * instead of a 182 * gchar *. The input is then taken to 183 * be a wide character string in the encoding of the 184 * current locale. (A wide character string is a string 185 * in which each character consists of several bytes, 186 * and the width of each character in the string is 187 * constant.) 188 * GDK provides functions to determine a number of different 189 * measurements (metrics) for a given string. (Need diagram 190 * here). 191 * ascent 192 * The vertical distance from the origin of the drawing 193 * opereration to the top of the drawn character. 194 * descent 195 * The vertical distance from the origin of the drawing 196 * opereration to the bottom of the drawn character. 197 * left bearing 198 * The horizontal distance from the origin of the drawing 199 * operation to the left-most part of the drawn character. 200 * right bearing 201 * The horizontal distance from the origin of the drawing 202 * operation to the right-most part of the drawn character. 203 * width bearing 204 * The horizontal distance from the origin of the drawing 205 * operation to the correct origin for drawing another 206 * string to follow the current one. Depending on the 207 * font, this could be greater than or less than the 208 * right bearing. 209 */ 210 public class Font 211 { 212 213 /** the main Gtk struct */ 214 protected GdkFont* gdkFont; 215 216 217 public GdkFont* getFontStruct() 218 { 219 return gdkFont; 220 } 221 222 223 /** the main Gtk struct as a void* */ 224 protected void* getStruct() 225 { 226 return cast(void*)gdkFont; 227 } 228 229 /** 230 * Sets our main struct and passes it to the parent class 231 */ 232 public this (GdkFont* gdkFont) 233 { 234 this.gdkFont = gdkFont; 235 } 236 237 /** 238 * Create and loads a font 239 */ 240 public this(string fontName) 241 { 242 this(gdk_font_load(Str.toStringz(fontName))); 243 } 244 245 /** 246 */ 247 248 /** 249 * Warning 250 * gdk_font_load is deprecated and should not be used in newly-written code. 251 * Loads a font. 252 * The font may be newly loaded or looked up the font in a cache. 253 * You should make no assumptions about the initial reference count. 254 * Params: 255 * fontName = a XLFD describing the font to load. 256 * Returns: a GdkFont, or NULL if the font could not be loaded. 257 */ 258 public static Font load(string fontName) 259 { 260 // GdkFont * gdk_font_load (const gchar *font_name); 261 auto p = gdk_font_load(Str.toStringz(fontName)); 262 263 if(p is null) 264 { 265 return null; 266 } 267 268 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 269 } 270 271 /** 272 * Warning 273 * gdk_font_load_for_display is deprecated and should not be used in newly-written code. 274 * Loads a font for use on display. 275 * The font may be newly loaded or looked up the font in a cache. 276 * You should make no assumptions about the initial reference count. 277 * Since 2.2 278 * Params: 279 * display = a GdkDisplay 280 * fontName = a XLFD describing the font to load. 281 * Returns: a GdkFont, or NULL if the font could not be loaded. 282 */ 283 public static Font loadForDisplay(Display display, string fontName) 284 { 285 // GdkFont * gdk_font_load_for_display (GdkDisplay *display, const gchar *font_name); 286 auto p = gdk_font_load_for_display((display is null) ? null : display.getDisplayStruct(), Str.toStringz(fontName)); 287 288 if(p is null) 289 { 290 return null; 291 } 292 293 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 294 } 295 296 /** 297 * Warning 298 * gdk_fontset_load is deprecated and should not be used in newly-written code. 299 * Loads a fontset. 300 * The fontset may be newly loaded or looked up in a cache. 301 * You should make no assumptions about the initial reference count. 302 * Params: 303 * fontsetName = a comma-separated list of XLFDs describing 304 * the component fonts of the fontset to load. 305 * Returns: a GdkFont, or NULL if the fontset could not be loaded. 306 */ 307 public static Font fontsetLoad(string fontsetName) 308 { 309 // GdkFont * gdk_fontset_load (const gchar *fontset_name); 310 auto p = gdk_fontset_load(Str.toStringz(fontsetName)); 311 312 if(p is null) 313 { 314 return null; 315 } 316 317 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 318 } 319 320 /** 321 * Warning 322 * gdk_fontset_load_for_display is deprecated and should not be used in newly-written code. 323 * Loads a fontset for use on display. 324 * The fontset may be newly loaded or looked up in a cache. 325 * You should make no assumptions about the initial reference count. 326 * Since 2.2 327 * Params: 328 * display = a GdkDisplay 329 * fontsetName = a comma-separated list of XLFDs describing 330 * the component fonts of the fontset to load. 331 * Returns: a GdkFont, or NULL if the fontset could not be loaded. 332 */ 333 public static Font fontsetLoadForDisplay(Display display, string fontsetName) 334 { 335 // GdkFont * gdk_fontset_load_for_display (GdkDisplay *display, const gchar *fontset_name); 336 auto p = gdk_fontset_load_for_display((display is null) ? null : display.getDisplayStruct(), Str.toStringz(fontsetName)); 337 338 if(p is null) 339 { 340 return null; 341 } 342 343 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 344 } 345 346 /** 347 * Warning 348 * gdk_font_from_description is deprecated and should not be used in newly-written code. 349 * Load a GdkFont based on a Pango font description. This font will 350 * only be an approximation of the Pango font, and 351 * internationalization will not be handled correctly. This function 352 * should only be used for legacy code that cannot be easily converted 353 * to use Pango. Using Pango directly will produce better results. 354 * Params: 355 * fontDesc = a PangoFontDescription. 356 * Returns: the newly loaded font, or NULL if the font cannot be loaded. 357 */ 358 public static Font fromDescription(PgFontDescription fontDesc) 359 { 360 // GdkFont * gdk_font_from_description (PangoFontDescription *font_desc); 361 auto p = gdk_font_from_description((fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 362 363 if(p is null) 364 { 365 return null; 366 } 367 368 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 369 } 370 371 /** 372 * Warning 373 * gdk_font_from_description_for_display is deprecated and should not be used in newly-written code. 374 * Loads a GdkFont based on a Pango font description for use on display. 375 * This font will only be an approximation of the Pango font, and 376 * internationalization will not be handled correctly. This function 377 * should only be used for legacy code that cannot be easily converted 378 * to use Pango. Using Pango directly will produce better results. 379 * Since 2.2 380 * Params: 381 * display = a GdkDisplay 382 * fontDesc = a PangoFontDescription. 383 * Returns: the newly loaded font, or NULL if the font cannot be loaded. 384 */ 385 public static Font fromDescriptionForDisplay(Display display, PgFontDescription fontDesc) 386 { 387 // GdkFont * gdk_font_from_description_for_display (GdkDisplay *display, PangoFontDescription *font_desc); 388 auto p = gdk_font_from_description_for_display((display is null) ? null : display.getDisplayStruct(), (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 389 390 if(p is null) 391 { 392 return null; 393 } 394 395 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 396 } 397 398 /** 399 * Warning 400 * gdk_font_get_display is deprecated and should not be used in newly-written code. 401 * Returns the GdkDisplay for font. 402 * Since 2.2 403 * Returns: the corresponding GdkDisplay. 404 */ 405 public Display getDisplay() 406 { 407 // GdkDisplay * gdk_font_get_display (GdkFont *font); 408 auto p = gdk_font_get_display(gdkFont); 409 410 if(p is null) 411 { 412 return null; 413 } 414 415 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 416 } 417 418 /** 419 * Warning 420 * gdk_font_ref is deprecated and should not be used in newly-written code. 421 * Increases the reference count of a font by one. 422 * Returns: font 423 */ 424 public Font doref() 425 { 426 // GdkFont * gdk_font_ref (GdkFont *font); 427 auto p = gdk_font_ref(gdkFont); 428 429 if(p is null) 430 { 431 return null; 432 } 433 434 return ObjectG.getDObject!(Font)(cast(GdkFont*) p); 435 } 436 437 /** 438 * Warning 439 * gdk_font_unref is deprecated and should not be used in newly-written code. 440 * Decreases the reference count of a font by one. 441 * If the result is zero, destroys the font. 442 */ 443 public void unref() 444 { 445 // void gdk_font_unref (GdkFont *font); 446 gdk_font_unref(gdkFont); 447 } 448 449 /** 450 * Warning 451 * gdk_font_id is deprecated and should not be used in newly-written code. 452 * Returns the X Font ID for the given font. 453 * Returns: the numeric X Font ID 454 */ 455 public int id() 456 { 457 // gint gdk_font_id (const GdkFont *font); 458 return gdk_font_id(gdkFont); 459 } 460 461 /** 462 * Warning 463 * gdk_font_equal is deprecated and should not be used in newly-written code. 464 * Compares two fonts for equality. Single fonts compare equal 465 * if they have the same X font ID. This operation does 466 * not currently work correctly for fontsets. 467 * Params: 468 * fontb = another GdkFont. 469 * Returns: TRUE if the fonts are equal. 470 */ 471 public int equal(Font fontb) 472 { 473 // gboolean gdk_font_equal (const GdkFont *fonta, const GdkFont *fontb); 474 return gdk_font_equal(gdkFont, (fontb is null) ? null : fontb.getFontStruct()); 475 } 476 477 /** 478 * Warning 479 * gdk_string_extents is deprecated and should not be used in newly-written code. 480 * Gets the metrics of a nul-terminated string. 481 * Params: 482 * string = the nul-terminated string to measure. 483 * lbearing = the left bearing of the string. 484 * rbearing = the right bearing of the string. 485 * width = the width of the string. 486 * ascent = the ascent of the string. 487 * descent = the descent of the string. 488 */ 489 public void stringExtents(string string, out int lbearing, out int rbearing, out int width, out int ascent, out int descent) 490 { 491 // void gdk_string_extents (GdkFont *font, const gchar *string, gint *lbearing, gint *rbearing, gint *width, gint *ascent, gint *descent); 492 gdk_string_extents(gdkFont, Str.toStringz(string), &lbearing, &rbearing, &width, &ascent, &descent); 493 } 494 495 /** 496 * Warning 497 * gdk_text_extents is deprecated and should not be used in newly-written code. 498 * Gets the metrics of a string. 499 * Params: 500 * text = the text to measure 501 * textLength = the length of the text in bytes. (If the 502 * font is a 16-bit font, this is twice the length 503 * of the text in characters.) 504 * lbearing = the left bearing of the string. 505 * rbearing = the right bearing of the string. 506 * width = the width of the string. 507 * ascent = the ascent of the string. 508 * descent = the descent of the string. 509 */ 510 public void textExtents(string text, int textLength, out int lbearing, out int rbearing, out int width, out int ascent, out int descent) 511 { 512 // void gdk_text_extents (GdkFont *font, const gchar *text, gint text_length, gint *lbearing, gint *rbearing, gint *width, gint *ascent, gint *descent); 513 gdk_text_extents(gdkFont, Str.toStringz(text), textLength, &lbearing, &rbearing, &width, &ascent, &descent); 514 } 515 516 /** 517 * Warning 518 * gdk_text_extents_wc is deprecated and should not be used in newly-written code. 519 * Gets the metrics of a string of wide characters. 520 * Params: 521 * text = the text to measure. 522 * lbearing = the left bearing of the string. 523 * rbearing = the right bearing of the string. 524 * width = the width of the string. 525 * ascent = the ascent of the string. 526 * descent = the descent of the string. 527 */ 528 public void textExtentsWc(GdkWChar[] text, out int lbearing, out int rbearing, out int width, out int ascent, out int descent) 529 { 530 // void gdk_text_extents_wc (GdkFont *font, const GdkWChar *text, gint text_length, gint *lbearing, gint *rbearing, gint *width, gint *ascent, gint *descent); 531 gdk_text_extents_wc(gdkFont, text.ptr, cast(int) text.length, &lbearing, &rbearing, &width, &ascent, &descent); 532 } 533 534 /** 535 * Warning 536 * gdk_string_width is deprecated and should not be used in newly-written code. 537 * Determines the width of a nul-terminated string. 538 * (The distance from the origin of the string to the 539 * point where the next string in a sequence of strings 540 * should be drawn) 541 * Params: 542 * string = the nul-terminated string to measure 543 * Returns: the width of the string in pixels. 544 */ 545 public int stringWidth(string string) 546 { 547 // gint gdk_string_width (GdkFont *font, const gchar *string); 548 return gdk_string_width(gdkFont, Str.toStringz(string)); 549 } 550 551 /** 552 * Warning 553 * gdk_text_width is deprecated and should not be used in newly-written code. 554 * Determines the width of a given string. 555 * Params: 556 * text = the text to measure. 557 * textLength = the length of the text in bytes. 558 * Returns: the width of the string in pixels. 559 */ 560 public int textWidth(string text, int textLength) 561 { 562 // gint gdk_text_width (GdkFont *font, const gchar *text, gint text_length); 563 return gdk_text_width(gdkFont, Str.toStringz(text), textLength); 564 } 565 566 /** 567 * Warning 568 * gdk_text_width_wc is deprecated and should not be used in newly-written code. 569 * Determines the width of a given wide-character string. 570 * Params: 571 * text = the text to measure. 572 * Returns: the width of the string in pixels. 573 */ 574 public int textWidthWc(GdkWChar[] text) 575 { 576 // gint gdk_text_width_wc (GdkFont *font, const GdkWChar *text, gint text_length); 577 return gdk_text_width_wc(gdkFont, text.ptr, cast(int) text.length); 578 } 579 580 /** 581 * Warning 582 * gdk_char_width has been deprecated since version 2.2 and should not be used in newly-written code. Use gdk_text_extents() instead. 583 * Determines the width of a given character. 584 * Params: 585 * character = the character to measure. 586 * Returns: the width of the character in pixels. 587 */ 588 public int charWidth(char character) 589 { 590 // gint gdk_char_width (GdkFont *font, gchar character); 591 return gdk_char_width(gdkFont, character); 592 } 593 594 /** 595 * Warning 596 * gdk_char_width_wc is deprecated and should not be used in newly-written code. 597 * Determines the width of a given wide character. (Encoded 598 * in the wide-character encoding of the current locale). 599 * Params: 600 * character = the character to measure. 601 * Returns: the width of the character in pixels. 602 */ 603 public int charWidthWc(GdkWChar character) 604 { 605 // gint gdk_char_width_wc (GdkFont *font, GdkWChar character); 606 return gdk_char_width_wc(gdkFont, character); 607 } 608 609 /** 610 * Warning 611 * gdk_string_measure is deprecated and should not be used in newly-written code. 612 * Determines the distance from the origin to the rightmost 613 * portion of a nul-terminated string when drawn. This is not the 614 * correct value for determining the origin of the next 615 * portion when drawing text in multiple pieces. 616 * See gdk_string_width(). 617 * Params: 618 * string = the nul-terminated string to measure. 619 * Returns: the right bearing of the string in pixels. 620 */ 621 public int stringMeasure(string string) 622 { 623 // gint gdk_string_measure (GdkFont *font, const gchar *string); 624 return gdk_string_measure(gdkFont, Str.toStringz(string)); 625 } 626 627 /** 628 * Warning 629 * gdk_text_measure is deprecated and should not be used in newly-written code. 630 * Determines the distance from the origin to the rightmost 631 * portion of a string when drawn. This is not the 632 * correct value for determining the origin of the next 633 * portion when drawing text in multiple pieces. 634 * See gdk_text_width(). 635 * Params: 636 * text = the text to measure. 637 * textLength = the length of the text in bytes. 638 * Returns: the right bearing of the string in pixels. 639 */ 640 public int textMeasure(string text, int textLength) 641 { 642 // gint gdk_text_measure (GdkFont *font, const gchar *text, gint text_length); 643 return gdk_text_measure(gdkFont, Str.toStringz(text), textLength); 644 } 645 646 /** 647 * Warning 648 * gdk_char_measure is deprecated and should not be used in newly-written code. 649 * Determines the distance from the origin to the rightmost 650 * portion of a character when drawn. This is not the 651 * correct value for determining the origin of the next 652 * portion when drawing text in multiple pieces. 653 * Params: 654 * character = the character to measure. 655 * Returns: the right bearing of the character in pixels. 656 */ 657 public int charMeasure(char character) 658 { 659 // gint gdk_char_measure (GdkFont *font, gchar character); 660 return gdk_char_measure(gdkFont, character); 661 } 662 663 /** 664 * Warning 665 * gdk_string_height is deprecated and should not be used in newly-written code. 666 * Determines the total height of a given nul-terminated 667 * string. This value is not generally useful, because you 668 * cannot determine how this total height will be drawn in 669 * relation to the baseline. See gdk_string_extents(). 670 * Params: 671 * string = the nul-terminated string to measure. 672 * Returns: the height of the string in pixels. 673 */ 674 public int stringHeight(string string) 675 { 676 // gint gdk_string_height (GdkFont *font, const gchar *string); 677 return gdk_string_height(gdkFont, Str.toStringz(string)); 678 } 679 680 /** 681 * Warning 682 * gdk_text_height is deprecated and should not be used in newly-written code. 683 * Determines the total height of a given string. 684 * This value is not generally useful, because you cannot 685 * determine how this total height will be drawn in 686 * relation to the baseline. See gdk_text_extents(). 687 * Params: 688 * text = the text to measure. 689 * textLength = the length of the text in bytes. 690 * Returns: the height of the string in pixels. 691 */ 692 public int textHeight(string text, int textLength) 693 { 694 // gint gdk_text_height (GdkFont *font, const gchar *text, gint text_length); 695 return gdk_text_height(gdkFont, Str.toStringz(text), textLength); 696 } 697 698 /** 699 * Warning 700 * gdk_char_height has been deprecated since version 2.2 and should not be used in newly-written code. Use gdk_text_extents() instead. 701 * Determines the total height of a given character. 702 * This value is not generally useful, because you cannot 703 * determine how this total height will be drawn in 704 * relation to the baseline. See gdk_text_extents(). 705 * Params: 706 * character = the character to measure. 707 * Returns: the height of the character in pixels. 708 */ 709 public int charHeight(char character) 710 { 711 // gint gdk_char_height (GdkFont *font, gchar character); 712 return gdk_char_height(gdkFont, character); 713 } 714 715 /** 716 * Warning 717 * gdk_wcstombs is deprecated and should not be used in newly-written code. 718 * Converts a wide character string to a multi-byte string. 719 * (The function name comes from an acronym of 'Wide Character String TO 720 * Multi-Byte String'). 721 * Params: 722 * src = a wide character string. 723 * Returns: the multi-byte string corresponding to src, or NULL if the conversion failed. The returned string should be freed with g_free() when no longer needed. 724 */ 725 public static string wcstombs(GdkWChar* src) 726 { 727 // gchar * gdk_wcstombs (const GdkWChar *src); 728 return Str.toString(gdk_wcstombs(src)); 729 } 730 731 /** 732 * Warning 733 * gdk_mbstowcs is deprecated and should not be used in newly-written code. 734 * Converts a multi-byte string to a wide character string. 735 * (The function name comes from an acronym of 'Multi-Byte String TO Wide 736 * Character String'). 737 * Params: 738 * dest = the space to place the converted wide character string into. 739 * src = the multi-byte string to convert, which must be nul-terminated. 740 * destMax = the maximum number of wide characters to place in dest. 741 * Returns: the number of wide characters written into dest, or -1 if the conversion failed. 742 */ 743 public static int mbstowcs(GdkWChar* dest, string src, int destMax) 744 { 745 // gint gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max); 746 return gdk_mbstowcs(dest, Str.toStringz(src), destMax); 747 } 748 }