Integrating revFont

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Sat Jun 01, 2013 1:13 pm

@trevordevore:
1) Since the font load/unload commands will require disk access, you just need to check the MCsecuremode global after evaluation but before execution.

Code: Select all

if (MCsecuremode & MC_SECUREMODE_DISK)
{
    MCeerror->add(EE_DISK_NOPERM, line, pos);
    return ES_ERROR;
}
2) The problem here is that we don't use STL (nor any exception-requiring C++) code in the engine (ideally the externals wouldn't either - but we've never had time to sanitize them). You could use an MCVariableValue instead which becomes a hash-table (LiveCode array!) when you use store_element etc.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Sat Jun 01, 2013 1:21 pm

Perfect. Thanks Mark.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Thu Jun 13, 2013 7:54 pm

Just posting an update. I have parsing and execution working for 'start using font' to the point that the calls into MCScreenDC are working. Now I'm just finishing up the actual implementation :-)
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Fri Jun 14, 2013 3:47 pm

@runrevmark - I'm having difficulty figuring out how to parse "globally". I have found examples that seem similar for "flip image" and "insert". They use something like sp.lookup(SP_INSERT, te). What I can't figure out is how to get sp.lookup working for "globally". Can you provide some additional details?

So far I have this which places the font file into 'font'. That works great. I just don't know how to conditionally grab "globally".

Code: Select all

 else if (sp.skip_token(SP_FACTOR, TT_CHUNK, CT_FONT) == PS_NORMAL)
        {
            if (sp . parseexp(False, True, &font) != PS_NORMAL)
            {
                MCperror->add(PE_START_BADCHUNK, sp);
                return PS_ERROR;
            }
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Fri Jun 14, 2013 4:19 pm

@trevordevore: Things like 'font' and 'globally' should be put in the 'sugar_table'... And then use skip_token(SP_SUGAR, TT_UNDEFINED, SG_FONT) or skip_token(SG_SUGAR, TT_UNDEFINED, SG_GLOBALLY). (The 'factor' table should only contain tokens for functions, properties and things that are related to parsing 'real' chunks - as in, in the context of MCChunk - as those tokens are essentially reserved).

Update: Just realized I misunderstood what you said! Conditionally parsing 'globally' can just be done with 'skip_token()' - if skip_token(SG_SUGAR, TT_UNDEFINED, SG_GLOBALLY) == PS_NORMAL, then it is present; otherwise it is not.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: Integrating revFont

Post by Janschenkel » Fri Jun 14, 2013 4:33 pm

@trevordevore
Maybe you can derive some information from my experiments with the 'tinker' command (in preparation for 'filter' enhancements)
https://github.com/quartamsoftware/live ... /cmdsf.cpp

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Fri Jun 14, 2013 7:55 pm

@runrevmark - thanks for the info. Got it working now.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Mon Jun 24, 2013 8:38 pm

I have pushed the changes I've been working on to my repository:

https://github.com/trevordevore/livecod ... 6892ec648f

* I've added in all of the parsing for 'start using font file theFile [globally]'/'stop using font file theFile' and fontFilesInUse.
* Windows should be working although I don't have dev environment set up yet so I haven't tested.
* 'start using' is working on OS X but not 'stop using'. I'm stuck on how best to store the container that I need for unloading the font on OS X. I tried implementing MCVariableValue within osxdc.cpp but it seems all of the MCVariables want Exec Points in order to work and I started getting an error about not being able to bind to a temporary exec point variable, blah, blah, blah (my brain started hurting).
* I'm storing the font files in use in an MCVariableValue in cmdse.cpp. I couldn't find a precedent for this so perhaps this isn't the best way to do it.

At this point I need some feedback.

1) Is the way I am storing font files in cmdse.cpp the right way to do it?

2) How to get MCVariableValue (or something else) working in osxdc.cpp. I just want a simple hash lookup I think.

3) Need someone to test Windows.

4) How to organize the code to throw an error when executing on platforms that don't support the syntax.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Thu Jun 27, 2013 5:27 pm

@trevordevore: I'd hoped to have time this week to look at this and answer your questions and give feedback, however that hasn't been the case :( I'm off tomorrow, but will see what I can do on Monday.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Integrating revFont

Post by trevordevore » Thu Jun 27, 2013 5:37 pm

Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Mon Jul 01, 2013 9:13 am

Are you swamped?
Ah - the Princess Bride - always good for a laugh :)

I was a little swamped last week due to spending about two days tracking down a couple of memory related bugs... I think it's been a while since about 6 lines of new code too so long to figure out...

Hoping to catch up with things today.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Mon Jul 01, 2013 5:25 pm

@trevordevore: Comments on your commit posted - although I think you noticed that already ;)

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: Integrating revFont

Post by LCMark » Wed Sep 11, 2013 2:23 pm

I pulled in this today into develop - it will appear in 6.5-dp-1 which we're hoping to get out asap.

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: Integrating revFont

Post by SirWobbyTheFirst » Tue Dec 31, 2013 10:57 pm

Hey guys, I was wondering if I could suggest a little edit to the font functionality, I'm going through with my idea of containing all of the files that Nix will use inside a virtual file system and one of the road blocks seems to be getting font files to be able to be loaded, so my request is that of being able to load a font file as a sequence of bytes. For example, after I "read" the file from my virtual file system and have placed the data into a variable, it would be great to be able to pass that to Start Using Font File and have it load the font that way.

I feel my requests are kind of niche given the projects I like to work on but hell, if you don't ask you'll never find out.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Integrating revFont

Post by monte » Thu Jan 02, 2014 12:42 am

Both the OS X and Windows font loading APIs appear to use file paths so you might just need to save the font out to a temporary file.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”