Exemple #1
0
unichar_t* Wordlist_advanceSelectedCharsBy( SplineFont* sf, EncMap *map, unichar_t* txtu, int offset )
{
    unichar_t original_data[ PATH_MAX ];
    static unichar_t ret[ PATH_MAX ];
    int i = 0;

    u_strcpy( original_data, txtu );
    TRACE("Wordlist_advanceSelectedCharsBy(1) %s\n", u_to_c( txtu ));
    WordlistTrimTrailingSingleSlash( txtu );
    WordListLine wll = WordlistEscapedInputStringToParsedData( sf, txtu );

    int selectedCount = WordListLine_countSelected( wll );
    if( !selectedCount )
	wll->isSelected = 1;
    
    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
    for( i = 0; wll->sc; wll++, i++ )
    {
	SplineChar* sc = wll->sc;
        int element_selected = wll->isSelected;

        if( element_selected )
        {
            int pos = map->backmap[ sc->orig_pos ];
            pos += offset;
            int gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
            if( gid == -2 )
	    {
		// we can't find a glyph at the desired position.
		// so instead of dropping it we just do not perform the operation
		// on this char.
		pos -= offset;
		gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
		if( gid == -2 )
		{
		    // we can't go back manually!
		    u_strcpy( ret, original_data );
		    return ret;
		}
	    }
	    if( gid==-1 || !sf->glyphs[gid] ) 
                sc = SFMakeChar( sf, map, pos );
            else
                sc = sf->glyphs[gid];
        }
        
        
        if( element_selected )
            uc_strcat( ret, "[" );

        /* uc_strcat( ret, "/" ); */
        /* uc_strcat( ret, scarray[i]->name ); */
        uc_strcat( ret, Wordlist_getSCName( sc ));

        if( element_selected )
            uc_strcat( ret, "]" );
    }

    return ret;
}
Exemple #2
0
unichar_t* Wordlist_selectionAdd( SplineFont* sf, EncMap *map, unichar_t* txtu, int offset )
{
    int i = 0;
    static unichar_t ret[ PATH_MAX ];
    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
 
    WordlistTrimTrailingSingleSlash( txtu );
    WordListLine wll = WordlistEscapedInputStringToParsedData( sf, txtu );

    for( i = 0; wll->sc; wll++, i++ )
    {
	SplineChar* sc = wll->sc;
        int element_selected = wll->isSelected;
    
	if( i == offset )
	    element_selected = 1;
	
        if( element_selected )
        {
            int pos = map->backmap[ sc->orig_pos ];
            TRACE("pos1:%d\n", pos );
            TRACE("map:%d\n", map->map[ pos ] );
            int gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
            if( gid == -2 )
                continue;
            if( gid==-1 || !sf->glyphs[gid] ) 
                sc = SFMakeChar( sf, map, pos );
            else
                sc = sf->glyphs[gid];
        }
        
        
        if( element_selected )
            uc_strcat( ret, "[" );

        /* uc_strcat( ret, "/" ); */
        /* uc_strcat( ret, scarray[i]->name ); */
        uc_strcat( ret, Wordlist_getSCName( sc ));

        if( element_selected )
            uc_strcat( ret, "]" );
    }
    
    return ret;
}
Exemple #3
0
unichar_t* Wordlist_advanceSelectedCharsBy( SplineFont* sf, EncMap *map, unichar_t* txtu, int offset )
{
    unichar_t original_data[ PATH_MAX ];
    static unichar_t ret[ PATH_MAX ];
    int limit = PATH_MAX;
    SplineChar* scarray[ PATH_MAX + 1 ];
    GArray* selected = 0;
    int i = 0;

    u_strcpy( original_data, txtu );
    TRACE("Wordlist_advanceSelectedCharsBy(1) %s\n", u_to_c( txtu ));
    WordlistTrimTrailingSingleSlash( txtu );
    txtu = WordlistEscapedInputStringToRealStringBasic( sf, txtu, &selected );
    TRACE("Wordlist_advanceSelectedCharsBy(2) %s\n", u_to_c( txtu ));

    GArray* bv = Wordlist_selectedToBitmapArray( selected );
    TRACE("selected->len:%d\n", selected->len );
    if( !selected->len )
    {
        int one = 1;
        g_array_insert_val( bv, 0, one );
    }
    g_array_unref( selected );
    selected = 0;
    
    memset( scarray, 0, sizeof(SplineChar*) * limit+1 );
    const unichar_t *pt, *ept, *tpt;
    pt = txtu;
    ept=txtu+u_strlen(txtu);
    for ( tpt=pt; tpt<ept; ++tpt )
    {
        int ch = *tpt;
        if( tpt == pt )
        {
            // your own char at the leading of the text
            SplineChar* sc = SFGetOrMakeCharFromUnicodeBasic( sf, ch );
            scarray[i] = sc;
            i++;
            continue;
        }
		
        scarray[i] = SFGetOrMakeCharFromUnicodeBasic( sf, ch );

        
        i++;
        if( i >= limit )
            break;
    }

    

    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
    for( i = 0; scarray[i]; i++ )
    {
        int element_selected = g_array_index (bv, gint, i);

        if( element_selected )
        {
            int pos = map->backmap[ scarray[i]->orig_pos ];
            TRACE("pos1:%d\n", pos );
            pos += offset;
            TRACE("pos2:%d\n", pos );
            TRACE("map:%d\n", map->map[ pos ] );
            int gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
            if( gid == -2 )
	    {
		// we can't find a glyph at the desired position.
		// so instead of dropping it we just do not perform the operation
		// on this char.
		pos -= offset;
		gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
		if( gid == -2 )
		{
		    // we can't go back manually!
		    printf("no glyph!\n");
		    u_strcpy( ret, original_data );
		    return ret;
		}
	    }
	    if( gid==-1 || !sf->glyphs[gid] ) 
                scarray[i] = SFMakeChar( sf, map, pos );
            else
                scarray[i] = sf->glyphs[gid];
        }
        
        
        if( element_selected )
            uc_strcat( ret, "[" );

        /* uc_strcat( ret, "/" ); */
        /* uc_strcat( ret, scarray[i]->name ); */
        uc_strcat( ret, Wordlist_getSCName( scarray[i] ));

        if( element_selected )
            uc_strcat( ret, "]" );
    }

    TRACE("Wordlist_advanceSelectedCharsBy(e) %s\n", u_to_c( ret ));
    return ret;
}
Exemple #4
0
unichar_t* Wordlist_selectionAdd( SplineFont* sf, EncMap *map, unichar_t* txtu, int offset )
{
    int i = 0;
    static unichar_t ret[ PATH_MAX ];
    int limit = PATH_MAX;
    SplineChar* scarray[ PATH_MAX + 1 ];
    GArray* selected = 0;
    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
    memset( scarray, 0, sizeof(SplineChar*) * limit+1 );
 
    WordlistTrimTrailingSingleSlash( txtu );
    txtu = WordlistEscapedInputStringToRealStringBasic( sf, txtu, &selected );
    GArray* bv = Wordlist_selectedToBitmapArray( selected );
    g_array_unref( selected );
    selected = 0;


    const unichar_t *pt, *ept, *tpt;
    pt = txtu;
    ept=txtu+u_strlen(txtu);
    for ( tpt=pt; tpt<ept; ++tpt )
    {
        int ch = *tpt;
        if( tpt == pt )
        {
            // your own char at the leading of the text
            SplineChar* sc = SFGetOrMakeCharFromUnicodeBasic( sf, ch );
            scarray[i] = sc;
            i++;
            continue;
        }
        scarray[i] = SFGetOrMakeCharFromUnicodeBasic( sf, ch );

        i++;
        if( i >= limit )
            break;
    }
    
    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
    for( i = 0; scarray[i]; i++ )
    {
        int element_selected = g_array_index (bv, gint, i);
	if( i == offset )
	    element_selected = 1;
	
        if( element_selected )
        {
            int pos = map->backmap[ scarray[i]->orig_pos ];
            TRACE("pos1:%d\n", pos );
            TRACE("map:%d\n", map->map[ pos ] );
            int gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
            if( gid == -2 )
                continue;
            if( gid==-1 || !sf->glyphs[gid] ) 
                scarray[i] = SFMakeChar( sf, map, pos );
            else
                scarray[i] = sf->glyphs[gid];
        }
        
        
        if( element_selected )
            uc_strcat( ret, "[" );

        /* uc_strcat( ret, "/" ); */
        /* uc_strcat( ret, scarray[i]->name ); */
        uc_strcat( ret, Wordlist_getSCName( scarray[i] ));

        if( element_selected )
            uc_strcat( ret, "]" );
    }
    
    return ret;
}