font.pp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Font.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * This file defines font structures and routines.
  12. *
  13. * History:
  14. * 09/13/94 art Created by Art Lamb.
  15. * 05/05/98 art Add structures for font mapping table.
  16. * 07/03/98 kwk Added FntWidthToOffset.
  17. * 10/23/98 kwk Changed fontMapTable to 0xC000 (was 0xFFFF).
  18. * 10/20/99 kwk Moved private values to FontPrv.h
  19. * 05/12/00 kwk Added FntWCharWidth.
  20. *
  21. *****************************************************************************)
  22. {$MACRO ON}
  23. unit font;
  24. interface
  25. uses palmos, coretraps;
  26. // Pixel width of tab stops in fields
  27. const
  28. fntTabChrWidth = 20;
  29. // Width of character missing from font.
  30. const
  31. fntMissingChar = -1;
  32. type
  33. FontCharInfoType = record
  34. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FONTS} // These fields will not be available in the next OS release!
  35. offset: Int8;
  36. width: Int8;
  37. {$endif}
  38. end;
  39. FontCharInfoTag = FontCharInfoType;
  40. FontCharInfoPtr = ^FontCharInfoType;
  41. type
  42. FontType = record
  43. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FONTS} // These fields will not be available in the next OS release!
  44. fontType: Int16; // font type
  45. firstChar: Int16; // ASCII code of first character
  46. lastChar: Int16; // ASCII code of last character
  47. maxWidth: Int16; // maximum character width
  48. kernMax: Int16; // negative of maximum character kern
  49. nDescent: Int16; // negative of descent
  50. fRectWidth: Int16; // width of font rectangle
  51. fRectHeight: Int16; // height of font rectangle
  52. owTLoc: Int16; // offset to offset/width table
  53. ascent: Int16; // ascent
  54. descent: Int16; // descent
  55. leading: Int16; // leading
  56. rowWords: Int16; // row width of bit image / 2
  57. {$endif}
  58. end;
  59. FontTag = FontType;
  60. FontPtr = ^FontType;
  61. FontTablePtr = ^FontPtr;
  62. type
  63. FontID = Enum;
  64. const
  65. stdFont = $00; // Small font used for the user's writing. Shows a good amount
  66. boldFont = Succ(stdFont); // Small font. Bold for easier reading. Used often for ui.
  67. largeFont = Succ(boldFont); // Larger font for easier reading. Shows a lot less.
  68. symbolFont = Succ(largeFont); // Various ui images like check boxes and arrows
  69. symbol11Font = Succ(symbolFont); // Larger various ui images
  70. symbol7Font = Succ(symbol11Font); // Smaller various ui images
  71. ledFont = Succ(symbol7Font); // Calculator specific font
  72. largeBoldFont = Succ(ledFont); // A thicker version of the large font. More readable.
  73. fntAppFontCustomBase = $80; // First available application-defined font ID
  74. const
  75. checkboxFont = symbol11Font;
  76. function FntIsAppDefined(fnt: FontID): Boolean;
  77. //--------------------------------------------------------------------
  78. //
  79. // Font Function
  80. //
  81. //--------------------------------------------------------------------
  82. function FntGetFont: FontID; syscall sysTrapFntGetFont;
  83. function FntSetFont(font: FontID): FontID; syscall sysTrapFntSetFont;
  84. function FntGetFontPtr: FontPtr; syscall sysTrapFntGetFontPtr;
  85. function FntBaseLine: Int16; syscall sysTrapFntBaseLine;
  86. function FntCharHeight: Int16; syscall sysTrapFntCharHeight;
  87. function FntLineHeight: Int16; syscall sysTrapFntLineHeight;
  88. function FntAverageCharWidth: Int16; syscall sysTrapFntAverageCharWidth;
  89. function FntCharWidth(ch: Char): Int16; syscall sysTrapFntCharWidth;
  90. function FntWCharWidth(iChar: WChar): Int16; syscall sysTrapFntWCharWidth;
  91. function FntCharsWidth(const chars: PChar; len: Int16): Int16; syscall sysTrapFntCharsWidth;
  92. function FntWidthToOffset(const pChars: PChar; length: UInt16; pixelWidth: Int16; var leadingEdge: Boolean; var truncWidth: Int16): Int16; syscall sysTrapFntWidthToOffset;
  93. procedure FntCharsInWidth(const AString: PChar; var stringWidthP, stringLengthP: Int16;
  94. var fitWithinWidth: Boolean); syscall sysTrapFntCharsInWidth;
  95. function FntDescenderHeight: Int16; syscall sysTrapFntDescenderHeight;
  96. function FntLineWidth(const pChars: PChar; length: UInt16): Int16; syscall sysTrapFntLineWidth;
  97. function FntWordWrap(const chars: PChar; maxWidth: UInt16): UInt16; syscall sysTrapFntWordWrap;
  98. procedure FntWordWrapReverseNLines(const chars: PChar; maxWidth: UInt16; var linesToScrollP, scrollPosP: UInt16); syscall sysTrapFntWordWrapReverseNLines;
  99. procedure FntGetScrollValues(const chars: PChar; width, scrollPos: UInt16; var linesP, topLine: UInt16); syscall sysTrapFntGetScrollValues;
  100. function FntDefineFont(font: FontID; fontP: FontPtr): Err; syscall sysTrapFntDefineFont;
  101. implementation
  102. function FntIsAppDefined(fnt: FontID): Boolean;
  103. begin
  104. FntIsAppDefined := fnt >= fntAppFontCustomBase;
  105. end;
  106. end.