











open Compatibility;;
open Types;;
open Default;;
open Exceptions;;
open Basic_types;;

(**************************************************************************)
(* $Id: font.ml,v 1.2 1997/04/17 19:40:04 doub Exp $                      *)
(* Creation and manipulation of fonts                                     *)
(**************************************************************************)

(* Font style *************************************************************)

(* new_complete_font :
   string -> bool -> string list -> string -> bool -> float -> float
-> string -> bool -> fontStyle *)
let new_complete_font family horizontal justify language
                      left2right size spacing style top2bottom =
    { family        = family ;
      horizontal    = horizontal ;
      justify       = justify ;
      language      = language ;
      left_to_right = left2right ;
      size          = size ;
      spacing       = spacing ;
      style         = style ;
      top_to_bottom = top2bottom }
;;

(* new_font : string -> float -> string -> fontStyle *)
let new_font family size style =
    let d = default_fontStyle
    in
       new_complete_font family d.horizontal d.justify
                         d.language d.left_to_right size
                         d.spacing style d.top_to_bottom
;;

(* setf_family : fontStyle -> string -> fontStyle *)
let setf_family font family =
    new_complete_font family 
                      font.horizontal font.justify font.language
                      font.left_to_right font.size font.spacing
                      font.style font.top_to_bottom
;; 

(* setf_horizontal : fontStyle -> bool -> fontStyle *)
let setf_horizontal font horizontal = 
    new_complete_font font.family horizontal font.justify
                      font.language font.left_to_right font.size
                      font.spacing font.style font.top_to_bottom
;;

(* setf_justify : fontStyle -> string list -> fontStyle *)
let setf_justify font justify =
    new_complete_font font.family font.horizontal
                      justify
                      font.language font.left_to_right font.size
                      font.spacing font.style font.top_to_bottom
;;

(* setf_language : fontStyle -> string -> fontStyle *)
let setf_language font language =
    new_complete_font font.family font.horizontal font.justify
                      language
                      font.left_to_right font.size font.spacing
                      font.style font.top_to_bottom
;;

(* setf_left_to_right : fontStyle -> bool -> fontStyle *)
let setf_left_to_right font left2right =
    new_complete_font font.family font.horizontal font.justify
                      font.language left2right
                      font.size font.spacing font.style
                      font.top_to_bottom
;;

(* setf_size : fontStyle -> float -> fontStyle *)
let setf_size font size =
    new_complete_font font.family font.horizontal font.justify
                      font.language font.left_to_right size
                      font.spacing font.style font.top_to_bottom
;;

(* setf_spacing : fontStyle -> float -> fontStyle *)
let setf_spacing font spacing =
    new_complete_font font.family font.horizontal font.justify
                      font.language font.left_to_right font.size
                      spacing font.style font.top_to_bottom
;;

(* setf_style : fontStyle -> string -> fontStyle *)
let setf_style font style =
    new_complete_font font.family font.horizontal font.justify
                      font.language font.left_to_right font.size
                      font.spacing style font.top_to_bottom
;;

(* setf_top_to_bottom : fontStyle -> bool -> fontStyle *)
let setf_top_to_bottom font top2bottom =
    new_complete_font font.family font.horizontal font.justify
                      font.language font.left_to_right font.size
                      font.spacing font.style top2bottom
;;


let serif       = "SERIF" ;;
let sans_serif  = "SANS" ;;
let typewriter  = "TYPEWRITER" ;;
let plain       = "PLAIN" ;;
let bold        = "BOLD" ;;
let italic      = "ITALIC" ;;
let bold_italic = "BOLDITALIC" ;;

(* set_font_family : fontStyle -> string -> fontStyle *)
let set_font_family = setf_family ;;

(* set_font_size : fontStyle -> float -> fontStyle *)
let set_font_size = setf_size ;;

(* set_font_style : fontStyle -> string -> fontStyle *)
let set_font_style = setf_style ;;
