home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / facesos2.zip / faces-os2.el next >
Lisp/Scheme  |  1994-01-26  |  4KB  |  108 lines

  1. ;; faces-os2.el
  2. ;;
  3. ;; makes bold and italic fonts work with OS/2 font specifications..
  4. ;; you don't have to use the portable character representation
  5. ;;
  6. ;; try this with hilit19.el, or hl319.el, or some other
  7. ;; code for fontifying your emacs 19.
  8. ;;
  9. ;; Version 1.0 - 1/24/94 - original public release
  10. ;; 
  11. ;; written by John-Marc Chandonia (chandoni@husc.harvard.edu)
  12. ;; please send suggestions and bug fixes!  Especially code.
  13. ;; 
  14. ;; THIS FILE IS RELEASED INTO THE PUBLIC DOMAIN
  15. ;; USE AT YOUR OWN RISK!
  16. ;;
  17. ;; To install, load "faces-os2.el" somewhere after "faces.el"
  18. ;;
  19. ;; The easiest way to do this is to put
  20. ;; (require 'faces-os2)
  21. ;; somewhere in your .emacs file
  22. ;;
  23. ;; you can also put this line in your ~emacs/lisp/term/pm-win.el,
  24. ;; right after the (require 'faces) line
  25. ;;
  26. ;; I have tested this with EM's port of Emacs 19.22; it probably
  27. ;; works with every version >= 19.19.
  28. ;; 
  29. ;; BUGS:
  30. ;;
  31. ;; * probably doesn't work right with bold-italic fonts
  32. ;; * fonts don't always look good.  i.e. for italic fonts,
  33. ;;   should have a routine to choose the next smallest bitmapped
  34. ;;   italic font.
  35. ;; * simulated fonts are too slow, but look better.  Should make
  36. ;;   it a user option which to try first.
  37. ;;   an example of a simulated font is "10.italic.Courier"
  38. ;;   the os/2 font is "10.Courier Italic"
  39.  
  40.  
  41. (defun pm-make-font-bold (font)
  42.   "Given a PM font specification (i.e 10.Courier), make a
  43. bold version of it.  If impossible, return nil.  Uses simulated
  44. bold fonts instead of os2's bold fonts; I think they look nicer."
  45.   (if (string-match "bold" font) 
  46.       font ;; make sure we aren't already in the appropriate font
  47. ;;    (let ((os2font (concat font " bold")))
  48.       ;; look for a font in the os/2 naming style
  49. ;;      (if (pm-list-fonts os2font) 
  50. ;;      os2font
  51.     ;; else, try to simulate the font
  52.     (if (string-match "\\." font)
  53.         (let ((simfont (concat (substring font 0 (match-beginning 0))
  54.                    ".bold."
  55.                    (substring font (match-end 0)))))
  56.           (if (pm-list-fonts simfont) simfont nil)))))
  57. ;; ))
  58.  
  59.  
  60. (defun pm-make-font-italic (font)
  61.   "Given a PM font specification (i.e 10.Courier), make an
  62. italic version of it.  If impossible, return nil."
  63.   (if (string-match "italic" font) 
  64.       font ;; make sure we aren't already in the appropriate font
  65.     (let ((os2font (concat font " Italic")))
  66.       ;; look for a font in the os/2 naming style
  67.       (if (pm-list-fonts os2font) 
  68.       os2font
  69.     ;; else, try to simulate the font
  70.     (if (string-match "\\." font)
  71.         (let ((simfont (concat (substring font 0 (match-beginning 0))
  72.                    ".italic."
  73.                    (substring font (match-end 0)))))
  74.           (if (pm-list-fonts simfont) simfont nil)))))))
  75.  
  76. (defun pm-make-font-unbold (font)
  77.   "Given a bold PM font spec (i.e. 10.Courier Bold or 10.bold.Courier,
  78. make a nonbold version of it.  If impossible, return nil."
  79.   (if (string-match " Bold" font)
  80.       (let ((nfont (substring font 0 (match-beginning 0))))
  81.     (if (pm-list-fonts nfont) nfont nil))
  82.     (if (string-match "\\.bold\\." font)
  83.     (let ((nfont (concat (substring font 0 (match-beginning 0))
  84.                   "."
  85.                   (substring font (match-end 0)))))
  86.       (if (pm-list-fonts nfont) nfont nil))
  87.       font)))
  88.  
  89. (defun pm-make-font-unitalic (font)
  90.   "Given a italic PM font spec (i.e. 10.Courier Italic or
  91. 10.italic.Courier, make a nonbold version of it.
  92. If impossible, return nil."
  93.   (if (string-match " Italic" font)
  94.       (let ((nfont (substring font 0 (match-beginning 0))))
  95.     (if (pm-list-fonts nfont) nfont nil))
  96.     (if (string-match "\\.italic\\." font)
  97.     (let ((nfont (concat (substring font 0 (match-beginning 0))
  98.                  "."
  99.                  (substring font (match-end 0)))))
  100.       (if (pm-list-fonts nfont) nfont nil)))
  101.     font))
  102.  
  103. (defalias 'x-make-font-bold 'pm-make-font-bold)
  104. (defalias 'x-make-font-unbold 'pm-make-font-unbold)
  105. (defalias 'x-make-font-italic 'pm-make-font-italic)
  106. (defalias 'x-make-font-italic 'pm-make-font-italic)
  107.  
  108. (provide 'faces-os2)