Page 2 of 3

Re: Integrating revFont

Posted: Sat Jun 01, 2013 1:13 pm
by LCMark
@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.

Re: Integrating revFont

Posted: Sat Jun 01, 2013 1:21 pm
by trevordevore
Perfect. Thanks Mark.

Re: Integrating revFont

Posted: Thu Jun 13, 2013 7:54 pm
by trevordevore
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 :-)

Re: Integrating revFont

Posted: Fri Jun 14, 2013 3:47 pm
by trevordevore
@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;
            }

Re: Integrating revFont

Posted: Fri Jun 14, 2013 4:19 pm
by LCMark
@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.

Re: Integrating revFont

Posted: Fri Jun 14, 2013 4:33 pm
by Janschenkel
@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.

Re: Integrating revFont

Posted: Fri Jun 14, 2013 7:55 pm
by trevordevore
@runrevmark - thanks for the info. Got it working now.

Re: Integrating revFont

Posted: Mon Jun 24, 2013 8:38 pm
by trevordevore
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.

Re: Integrating revFont

Posted: Thu Jun 27, 2013 5:27 pm
by LCMark
@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.

Re: Integrating revFont

Posted: Thu Jun 27, 2013 5:37 pm
by trevordevore

Re: Integrating revFont

Posted: Mon Jul 01, 2013 9:13 am
by LCMark
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.

Re: Integrating revFont

Posted: Mon Jul 01, 2013 5:25 pm
by LCMark
@trevordevore: Comments on your commit posted - although I think you noticed that already ;)

Re: Integrating revFont

Posted: Wed Sep 11, 2013 2:23 pm
by LCMark
I pulled in this today into develop - it will appear in 6.5-dp-1 which we're hoping to get out asap.

Re: Integrating revFont

Posted: Tue Dec 31, 2013 10:57 pm
by SirWobbyTheFirst
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.

Re: Integrating revFont

Posted: Thu Jan 02, 2014 12:42 am
by monte
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.