Created a nice software using SpiderBasic ? Post you link here !
User avatar
eddy
 
Posts: 124
Joined: Thu Mar 27, 2014 8:34 am

Lorem Ipsum (using web fonts from Google,TypeKit,Monotype )

by eddy Sun Apr 05, 2015 11:04 am

- plugin : https://github.com/millermedeiros/requirejs-plugins
- Web Font Loader API : https://github.com/typekit/webfontloader

Code: Select all
; ******************************
; Plugins
; ******************************

Macro InitPlugins(IsInitialized=#True) ; internal functions
  CompilerIf IsInitialized
    !"undefined"==typeof window.SpiderPlugins&&(window.SpiderPlugins={extensions:{},paths:{},names:[]})
  CompilerElse
    !window.SpiderPlugins={extensions:{},paths:{},names:[]};
  CompilerEndIf   
EndMacro

Procedure DeclarePlugin(Plugin.s, Path.s, IsUsed=#True)
  InitPlugins()
  !,window.SpiderPlugins.paths[v_Plugin]=v_Path
  !,v_IsUsed && window.SpiderPlugins.names.push(v_Plugin);
EndProcedure


Procedure DeclarePluginResource(Resource.s)
  InitPlugins()
  !,window.SpiderPlugins.names.push(v_Resource)
EndProcedure

Procedure UsePlugins(*FunctionUsingPlugins, EnforceDefine=#False) 
  !var cfg=$.extend({ enforceDefine: v_EnforceDefine, paths: window.SpiderPlugins.paths }, window.SpiderPlugins.extensions);
  !requirejs.config(cfg);
  !require(window.SpiderPlugins.names, p_FunctionUsingPlugins); 
  InitPlugins(#False)
EndProcedure

; ******************************
; Web Font
; ******************************

Procedure.i GadgetElement(Gadget, UseJquery.b=#True)
  Protected gadgetObject=GadgetID(Gadget)
  !return (v_gadgetObject && v_gadgetObject.div)? v_UseJquery? $(v_gadgetObject.div):v_gadgetObject.div:null;
EndProcedure

Procedure WriteWithGoogleFonts() 
  OpenWindow(0,0,0,0,0,"",#PB_Window_Background)
  EditorGadget(0,10,10,800,600,#PB_Editor_WordWrap)
  SetGadgetText(0,"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
 
  element = GadgetElement(0)
  !v_element.find('textarea').css({ fontStyle:"italic", fontFamily:"Tangerine", fontSize:"40px", lineHeight:"50px" }); 
EndProcedure


DeclarePlugin("propertyParser","//cdnjs.cloudflare.com/ajax/libs/requirejs-plugins/1.0.3/propertyParser",#False) ;plugin prerequisite
DeclarePlugin("font","//cdnjs.cloudflare.com/ajax/libs/requirejs-plugins/1.0.3/font",#False)                     ;plugin to load fonts (based on Web Font Loader API)
;This code will load 5 web fonts
DeclarePluginResource("font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700]|typekit,id:123|monotype,projectId:555") ;import fonts via plugin
                                                                                                                                ;caution, Typekit And Monotype fonts works with online subscription
UsePlugins(@WriteWithGoogleFonts())
Return to Showcase

Who is online

Users browsing this forum: No registered users and 2 guests