diff --git a/CHANGES.md b/CHANGES.md index 85aba34188..013bf65f54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Changed: - Mute SDL startup messages (#2913). - `int` can optionally raises an error when passing `nan` or `infinity`, `int(infinity)` now returns `max_int` and `int(-infinity)` returns `min_int`. (#3407) +- Made default font a setting (#3507) - Changed internal metadata format to be immutable (#3297). - Allow a getter for the offset of `on_offset` and dropped the metadata mechanism for updating it (#3355). diff --git a/src/core/builtins/builtins_sys.ml b/src/core/builtins/builtins_sys.ml index 29f9ee8941..c12b6d5a8c 100644 --- a/src/core/builtins/builtins_sys.ml +++ b/src/core/builtins/builtins_sys.ml @@ -38,7 +38,6 @@ let () = ("bindir", "Internal script directory", Configure.bin_dir ()); ("rundir", "PID file directory", Configure.rundir ()); ("logdir", "logging directory", Configure.logdir ()); - ("default_font", "default font file", Configure.default_font); ] (** Liquidsoap stuff *) diff --git a/src/core/configure.ml b/src/core/configure.ml index 9d0d0c4c8a..7ccd23188e 100644 --- a/src/core/configure.ml +++ b/src/core/configure.ml @@ -5,11 +5,19 @@ include Liquidsoap_paths let git_snapshot = git_sha <> None let requests_max_id = 50 let requests_table_size = 50 -let default_font = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" (** General configuration *) let conf = Dtools.Conf.void "Liquidsoap configuration" +let conf_default_font = + Dtools.Conf.string + ~d: + (match (Sys.os_type, Build_config.system) with + | _, "macosx" -> "/System/Library/Fonts/Times.ttc" + | "Win32", _ -> {|C:\\Windows\WinSxS\calibri.ttf|} + | _ -> "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf") + ~p:(conf#plug "default_font") "Default font" + let libs_versions () = Build_info.V1.Statically_linked_libraries.to_list () |> List.map (fun lib -> diff --git a/src/core/configure.mli b/src/core/configure.mli index 2a641284bb..ddf01af06b 100644 --- a/src/core/configure.mli +++ b/src/core/configure.mli @@ -4,6 +4,7 @@ val conf : Dtools.Conf.ut val conf_init : Dtools.Conf.ut val conf_debug : bool Dtools.Conf.t val conf_debug_errors : bool Dtools.Conf.t +val conf_default_font : string Dtools.Conf.t (** String describing the OS *) val host : string @@ -26,9 +27,6 @@ val bin_dir : unit -> string (** Standard path. *) val path : unit -> string list -(** Default font file *) -val default_font : string - (** Maximal id for a request. *) val requests_max_id : int diff --git a/src/core/decoder/text/video_text_native.ml b/src/core/decoder/text/video_text_native.ml index f50b467a54..74d6a06467 100644 --- a/src/core/decoder/text/video_text_native.ml +++ b/src/core/decoder/text/video_text_native.ml @@ -25,7 +25,7 @@ open Mm let log = Log.make ["video"; "text"; "native"] let render_text ~font ~size text = - if font <> Configure.default_font then + if font <> Configure.conf_default_font#get then log#important "video.text.native does not support custom fonts yet!"; let () = ignore font in let font = Image.Bitmap.Font.native in diff --git a/src/core/decoder/text/video_text_sdl.ml b/src/core/decoder/text/video_text_sdl.ml index a410883010..83d417abaf 100644 --- a/src/core/decoder/text/video_text_sdl.ml +++ b/src/core/decoder/text/video_text_sdl.ml @@ -29,7 +29,7 @@ let init () = Sdl_utils.check Tsdl_ttf.Ttf.init () let get_font font size = - let font = if font = "" then Configure.default_font else font in + let font = if font = "" then Configure.conf_default_font#get else font in try Sdl_utils.check (Ttf.open_font font) size with e -> raise diff --git a/src/core/sources/video_text.ml b/src/core/sources/video_text.ml index a9afe65859..97c78a3b07 100644 --- a/src/core/sources/video_text.ml +++ b/src/core/sources/video_text.ml @@ -96,7 +96,7 @@ let register name init render_text = Some Lang.null, Some (Printf.sprintf "Path to ttf font file (default is `\"%s\"`)." - Configure.default_font) ); + Configure.conf_default_font#get) ); ("size", Lang.getter_t Lang.int_t, Some (Lang.int 18), Some "Font size."); ( "color", Lang.getter_t Lang.int_t, @@ -113,7 +113,7 @@ let register name init render_text = let ttf = List.assoc "font" p |> Lang.to_option |> Option.map Lang.to_string_getter - |> Option.value ~default:(fun () -> Configure.default_font) + |> Option.value ~default:(fun () -> Configure.conf_default_font#get) in let ttf_size = List.assoc "size" p |> Lang.to_int_getter in let color = List.assoc "color" p |> Lang.to_int_getter in diff --git a/src/libs/liquidsoap.liq b/src/libs/liquidsoap.liq index b512da700a..0b500ad451 100644 --- a/src/libs/liquidsoap.liq +++ b/src/libs/liquidsoap.liq @@ -23,7 +23,7 @@ def liquidsoap.chroot.make(chroot) = cp(configure.libdir) cp(configure.bindir) - if file.exists(configure.default_font) then cp(configure.default_font) end + if file.exists(settings.default_font()) then cp(settings.default_font()) end mkdir(chroot(configure.logdir)) mkdir(chroot(configure.rundir)) cp(liquidsoap.executable)