diskfont.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. MorphOS version (c) 2015 by Karoly Balogh
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$PACKRECORDS 2}
  14. unit diskfont;
  15. INTERFACE
  16. uses exec, agraphics, utility;
  17. Const
  18. MAXFONTPATH = 256;
  19. Type
  20. pFontContents = ^tFontContents;
  21. tFontContents = record
  22. fc_FileName : Array [0..MAXFONTPATH-1] of Char;
  23. fc_YSize : Word;
  24. fc_Style : Byte;
  25. fc_Flags : Byte;
  26. end;
  27. pTFontContents = ^tTFontContents;
  28. tTFontContents = record
  29. tfc_FileName : Array[0..MAXFONTPATH-3] of Char;
  30. tfc_TagCount : Word;
  31. tfc_YSize : Word;
  32. tfc_Style,
  33. tfc_Flags : Byte;
  34. END;
  35. Const
  36. FCH_ID = $0f00;
  37. TFCH_ID = $0f02;
  38. OFCH_ID = $0f03;
  39. Type
  40. pFontContentsHeader = ^tFontContentsHeader;
  41. tFontContentsHeader = record
  42. fch_FileID : Word;
  43. fch_NumEntries : Word;
  44. end;
  45. Const
  46. DFH_ID = $0f80;
  47. MAXFONTNAME = 32;
  48. Type
  49. pDiskFontHeader = ^tDiskFontHeader;
  50. tDiskFontHeader = record
  51. dfh_DF : tNode;
  52. dfh_FileID : Word;
  53. dfh_Revision : Word;
  54. dfh_Segment : Longint;
  55. dfh_Name : Array [0..MAXFONTNAME-1] of Char;
  56. dfh_TF : tTextFont;
  57. end;
  58. Const
  59. AFB_MEMORY = 0;
  60. AFF_MEMORY = 1;
  61. AFB_DISK = 1;
  62. AFF_DISK = 2;
  63. AFB_SCALED = 2;
  64. AFF_SCALED = $0004;
  65. AFB_BITMAP = 3;
  66. AFF_BITMAP = $0008;
  67. AFB_TAGGED = 16;
  68. AFF_TAGGED = $10000;
  69. Type
  70. pAvailFonts = ^tAvailFonts;
  71. tAvailFonts = record
  72. af_Type : Word;
  73. af_Attr : tTextAttr;
  74. end;
  75. pTAvailFonts = ^tTAvailFonts;
  76. tTAvailFonts = record
  77. taf_Type : Word;
  78. taf_Attr : tTTextAttr;
  79. END;
  80. pAvailFontsHeader = ^tAvailFontsHeader;
  81. tAvailFontsHeader = record
  82. afh_NumEntries : Word;
  83. end;
  84. const
  85. DISKFONTNAME : PChar = 'diskfont.library';
  86. VAR DiskfontBase : pLibrary;
  87. FUNCTION AvailFonts(buffer : pCHAR location 'a0'; bufBytes : LONGINT location 'd0'; flags : LONGINT location 'd1') : LONGINT; syscall DiskfontBase 036;
  88. PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader location 'a1'); syscall DiskfontBase 048;
  89. FUNCTION NewFontContents(fontsLock : BPTR location 'a0'; fontName : pCHAR location 'a1') : pFontContentsHeader; syscall DiskfontBase 042;
  90. FUNCTION NewScaledDiskFont(sourceFont : pTextFont location 'a0'; destTextAttr : pTextAttr location 'a1') : pDiskFontHeader; syscall DiskfontBase 054;
  91. FUNCTION OpenDiskFont(textAttr : pTextAttr location 'a0') : pTextFont; syscall DiskfontBase 030;
  92. { MorphOS actually supports these V45+ calls }
  93. FUNCTION GetDiskFontCtrl(tagid : LONGINT location 'd0') : LONGINT; syscall DiskfontBase 060;
  94. PROCEDURE SetDiskFontCtrlA(taglist : pTagItem location 'a0'); syscall DiskfontBase 066;
  95. function InitDISKFONTLibrary: boolean;
  96. IMPLEMENTATION
  97. const
  98. { Change VERSION and LIBVERSION to proper values }
  99. VERSION : string[2] = '0';
  100. LIBVERSION : longword = 0;
  101. var
  102. diskfont_exit : Pointer;
  103. procedure CloseDiskFontLibrary;
  104. begin
  105. ExitProc := diskfont_exit;
  106. if DiskFontBase <> nil then begin
  107. CloseLibrary(DiskFontBase);
  108. DiskFontBase := nil;
  109. end;
  110. end;
  111. function InitDiskFontLibrary: boolean;
  112. begin
  113. DiskFontBase := nil;
  114. DiskFontBase := OpenLibrary(DISKFONTNAME,LIBVERSION);
  115. if DiskFontBase <> nil then begin
  116. diskfont_exit := ExitProc;
  117. ExitProc := @CloseDiskFontLibrary;
  118. InitDiskFontLibrary := true;
  119. end else begin
  120. InitDiskFontLibrary := false;
  121. end;
  122. end;
  123. END.