4.2 Using fonts
stringbltprint onto a bitmap a single character and a string respectively. You can specify the font that is used for the character or string.
Print text in some alternate fonts. You might have to load these fonts first for this example to work.
(clear-bitmap *window*) ;; Use the default font first. (stringblt *window* (make-position 20 20) *default-font* "Default Font")Define a function that prints the contents of a font on a window by using the function
;; Use a roman font. (stringblt *window* (make-position 20 40) (find-font "BOLD-ROMAN") "Bold Roman")
;; Use an italic font. (stringblt *window* (make-position 20 60) (find-font "ITALIC") "ITALIC")
(defun show-font (window font) (let ((font (find-font font))) (if font ; Check to see that the font exists. (let ((window-width (region-width (window-inside-region window))) (window-height (region-height (window-inside-region window))) (font-width (font-fixed-width font)) (font-height (font-height font))) (clear-bitmap window) ;; iterate over the characters in this font. (loop for char-number from 0 to (font-code-limit font) with window-x = 0 with window-y = font-height do (charblt ; Print the character. window (make-position window-x window-y) font (character char-number)) if (>= (+ window-x (* font-width 2)) window-width) do (progn (setq window-x 0) (setq window-y (+ window-y font-height))) else do (setq window-x (+ window-x font-width)))) (format t "Sorry, this font is not loaded.~%"))))Some fonts contain nonprinting characters that have special bit settings and that do not look like normal characters. Nonprinting character sometimes appear as blocks and lines when you display a font.
;; Invoke the function with the default font. (show-font *window* *default-font*)
;; Now try another font. (show-font *window* "BOLD-ROMAN")
Generated with Harlequin WebMaker