Beispiel #1
0
static void dump_ustr( char* msg, unichar_t* u )
{
    char u8buf[1001];
    char* pt = u8buf;
    memset( u8buf, 0, 1000 );
    printf("%s\n", msg );
    unichar_t* p = u;
    unichar_t* e = u + u_strlen( u );
    for( ; p!=e; ++p )
    {
	unichar_t buf[5];
	buf[0] = *p;
	buf[1] = '\0';
	printf("walk %d %s\n", *p, u_to_c(buf));

	pt = utf8_idpb( pt, *p, 0);
    }
    printf("%s u8str:%s\n", msg, u8buf );
}
Beispiel #2
0
unichar_t* WordlistEscapedInputStringToRealString(
    SplineFont* sf,
    const unichar_t* input_const,
    GArray** selected_out,
    WordlistEscapedInputStringToRealString_getFakeUnicodeOfScFunc getUnicodeFunc,
    void* udata )
{
    char* input = u2utf8_copy(input_const);

    // truncate insanely long lines rather than crash
    if( strlen(input) > PATH_MAX )
	input[PATH_MAX] = '\0';

//    printf("MVEscapedInputStringToRealString(top) input:%s\n", input );
    int  buffer_sz = PATH_MAX;
    char buffer[PATH_MAX+1];
    memset( buffer, '\0', buffer_sz );
    char *out = buffer;
    char* in = input;
    char* in_end = input + strlen(input);
    // trim comment and beyond from input
    {
	char* p = input;
	while( p && p < in_end  )
	{
	    p = strchr( p, '#' );
	    if( p > input && *(p-1) == '/' )
	    {
		p++;
		continue;
	    }
	    if( p )
		*p = '\0';
	    break;
	}
    }
    in_end = input + strlen(input);

//    printf("MVEscapedInputStringToRealString() in:%p in_end:%p\n", in, in_end );

    GArray* selected = g_array_new( 1, 1, sizeof(int));
    *selected_out = selected;
    int addingGlyphsToSelected = 0;
    int currentGlyphIndex = -1;
    for ( ; in != in_end; in++ )
    {
	char ch = *in;
//	printf("got ch:%c buf:%s\n", ch, buffer );

	if( ch == '[' )
	{
	    addingGlyphsToSelected = 1;
	    continue;
	}
	if( ch == ']' )
	{
	    addingGlyphsToSelected = 0;
	    continue;
	}
	currentGlyphIndex++;
	if( addingGlyphsToSelected )
	{
	    int selectGlyph = currentGlyphIndex;
	    g_array_append_val( selected, selectGlyph );
	}

	if( ch == '/' || ch == '\\' )
	{
	    // start of a glyph name
	    char glyphname[ PATH_MAX+1 ];
	    char* updated_in = 0;
	    SplineChar* sc = WordlistEscapedInputStringToRealString_readGlyphName( sf, in, in_end, &updated_in, glyphname );
	    if( sc )
	    {
		TRACE("ToRealString have an sc!... in:%p updated_in:%p\n", in, updated_in );
		in = updated_in;
		int n = getUnicodeFunc( sc, udata );
		TRACE("ToRealString orig_pos:%d\n", sc->orig_pos );
		if( n == -1 )
		{
		    printf("ToRealString NO UNICODE, orig_pos:%d\n", sc->orig_pos );
		    printf("ToRealString NO UNICODE, name:%s\n", sc->name );
		}
		
//		printf("ToRealString have an sc!... n:%d\n", n );
//		printf("sc->unic:%d\n",sc->unicodeenc);

		TRACE("calling utf8_idpb buffer:%s out:%s ch:%d\n", buffer, out, n );
		
		out = utf8_idpb( out, n, 0);
		if( !out )
		    printf("ToRealString error on out\n");
		continue;
	    }
	}

	*out++ = ch;
    }

    unichar_t* ret = (unichar_t *) utf82u_copy( buffer );
    free(input);
    return(ret);
}
Beispiel #3
0
void SFShowLigatures(SplineFont *sf,SplineChar *searchfor) {
    int i, cnt;
    char **choices=NULL;
    int *where=NULL;
    SplineChar *sc, *sc2;
    char *pt, *line;
    char *start, *end, ch;
    PST *pst;

    while ( 1 ) {
	for ( i=cnt=0; i<sf->glyphcnt; ++i ) {
	    if ( (sc=sf->glyphs[i])!=NULL && SCDrawsSomething(sc) ) {
		for ( pst=sc->possub; pst!=NULL; pst=pst->next )
			if ( pst->type==pst_ligature &&
				(searchfor==NULL || PSTContains(pst->u.lig.components,searchfor->name))) {
		    if ( choices!=NULL ) {
			line = pt = galloc((strlen(sc->name)+13+3*strlen(pst->u.lig.components)));
			strcpy(pt,sc->name);
			pt += strlen(pt);
			if ( sc->unicodeenc!=-1 && sc->unicodeenc<0x10000 ) {
			    *pt++='(';
			    pt = utf8_idpb(pt,sc->unicodeenc);
			    *pt++=')';
			}
			/* *pt++ = 0x21d0;*/ /* left arrow */
			strcpy(pt," ⇐ "); pt += strlen(pt);
			for ( start= pst->u.lig.components; ; start=end ) {
			    while ( *start==' ' ) ++start;
			    if ( *start=='\0' )
			break;
			    for ( end=start+1; *end!='\0' && *end!=' '; ++end );
			    ch = *end;
			    *end = '\0';
			    strcpy( pt,start );
			    pt += strlen(pt);
			    sc2 = SFGetChar(sf,-1,start);
			    *end = ch;
			    if ( sc2!=NULL && sc2->unicodeenc!=-1 && sc2->unicodeenc<0x10000 ) {
				*pt++='(';
				*pt++ = sc2->unicodeenc;
				*pt++=')';
			    }
			    *pt++ = ' ';
			}
			pt[-1] = '\0';
			choices[cnt] = line;
			where[cnt] = i;
		    }
		    ++cnt;
		}
	    }
	}
	if ( choices!=NULL )
    break;
	choices = galloc((cnt+2)*sizeof(unichar_t *));
	where = galloc((cnt+1)*sizeof(int));
	if ( cnt==0 ) {
	    choices[0] = copy("<No Ligatures>");
	    where[0] = -1;
	    choices[1] = NULL;
    break;
	}
    }
    choices[cnt] = NULL;
    i = gwwv_choose(_("Ligatures"),(const char **) choices,cnt,0,_("Select a ligature to view"));
    if ( i!=-1 && where[i]!=-1 )
	CharViewCreate(sf->glyphs[where[i]],(FontView *) sf->fv,-1);
    free(where);
    for ( i=0; i<cnt; ++i )
	free(choices[i]);
    free(choices);
}