|
@@ -276,12 +276,14 @@ let build_swf9 com file swc =
|
|
|
let ttf = try TTFParser.parse ch with e -> abort ("Error while parsing font " ^ file ^ " : " ^ Printexc.to_string e) p in
|
|
|
close_in ch;
|
|
|
let get_string e = match fst e with
|
|
|
- | EConst (String s) -> Some s
|
|
|
+ | EConst (String s) -> s
|
|
|
| _ -> raise Not_found
|
|
|
in
|
|
|
let ttf_config = {
|
|
|
ttfc_range_str = "";
|
|
|
ttfc_font_name = None;
|
|
|
+ ttfc_font_weight = TFWRegular;
|
|
|
+ ttfc_font_posture = TFPNormal;
|
|
|
} in
|
|
|
begin match args with
|
|
|
| (EConst (String str),_) :: _ -> ttf_config.ttfc_range_str <- str;
|
|
@@ -291,8 +293,19 @@ let build_swf9 com file swc =
|
|
|
| _ :: [e] ->
|
|
|
begin match fst e with
|
|
|
| EObjectDecl fl ->
|
|
|
- begin try ttf_config.ttfc_font_name <- get_string (Expr.field_assoc "fontName" fl)
|
|
|
- with Not_found -> () end
|
|
|
+ (try ttf_config.ttfc_font_name <- Some(get_string (Expr.field_assoc "fontName" fl)) with Not_found -> ());
|
|
|
+ (try ttf_config.ttfc_font_weight <- (
|
|
|
+ match get_string (Expr.field_assoc "fontWeight" fl) with
|
|
|
+ | "regular" -> TFWRegular
|
|
|
+ | "bold" -> TFWBold
|
|
|
+ | _ -> abort "Invalid fontWeight value. Must be `regular` or `bold`." p
|
|
|
+ ) with Not_found -> ());
|
|
|
+ (try ttf_config.ttfc_font_posture <- (
|
|
|
+ match get_string (Expr.field_assoc "fontStyle" fl) with
|
|
|
+ | "normal" -> TFPNormal
|
|
|
+ | "italic" -> TFPItalic
|
|
|
+ | _ -> abort "Invalid fontStyle value. Must be `normal` or `italic`." p
|
|
|
+ ) with Not_found -> ());
|
|
|
| _ ->
|
|
|
()
|
|
|
end
|