예제 #1
0
static SFStringRecord *applyFontTables(SFFontRef sfFont, SFStringRecord *record) {
    SFInternal internal;
    
    SFFontReadTables(sfFont);
    
    internal.record = record;
    internal.cmap = &sfFont->_tables->_cmap;
    internal.gdef = &sfFont->_tables->_gdef;
    internal.gsub = &sfFont->_tables->_gsub;
    internal.gpos = &sfFont->_tables->_gpos;

    if (sfFont->_tables->_availableTables & itCMAP) {
        SFApplyCMAP(&internal);
    }
    
    if (sfFont->_tables->_availableTables & itGSUB) {
        SFApplyGSUB(&internal);
    }
    
    if (sfFont->_tables->_availableTables & itGPOS) {
        SFApplyGPOS(&internal);
    }
    
    return record;
}
예제 #2
0
SFStringRecordRef SFFontAllocateStringRecordForString(SFFontRef sfFont, SFUnichar *inputString, int length) {
	if (inputString && length) {
        SFStringRecordRef record = malloc(sizeof(SFStringRecord));
        
        int allocSize = (sizeof(int) * length);
        int *types = malloc(allocSize);
        int *levels = malloc(allocSize);
        int *lOrder = malloc(allocSize);
        
        resolveBidi(inputString, types, levels, length, lOrder);
        
        // SFDeallocateStringRecord will be responsible for freeing inputString, levels and lOrder
        SFAllocateStringRecord(record, inputString, levels, lOrder, length);
        
        free(types);
        
        readFontTables(sfFont);
        
        if (sfFont->_availableFontTables & itCMAP)
            SFApplyCMAP(&sfFont->_cmap, record);
        
        if (sfFont->_availableFontTables & itGSUB)
            SFApplyGSUB(&sfFont->_gsub,
                        (sfFont->_availableFontTables & itGDEF) ? &sfFont->_gdef : NULL
                        , record);
        
        if (sfFont->_availableFontTables & itGPOS)
            SFApplyGPOS(&sfFont->_gpos,
                        (sfFont->_availableFontTables & itGDEF) ? &sfFont->_gdef : NULL
                        , record);
        
        return record;
    }
    
	return NULL;
}