{"id":330,"date":"2008-07-03T12:49:48","date_gmt":"2008-07-03T03:49:48","guid":{"rendered":"http:\/\/hangunsworld.com\/blog\/?p=330"},"modified":"2008-07-05T12:14:37","modified_gmt":"2008-07-05T03:14:37","slug":"runtime-font-sharing","status":"publish","type":"post","link":"http:\/\/hangunsworld.com\/blog\/330","title":{"rendered":"Runtime font sharing."},"content":{"rendered":"<div class=\"korean\">\uc6b0\uc120 \uacf5\uc720\ud558\ub824\ub294 \ud3f0\ud2b8\ub97c \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0 \ub4f1\ub85d\ud558\uace0, \uc544\ub798 \uadf8\ub9bc\uacfc \uac19\uc774 \uc124\uc815\ud55c \ub2e4\uc74c SWF\uc744 \ud37c\ube14\ub9ac\uc2dc \ud569\ub2c8\ub2e4.<\/div>\n<div class=\"english\">First, register a font in the library, and set the linkage properties like the following image. Then, publish the SWF file.<\/div>\n<div class=\"japanese\">\u307e\u305a\u3001\u5171\u6709\u3057\u3088\u3046\u3068\u3059\u308b\u30d5\u30a9\u30f3\u30c8\u3092\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u767b\u9332\u3057\u3001\u4e0b\u306e\u30a4\u30e1\u30fc\u30b8\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3001SWF\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u7248\u3057\u307e\u3059\u3002<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hangunsworld.com\/blog\/wp-content\/uploads\/2008\/07\/sharefont1.jpg\" alt=\"Sharing a font\" title=\"sharefont1\" width=\"250\" height=\"227\" class=\"alignnone size-full wp-image-331\" \/><\/p>\n<div class=\"korean\">\uc774 SWF\ud30c\uc77c\uc744 Loader \uac1d\uccb4\ub85c \ub85c\ub4dc\ud55c \ub2e4\uc74c, \uc544\ub798 \ucf54\ub4dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \uacf5\uc720\ub41c \ud3f0\ud2b8\ub97c \ub4f1\ub85d, \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. <\/div>\n<div class=\"english\">Load the SWF via Loader object, then you can retrieve the shared font from the loaded SWF.<\/div>\n<div class=\"japanese\">\u3053\u306eSWF\u30d5\u30a1\u30a4\u30eb\u3092Loader\u5ba2\u4f53\u3092\u901a\u3058\u3066\u30ed\u30fc\u30c9\u3057\u305f\u5f8c\u3067\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3001\u5171\u6709\u3055\u308c\u305f\u30d5\u30a9\u30f3\u30c8\u3092\u767b\u9332\u3057\u3001\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/div>\n<pre lang=\"actionscript3\">var sharedFont:Class = font_loader.contentLoaderInfo.applicationDomain.getDefinition(\"Gothic\") as Class;\r\nFont.registerFont(sharedFont);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/hangunsworld.com\/blog\/wp-content\/uploads\/2008\/07\/sharefont2.jpg\" alt=\"Using the shared font.\" title=\"sharefont2\" width=\"221\" height=\"137\" class=\"alignnone size-full wp-image-332\" \/><\/p>\n<div class=\"korean\">\uadf8\ub7ec\ub098 \uc5ec\uae30\uc11c \ud55c \uac00\uc9c0 \ubb38\uc81c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uac19\uc740 \ub3c4\uba54\uc778\uc758 \uacbd\uc6b0 \uc0c1\uad00\uc774 \uc5c6\uc73c\ub098, \uc11c\ub85c \ub2e4\ub978 \ub3c4\uba54\uc778\uc5d0\uc11c\ub294 SWF\uac00 \ub85c\ub4dc\ub418\uc5c8\ub2e4 \ud558\ub354\ub77c\ub3c4, ApplicationDomain.getDefinition() \uba54\uc18c\ub4dc\ub97c \ud1b5\ud574 \ud3f0\ud2b8\ub97c \uac00\uc838\uc62c \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc989, www.mydomain.com\uc758 SWF\uc5d0\uc11c font.mydomain.com\uc758 SWF\ud30c\uc77c\uc5d0 \uc815\uc758\ub41c \ud3f0\ud2b8\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574\uc11c\ub294 LoaderContext.securityDomain \uc18d\uc131\uc744 \uc0ac\uc6a9\ud558\uc5ec, \ub2e4\ub978 \ub3c4\uba54\uc778\uc758 SWF \uc0ac\uc774\uc5d0\uc11c \uc790\uc6d0\uc5d0 \ub300\ud55c \uc811\uadfc\uc744 \ud5c8\uc6a9\ud560 \ud544\uc694\uac00 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc758 \ucf54\ub4dc\ub294 LoaderContext\ub97c \uc0ac\uc6a9\ud558\uc5ec \ub2e4\ub978 \ub3c4\uba54\uc778 \uc0ac\uc774\uc5d0 \ud3f0\ud2b8\ub97c \uacf5\uc720\ud560 \uc218 \uc788\ub3c4\ub85d \uad6c\uc131\ud55c \uac83\uc785\ub2c8\ub2e4.<\/p><\/div>\n<div class=\"english\">But there is a problem. If the two SWF files is on the same domain, no problem. If the SWFs are seperated in different domains, you can not access to the shared font with ApplicationDomain.getDefinition() method, though the SWF file is loaded in. So, an SWF file on www.mydomain.com can not use a font in an SWF on font.mydomain.com.<\/p>\n<p>You can use LoaderContext property, to allow access to assets in a different domain&#8217;s SWF file. The following code shows how it works.<\/p><\/div>\n<div class=\"japanese\">\u3067\u3082\u3001\u4e00\u3064\u3001\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002\u540c\u3058\u30c9\u30e1\u30a4\u30f3\u306a\u3089\u554f\u984c\u306a\u3044\u304c\u3001\u4e8c\u3064\u306eSWF\u30d5\u30a1\u30a4\u30eb\u304c\u9055\u3046\u30c9\u30e1\u30a4\u30f3\u306b\u3042\u308b\u3068\u3001\u305d\u306eSWF\u3092\u30ed\u30fc\u30c9\u3057\u3066\u3082\u3001ApplicationDomain.getDefinition()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u5171\u6709\u30d5\u30a9\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u306a\u3044\u3093\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u3001LoaderContext.securityDomain\u5c5e\u6027\u3092\u8a2d\u5b9a\u3057\u3066\u3001\u4ed6\u306e\u30c9\u30e1\u30a4\u30f3\u306b\u3042\u308bSWF\u30d5\u30a1\u30a4\u30eb\u306e\u8cc7\u6e90\u306b\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u5bb9\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001LoaderContext\u3092\u4f7f\u7528\u3057\u3066\u3001\u9055\u3046\u30c9\u30e1\u30a4\u30f3\u304b\u3089\u30d5\u30a9\u30f3\u30c8\u3092\u5171\u6709\u3057\u306b\u4f5c\u6210\u3057\u305f\u3082\u306e\u3067\u3059\u3002<\/p><\/div>\n<p><!--more--><\/p>\n<pre lang=\"actionscript3\" line=\"1\">package{\r\n\t\r\n\timport\tflash.display.*;\r\n\timport\tflash.events.*;\r\n\timport\tflash.net.*;\r\n\timport\tflash.system.*;\r\n\timport\tflash.text.*;\r\n\t\r\n\t\r\n\tpublic class ShareFont extends MovieClip{\r\n\t\t\r\n\t\tpublic const FONT_NAME:String = \"\ub9d1\uc740 \uace0\ub515\";\r\n\t\tpublic const FONT_SHARE_NAME:String = \"Gothic\";\r\n\t\tpublic const FONT_URL:String = \"gothic.swf\";\r\n\t\t\r\n\t\tpublic const PLAYER_TYPE:String = Capabilities.playerType;\r\n\t\tprivate var font_loader:Loader;\r\n\t\tprivate var context:LoaderContext;\r\n\t\t\r\n\t\t\r\n\t\tpublic function ShareFont(){\r\n\t\t\t\r\n\t\t\t\/\/ LoaderContext\r\n\t\t\tcontext = new LoaderContext();\r\n\t\t\tcontext.checkPolicyFile = true;\r\n\t\t\tcontext.securityDomain = SecurityDomain.currentDomain;\r\n\t\t\t\r\n\t\t\t\/\/ Loads an swf that contains the shared font.\r\n\t\t\tfont_loader = new Loader();\r\n\t\t\tfont_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontCompleteListener);\r\n\t\t\tif(PLAYER_TYPE == \"External\"){\r\n\t\t\t\tfont_loader.load(new URLRequest(FONT_URL));\r\n\t\t\t}else{\r\n\t\t\t\tfont_loader.load(new URLRequest(FONT_URL), context);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\/**\r\n\t\t * Font load complete listener.\r\n\t\t *\/\r\n\t\tprivate function fontCompleteListener(e:Event):void{\r\n\t\t\t\r\n\t\t\t\/\/ Get Font\r\n\t\t\tvar sharedFont:Class = font_loader.contentLoaderInfo.applicationDomain.getDefinition(FONT_SHARE_NAME) as Class;\r\n\t\t\tFont.registerFont(sharedFont);\r\n\t\t\t\r\n\t\t\t\/\/ TextFormat\r\n\t\t\tvar fmt:TextFormat = new TextFormat();\r\n\t\t\tfmt.size = 16;\r\n\t\t\tfmt.color = 0x666666;\r\n\t\t\tfmt.font = FONT_NAME;\r\n\t\t\t\r\n\t\t\t\/\/ TextField\r\n\t\t\tvar tf:TextField = new TextField();\r\n\t\t\ttf.embedFonts = true;\r\n\t\t\ttf.type = TextFieldType.INPUT;\r\n\t\t\ttf.multiline = true;\r\n\t\t\ttf.autoSize = TextFieldAutoSize.LEFT;\r\n\t\t\ttf.text = \"\uacf5\uc720 \ud3f0\ud2b8 \uc0ac\uc6a9\ud558\uae30\";\r\n\t\t\ttf.setTextFormat(fmt);\r\n\t\t\t\r\n\t\t\taddChild(tf);\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}<\/pre>\n<p>Related Links<br \/>\n<a href=\"http:\/\/geniusduck.tistory.com\/entry\/swf-load-%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-embeded-font-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0\">http:\/\/geniusduck.tistory.com\/entry\/swf-load-%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-embeded-font-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0<\/a><br \/>\n<a href=\"http:\/\/blog.jidolstar.com\/247\">http:\/\/blog.jidolstar.com\/247<\/a><br \/>\n<a href=\"http:\/\/liverwort.tistory.com\/227\">http:\/\/liverwort.tistory.com\/227<\/a><br \/>\n<a href=\"http:\/\/www.adobe.com\/devnet\/flash\/quickstart\/embedding_fonts\/\">http:\/\/www.adobe.com\/devnet\/flash\/quickstart\/embedding_fonts\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc6b0\uc120 \uacf5\uc720\ud558\ub824\ub294 \ud3f0\ud2b8\ub97c \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0 \ub4f1\ub85d\ud558\uace0, \uc544\ub798 \uadf8\ub9bc\uacfc \uac19\uc774 \uc124\uc815\ud55c \ub2e4\uc74c SWF\uc744 \ud37c\ube14\ub9ac\uc2dc \ud569\ub2c8\ub2e4. First, register a font in the library, and set the linkage properties like the following image. Then, publish the SWF file. \u307e\u305a\u3001\u5171\u6709\u3057\u3088\u3046\u3068\u3059\u308b\u30d5\u30a9\u30f3\u30c8\u3092\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u767b\u9332\u3057\u3001\u4e0b\u306e\u30a4\u30e1\u30fc\u30b8\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3001SWF\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u7248\u3057\u307e\u3059\u3002 \uc774 SWF\ud30c\uc77c\uc744 Loader \uac1d\uccb4\ub85c \ub85c\ub4dc\ud55c \ub2e4\uc74c, \uc544\ub798 \ucf54\ub4dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \uacf5\uc720\ub41c \ud3f0\ud2b8\ub97c \ub4f1\ub85d, \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. Load the SWF via Loader [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[31,123,125,122],"class_list":["post-330","post","type-post","status-publish","format-standard","hentry","category-as3","tag-crossdomain","tag-loadercontext","tag-securitydomain","tag-shared-font"],"_links":{"self":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/comments?post=330"}],"version-history":[{"count":0,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/330\/revisions"}],"wp:attachment":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/media?parent=330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/categories?post=330"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/tags?post=330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}