Example #1
0
PsychError FONTSFonts(void) 
{
    PsychGenericScriptType 	*nativeStructArray;
    int				arrayIndex, numFonts;
    PsychFontStructType		**fontPointerList, *fontElement;
    
    //all sub functions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    //check for  required and superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(0));
        
    //build a list of pointers to all the the font records in the font list, then hand the list of pointers to PsychCopyFontRecordsToNativeStructArray()
    //to get a native struct array of font records and return it to the scripting environment.
    arrayIndex=0;
    numFonts=PsychGetFontListLength();
    fontPointerList=(PsychFontStructType**)malloc(numFonts * sizeof(PsychFontStructType*));
    for(fontElement=PsychGetFontListHead();fontElement;fontElement=fontElement->next)
        fontPointerList[arrayIndex++]=fontElement;
    PsychCopyFontRecordsToNativeStructArray(numFonts, fontPointerList, &nativeStructArray);  
    free((void*)fontPointerList);
    PsychAssignOutStructArray(1, FALSE, nativeStructArray);
    
    return(PsychError_none);	
}
Example #2
0
/*
    PsychGetFontListLength()
    
    Walk down the list and count the number of elements in the list
*/
int PsychGetFontListLength(void)
{
    PsychFontStructPtrType		current;
    int 				i;
    
    i=0;
    for(current=PsychGetFontListHead();  current; current=current->next)
        ++i;
    return(i);
}
Example #3
0
/*
    PsychGetNumFontRecordsFromFontFamilyName()
    
    Accept a font family name string and a pointer to strorage.  Set the contents of the storage to hold 
    an array of pointers to font records for the fonts which are members of the  specified font family.
    
    Return the number of elements.
    
    Passing NULL in for pFontStructArray will cause PsychGetFontRecordsFromFontFamilyName() to return the tally of 
    the family's member fonts without storing the pointers. To determine the size of the pFontStructArray array 
    storage, first call PsychGetFontRecordsFromFontFamilyName, passing NULL in for pFontStructArray.
    
*/
int	PsychMemberFontsFromFontFamilyName(char *fontFamilyName, PsychFontStructPtrType *pFontStructArray)
{
    int				i;
    psych_bool			nameMatch;
    PsychFontStructPtrType	current;
    
    i=0;
    for(current=PsychGetFontListHead();  current; current=current->next){
        nameMatch= !(strcmp((char*) current->fontFMFamilyName, fontFamilyName));
        if(nameMatch){
            if(pFontStructArray)
                pFontStructArray[i]=current;
            i++;
        }
    }
    return(i);
}
Example #4
0
/*
    PsychGetFontRecordFromFontNumber()
    
    Accept a font number.  Lookup the specified font record in the list of font records.  If the font is found in the 
    list then set the fontStruct pointer to point to the font record.  Otherwise set fontStruct to NULL and return FALSE.   
        
    Font numbers are something the Psychtoolbox assigns when building its font list.  They are not genine properties of the 
    font.
*/
psych_bool	PsychGetFontRecordFromFontNumber(int fontIndex, PsychFontStructType **fontStruct)
{
    PsychFontStructPtrType	current;
    psych_bool			found;

    found=0;
    for(current=PsychGetFontListHead();  current; current=current->next){
        if(current->fontNumber==fontIndex){
            found=1;
            *fontStruct=current;
            break;
        }
    }
    if(!found)
        *fontStruct=NULL;

    return(found);
}
Example #5
0
/*
    PsychGetFontRecordFromFontNameAndFontStyle()
    
    Accept a font family name and a font style.  Lookup the specified font in the list of font records.  If the font is found in the 
    list then set the fontStruct pointer to point to the font record.  Otherwise set fontStruct to NULL and return FALSE.    
*/
psych_bool	PsychGetFontRecordFromFontFamilyNameAndFontStyle(char *fontFamilyName, FMFontStyle fontStyle, PsychFontStructType **fontStruct)
{
    PsychFontStructPtrType	current;
    psych_bool			nameMatch, styleMatch, found;

    found=0;
    for(current=PsychGetFontListHead();  current; current=current->next){
        nameMatch= !(strcmp((char*) current->fontFMFamilyName, fontFamilyName));
        styleMatch= current->fontFMStyle==fontStyle;
        found= nameMatch && styleMatch;
        if(found){
            *fontStruct=current;
            break;
        }
    }
    if(!found)
        *fontStruct=NULL;
    return(found);
}