瀏覽代碼

[flash] sidestep mxmlc bug with incorrect handling of embedded font names when compiling haxe-generated swcs into a final swf

looks like mxmlc expects the string to be null-terminated, even tho the spec says it's length-prefixed...
for the flash player it seems that there is no difference, since it can handle length-prefixed null-terminated strings ¯\_(ツ)_/¯

this adds an extra byte per embedded font in the output, but oh well
Dan Korostelev 4 年之前
父節點
當前提交
727d882a1d
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      libs/ttflib/tTFSwfWriter.ml

+ 2 - 1
libs/ttflib/tTFSwfWriter.ml

@@ -162,8 +162,9 @@ let write_font2 ch b f2 =
 	IO.write_bits b 1 (bi f2.font_is_italic);
 	IO.write_bits b 1 (bi f2.font_is_bold);
 	IO.write_byte ch (int_from_langcode f2.font_language);
-	IO.write_byte ch (String.length f2.font_name);
+	IO.write_byte ch ((String.length f2.font_name) + 1);
 	IO.nwrite_string ch f2.font_name;
+	IO.write_byte ch 0;
 	IO.write_ui16 ch (Array.length f2.font_glyphs);
 	let glyph_offset = ref (((Array.length f2.font_glyphs) * 4)+4) in
 	Array.iter (fun g ->