//family 字体家族 import gdip.core; import gdip.font; namespace gdip ; class family { ctor(name,collection){ if(name === null || name === "Tahoma" ) { name = _WINXP ? "MS Shell Dlg" : "Segoe UI"; } if(type(name) == type.string){ var e,f = gdip.CreateFontFamilyFromName (name,collection) ; if( e ) return null,gdip.errMsg[e]; this.pFamily = f; this.name = name; ..table.gc(this,"delete"); } elseif(type(name) == type.pointer){ this.pFamily = name; if(collection){ var family2 = {ptr p}; gdip.assert2( ::Gdiplus.GdipCloneFontFamily(this.pFamily,family2) ); this.pFamily = family2.p; ..table.gc(this,"delete"); } } else { error("参数错误",2) } if(!this.pFamily) return; } @_metaProperty } namespace family { self.gdip = ..gdip; var gdip = gdip; _metaProperty = ..util.metaProperty( createFont = function( emSize,style=0/*_GdipFontStyleRegular*/,unit=2/*_GdipUnitPixel*/ ){ return gdip.font(owner,..math.abs(emSize),style,unit) ; }; getName = function(lang){ var name ={WORD value[32]}; ::Gdiplus.GdipGetFamilyNameW(owner[["pFamily"]],name,lang); return name.value; }; name = { _get = lambda() owner.getName(); }; delete = function(){ if( owner[["pFamily"]] ){ ::Gdiplus.GdipDeleteFontFamily(owner[["pFamily"]]) owner[["pFamily"]] = null; } }; _type = "gdip.family"; _topointer = function(){ return owner[["pFamily"]]; } ) } var $ = _dll; /*intellisense(gdip)*/ CreateFontFamilyFromName := $.api("GdipCreateFontFamilyFromName","int(ustring name,ptr fontColl,pointer& fontFamily)") /*end intellisense*/ /**intellisense() gdip.family = 字体家族。\n字体家族由具有相同字样(typeface)但字形风格(例如常规、粗体)不同的字体(font)组成。\n已安装或嵌入的字体列表(FontCollection)包含字体家族(Family),\n字体家族可以用于创建不同大小、不同样式的字体(Font) gdip.family(.("字体名称") = 创建字体家族。\n字体名参数必须指定不包含 Regular 这种字形风格后缀的字体名称。\n不指定字体名字时,默认为"MS Shell Dlg",\n字体家族可以用于创建不同样式的同名字体\n创建失败返回空值 gdip.family(.(字体家族指针,复制对象) = 字体家族指针转换为字体家族对象。\n如果参数@2为true,则复制字体家族并在对象销毁时负责回收字体家族\n\n否则仅绑定指针到对象,这时应当谨慎使用避免字体家族指针被释放 !gdipfamily.createFont(.(emSize,style,unit) = 创建字体。\n参数@emSize指定大小,\n可选参数@style 使用 _GdipFontStyle 前缀的常量指定字形样式,默认为 _GdipFontStyleRegular。\n可选参数@unit 指定单位,默认值为_GdipUnitPixel !gdipfamily.delete() = 释放对象。\n注意不应手工调用此函数,除非该集合内创建的字体已不再使用 !gdipfamily.getName() = 返回字体名。\n可选用参数@1指定语言ID,不指定时默认为 LANG_NEUTRAL,\n语言ID设为 0x409 返回英文字体名 gdip.family() = !gdipfamily. !gdipfamily.createFont() = !gdipfont. !gdipfamily.name = 字体名 end intellisense**/