home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / graphics / text / ShowDefaultFont.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  2.5 KB  |  63 lines

  1. /* ShowDefaultFont
  2.    An example that prints the name and size of the default font.
  3.    Insert this routine into the "wrapper" code at the end of the chapter.
  4.  
  5.    Copyright (c) 1990 Commodore-Amiga, Inc.
  6.   
  7.    This example is provided in electronic form by Commodore-Amiga, Inc. for
  8.    use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  9.    The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  10.    information on the correct usage of the techniques and operating system
  11.    functions presented in this example.  The source and executable code of
  12.    this example may only be distributed in free electronic form, via bulletin
  13.    board or as part of a fully non-commercial and freely redistributable
  14.    diskette.  Both the source and executable code (including comments) must
  15.    be included, without modification, in any copy.  This example may not be
  16.    published in printed form or distributed with any commercial product.
  17.    However, the programming techniques and support routines set forth in
  18.    this example may be used in the development of original executable
  19.    software products for Commodore Amiga computers.
  20.    All other rights reserved.
  21.    This example is provided "as-is" and is subject to change; no warranties
  22.    are made.  All use is at your own risk.  No liability or responsibility
  23.    is assumed.
  24. */
  25.  
  26.  
  27. BOOL example(struct Window *window)
  28. {
  29. UBYTE textNum[6];    /*  A temporary buffer.  */
  30. struct TextAttr textAttr;
  31. struct RastPort *rastPort = window->RPort;
  32. SHORT indentLeft = window->BorderLeft, indentTop = window->BorderTop;
  33.  
  34. TITLE(window, "This Window's default font");
  35. SetAPen(rastPort, COLOR1);    /*  Set the pen color.  */
  36.  
  37. /*  AskFont() will fill textAttr with the default font's attributes.  */
  38. AskFont(rastPort, &textAttr);
  39.  
  40. /*  Move the pen's current position such that the characters
  41.     will be rendered below the Window's top border.
  42. */
  43. Move(rastPort, indentLeft, indentTop + rastPort->TxBaseline);
  44.  
  45. /*  Render this string (which is 20 characters long).  */
  46. Text(rastPort, "The default font is ", 20);
  47.  
  48. /*  The pen's cp_y has been updated to where the last rendering finished.
  49.     If we don't Move() it, the next string will continue from there.
  50. */
  51. Text(rastPort, textAttr.ta_Name, strlen(textAttr.ta_Name));
  52.  
  53. /*  Use sprintf() to copy the numeric value to a string buffer.  */
  54. sprintf(textNum, ", %d", textAttr.ta_YSize);
  55. Text(rastPort, textNum, strlen(textNum));
  56.  
  57. Text(rastPort, " pixels high.", 13);
  58.  
  59. /*  Wait for the user to click in the close gadget before returning.  */
  60. return(WAIT_FOR_CLOSE);
  61. }
  62.  
  63.