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; }
static void SplashLayout() { unichar_t *start, *pt, *lastspace; extern const char *source_modtime_str; extern const char *source_version_str; uc_strcpy(msg, "When my father finished his book on Renaissance printing (The Craft of Printing and the Publication of Shakespeare's Works) he told me that I would have to write the chapter on computer typography. This is my attempt to do so."); GDrawSetFont(splashw,splash_font); linecnt = 0; lines[linecnt++] = msg-1; for ( start = msg; *start!='\0'; start = pt ) { lastspace = NULL; for ( pt=start; ; ++pt ) { if ( *pt==' ' || *pt=='\0' ) { if ( GDrawGetTextWidth(splashw,start,pt-start)<splashimage.u.image->width-10 ) lastspace = pt; else break; if ( *pt=='\0' ) break; } } if ( lastspace!=NULL ) pt = lastspace; lines[linecnt++] = pt; if ( *pt ) ++pt; } uc_strcpy(pt, " FontForge used to be named PfaEdit."); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcpy(pt," git hash: ");; pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcat(pt, FONTFORGE_GIT_VERSION); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcpy(pt," Version: ");; uc_strcat(pt,FONTFORGE_MODTIME_STR); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcat(pt," ("); uc_strcat(pt,FONTFORGE_MODTIME_STR); uc_strcat(pt,"-ML"); #ifdef FREETYPE_HAS_DEBUGGER uc_strcat(pt,"-TtfDb"); #endif uc_strcat(pt,")"); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcpy(pt," Lib Version: "); uc_strcat(pt,FONTFORGE_MODTIME_STR); lines[linecnt++] = pt+u_strlen(pt); lines[linecnt] = NULL; is = u_strchr(msg,'('); ie = u_strchr(msg,')'); }
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; }
unichar_t *u_GFileGetAbsoluteName(unichar_t *name, unichar_t *result, int rsiz) { /* result may be the same as name */ unichar_t buffer[1000]; if ( ! u_GFileIsAbsolute(name) ) { unichar_t *pt, *spt, *rpt, *bpt; if ( dirname_[0]=='\0' ) { getcwd(dirname_,sizeof(dirname_)); } uc_strcpy(buffer,dirname_); if ( buffer[u_strlen(buffer)-1]!='/' ) uc_strcat(buffer,"/"); u_strcat(buffer,name); _u_backslash_to_slash(buffer); /* Normalize out any .. */ spt = rpt = buffer; while ( *spt!='\0' ) { if ( *spt=='/' ) ++spt; for ( pt = spt; *pt!='\0' && *pt!='/'; ++pt ); if ( pt==spt ) /* Found // in a path spec, reduce to / (we've*/ u_strcpy(spt,pt); /* skipped past the :// of the machine name) */ else if ( pt==spt+1 && spt[0]=='.' && *pt=='/' ) /* Noop */ u_strcpy(spt,spt+2); else if ( pt==spt+2 && spt[0]=='.' && spt[1]=='.' ) { for ( bpt=spt-2 ; bpt>rpt && *bpt!='/'; --bpt ); if ( bpt>=rpt && *bpt=='/' ) { u_strcpy(bpt,pt); spt = bpt; } else { rpt = pt; spt = pt; } } else spt = pt; } name = buffer; } if (result!=name) { u_strncpy(result,name,rsiz); result[rsiz-1]='\0'; _u_backslash_to_slash(result); } return(result); }
static int SD_Call(GGadget *g, GEvent *e) { if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { char *fn; unichar_t *insert; fn = gwwv_open_filename(_("Call Script"), NULL, "*",NULL); if ( fn==NULL ) return(true); insert = malloc((strlen(fn)+10)*sizeof(unichar_t)); *insert = '"'; utf82u_strcpy(insert+1,fn); uc_strcat(insert,"\"()"); GTextFieldReplace(GWidgetGetControl(GGadgetGetWindow(g),CID_Script),insert); free(insert); free(fn); } return( true ); }
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; }
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; }
static void SplashLayout() { unichar_t *start, *pt, *lastspace; extern const char *source_modtime_str; extern const char *source_version_str; uc_strcpy(msg, "When my father finished his book on Renaissance printing (The Craft of Printing and the Publication of Shakespeare's Works) he told me that I would have to write the chapter on computer typography. This is my attempt to do so."); GDrawSetFont(splashw,splash_font); linecnt = 0; lines[linecnt++] = msg-1; for ( start = msg; *start!='\0'; start = pt ) { lastspace = NULL; for ( pt=start; ; ++pt ) { if ( *pt==' ' || *pt=='\0' ) { if ( GDrawGetTextWidth(splashw,start,pt-start,NULL)<splashimage.u.image->width-10 ) lastspace = pt; else break; if ( *pt=='\0' ) break; } } if ( lastspace!=NULL ) pt = lastspace; lines[linecnt++] = pt; if ( *pt ) ++pt; } uc_strcpy(pt, " FontForge used to be named PfaEdit."); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcpy(pt," Version: ");; uc_strcat(pt,source_modtime_str); uc_strcat(pt," ("); uc_strcat(pt,source_version_str); #ifdef FONTFORGE_CONFIG_TYPE3 uc_strcat(pt,"-ML"); #endif #ifdef FREETYPE_HAS_DEBUGGER uc_strcat(pt,"-TtfDb"); #endif #ifdef _NO_PYTHON uc_strcat(pt,"-NoPython"); #endif #ifdef FONTFORGE_CONFIG_USE_LONGDOUBLE uc_strcat(pt,"-LD"); #elif defined(FONTFORGE_CONFIG_USE_DOUBLE) uc_strcat(pt,"-D"); #endif #ifndef FONTFORGE_CONFIG_DEVICETABLES uc_strcat(pt,"-NoDevTab"); #endif uc_strcat(pt,")"); pt += u_strlen(pt); lines[linecnt++] = pt; uc_strcpy(pt," Library Version: "); uc_strcat(pt,library_version_configuration.library_source_modtime_string); lines[linecnt++] = pt+u_strlen(pt); lines[linecnt] = NULL; is = u_strchr(msg,'('); ie = u_strchr(msg,')'); }