Developing on Mac, standalone on Windows

Pete pete at mollysrevenge.com
Mon Jan 23 13:55:31 EST 2012


Thanks Ken and Warren.  In 99% of cases, the font, size, style, etc are
left at whatever LC's default is, which sounds like the system font for the
platform.  I like the idea of having a small test application to find the
best solution for this, plus thanks Ken for the frontscript and other
ideas.  I'll be trying out all this stuff in the next couple of days.

Pete

On Mon, Jan 23, 2012 at 8:10 AM, Ken Ray <kray at sonsothunder.com> wrote:

>
> On Jan 22, 2012, at 11:55 PM, Pete wrote:
>
> > I just compiled and ran my fist standalone on Windows and I'm finally
> > realising the benefits of developing cross platform applications with LC.
> > I was pretty amazed when everything I developed on my Mac just ran as
> > expected on Windows!
> >
> > The on;y problem I need to address concerns fonts.  I have a very few
> > controls that depend on font size to correctly position themselves around
> > other, non-textobjects and it seems that LC's default font on WIndows is
> > different than on a Mac, or at least the font size/spacing is.
> >
> > I left the font and size blank in almost all of my controls' text
> > formatting options but perhaps I need to name a specific font to have
> > things line up correctly on OS X and Windows?
>
> Are you setting font names anywhere in your app or are you defaulting to
> the system fonts for everything? There are generally three schools of
> thought on font/platform management:
>
> 1) Use LC's built in property profiles. It's been a long time since I used
> them, and I came up with my own solution, so I don't really know the pros
> and cons. (Maybe someone else could fill this in?)
>
> 2) Pick a font that will be on all your target systems, and set the font
> of your stack(s) to that font, allowing it to be inherited by all cards and
> card objects.
>        - Pros: Easy to set up and implement
>        - Cons: Significant limitations on font choices; your controls will
> not end up being displayed in OS-compliant fonts; every control that has a
> separate style (like bold) will break the inheritance and you'll have to
> set those manually.
>
> 3) Set the font for your controls by hand, based on platform.
>        - Pros: More control over what's happening; can apply the same text
> attributes to multiple objects by code without having to set individual
> properties on the controls (unless you want to)
>        - Cons: Takes a little time to code and set up
>
> I have been using for a long time a frontscript that traps 'preOpenCard',
> and then just runs through the controls on the card in a repeat loop,
> setting the appropriate text attributes. For those controls that need
> custom styling (like bold, etc.), I check a custom property set and apply
> the styles/sizes/colors if it has them. Here's a scaled-down example of
> what I mean:
>
> -- Frontscript
> on preOpenCard
>  repeat with x = 1 to the number of controls of this card
>    put the customProperties["uTextAttribs"] of control x of this card into
> tAttribsA
>    put "font,style,size,color" into tAttribs
>    repeat for each item tAttrib in tAttribs
>      if tAttribsA[tAttrib] <> "" then
>         do "set the text" & tAttrib && "of control x of this card to
> tAttribsA[tAttrib]"
>      else
>         do "set the text" & tAttrib && "of control x of this card to
> TextAttribs(tAttrib)"
>      end if
>    end repeat
>  end repeat
>  pass preOpenCard
> end preOpenCard
>
> function TextAttribs pAttrib
>  put "font,style,size,color" into tAttribs
>  switch (the platform)
>    case "MacOS"
>      put "Lucida Grande,plain,12,black" into tSysAttribs
>      break
>    case "Win32"
>      if (word 2 of the systemVersion) > 5.1 then
>        put "Segoe UI,plain,12,black" into tSysAttribs
>      else
>        put "Tahoma,plain,11,black" into tSysAttribs
>      end if
>      break
>  end switch
>  return item (itemOffset(pAttrib,tAttribs)) of tSysAttribs
> end TextAttribs
>
> Obviously this doesn't handle a bunch of situations, isn't optimized, and
> is primarily meant to give you an idea how this can work. But LC is so fast
> that even with dozens of controls, the time to set the properties is not
> noticeable.
>
> Hope this helps,
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list