HostFonts.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. MODULE HostFonts;
  2. (* for Texts, HostTextConv *)
  3. IMPORT Fonts;
  4. CONST
  5. defTypeface = "*";
  6. defSize = 12 * Fonts.point;
  7. defW = 161925;
  8. defAsc = 142875;
  9. defDsc = 28575;
  10. TYPE
  11. Font = POINTER TO RECORD (Fonts.Font)
  12. alias-: Fonts.Typeface; (* alias # typeface & typeface # "*" == alien font *)
  13. END;
  14. Directory = POINTER TO RECORD (Fonts.Directory) END;
  15. VAR
  16. defFont-: Font; (* for HostTextConv *)
  17. ti: Fonts.TypefaceInfo;
  18. dir: Directory;
  19. PROCEDURE (f: Font) GetBounds (OUT asc, dsc, w: INTEGER);
  20. BEGIN
  21. asc := defAsc;
  22. dsc := defDsc;
  23. w := defW
  24. END GetBounds;
  25. PROCEDURE (f: Font) StringWidth (IN s: ARRAY OF CHAR): INTEGER;
  26. BEGIN
  27. RETURN LEN(s$) * defW
  28. END StringWidth;
  29. PROCEDURE (f: Font) SStringWidth (IN s: ARRAY OF SHORTCHAR): INTEGER;
  30. BEGIN
  31. RETURN LEN(s$) * defW
  32. END SStringWidth;
  33. PROCEDURE (f: Font) IsAlien (): BOOLEAN;
  34. BEGIN
  35. RETURN TRUE
  36. END IsAlien;
  37. PROCEDURE (d: Directory) This (typeface: Fonts.Typeface; size: INTEGER; style: SET; weight: INTEGER): Font;
  38. BEGIN
  39. RETURN defFont
  40. END This;
  41. PROCEDURE (d: Directory) Default (): Font;
  42. BEGIN
  43. RETURN defFont
  44. END Default;
  45. PROCEDURE (d: Directory) TypefaceList (): Fonts.TypefaceInfo;
  46. BEGIN
  47. RETURN ti
  48. END TypefaceList;
  49. PROCEDURE Init;
  50. BEGIN
  51. NEW(defFont);
  52. defFont.Init(defTypeface, defSize, {}, Fonts.normal);
  53. defFont.alias := "Arial";
  54. NEW(ti);
  55. ti.typeface := defTypeface;
  56. NEW(dir); Fonts.SetDir(dir)
  57. END Init;
  58. BEGIN
  59. Init
  60. END HostFonts.