浏览代码

initial @:font support (work in progress)

Simon Krajewski 12 年之前
父节点
当前提交
46c31f248b
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      genswf.ml

+ 15 - 0
genswf.ml

@@ -812,6 +812,21 @@ let build_swf9 com file swc =
 		| TClassDecl c ->
 		| TClassDecl c ->
 			let rec loop = function
 			let rec loop = function
 				| [] -> acc
 				| [] -> acc
+				| (":font",[EConst (String file),p],_) :: l ->
+					let ch = try open_in_bin file with _ -> error "File not found" p in
+					let ttf = Ttf.parse ch in
+					close_in ch;
+					let ttf_swf = Ttf.write_swf ttf "" in
+					let ch = IO.output_string () in
+					let b = IO.output_bits ch in
+					Ttf.write_font2 ch b ttf_swf;
+					let data = IO.close_out ch in
+					incr cid;
+					classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes;
+					tag (TFont3 {
+						cd_id = !cid;
+						cd_data = data;
+					}) :: loop l
 				| (":bitmap",[EConst (String file),p],_) :: l ->
 				| (":bitmap",[EConst (String file),p],_) :: l ->
 					let data = load_file_data file p in
 					let data = load_file_data file p in
 					incr cid;
 					incr cid;