void FVOutline(FontViewBase * fv, real width) { StrokeInfo si; SplineSet *temp, *spl; int i, cnt=0, changed, gid; SplineChar *sc; int layer=fv->active_layer; for (i=0; i < fv->map->enccount; ++i) if ((gid=fv->map->map[i]) != -1 && (sc=fv->sf->glyphs[gid]) != NULL && fv->selected[i] && sc->layers[layer].splines) ++cnt; memset(&si, 0, sizeof(si)); si.removeexternal=true; si.radius=width; /*si.removeoverlapifneeded=true; */ SFUntickAll(fv->sf); for (i=0; i < fv->map->enccount; ++i) if ((gid=fv->map->map[i]) != -1 && (sc=fv->sf->glyphs[gid]) != NULL && fv->selected[i] && sc->layers[layer].splines && !sc->ticked) { sc->ticked=true; SCPreserveLayer(sc, layer, false); temp = SplineSetStroke(sc->layers[layer].splines, &si, sc->layers[layer].order2); for (spl=sc->layers[layer].splines; spl->next != NULL; spl=spl->next); spl->next=temp; SplineSetsCorrect(sc->layers[layer].splines, &changed); SCCharChangedUpdate(sc, layer, true); } }
void FVInline(FontViewBase *fv, real width, real inset) { StrokeInfo si; SplineSet *temp, *spl, *temp2; int i, cnt=0, changed, gid; SplineChar *sc; int layer = fv->active_layer; for ( i=0; i<fv->map->enccount; ++i ) if ( (gid=fv->map->map[i])!=-1 && (sc=fv->sf->glyphs[gid])!=NULL && fv->selected[i] && sc->layers[layer].splines ) ++cnt; ff_progress_start_indicator(10,_("Inlining glyphs"),_("Inlining glyphs"),0,cnt,1); memset(&si,0,sizeof(si)); si.removeexternal = true; /*si.removeoverlapifneeded = true;*/ SFUntickAll(fv->sf); for ( i=0; i<fv->map->enccount; ++i ) if ( (gid=fv->map->map[i])!=-1 && (sc=fv->sf->glyphs[gid])!=NULL && fv->selected[i] && sc->layers[layer].splines && !sc->ticked ) { sc->ticked = true; SCPreserveLayer(sc,layer,false); si.radius = width; temp = SplineSetStroke(sc->layers[layer].splines,&si,sc->layers[layer].order2); si.radius = width+inset; temp2 = SplineSetStroke(sc->layers[layer].splines,&si,sc->layers[layer].order2); for ( spl=sc->layers[layer].splines; spl->next!=NULL; spl=spl->next ); spl->next = temp; for ( ; spl->next!=NULL; spl=spl->next ); spl->next = temp2; SplineSetsCorrect(sc->layers[layer].splines,&changed); SCCharChangedUpdate(sc,layer); if ( !ff_progress_next()) break; } ff_progress_end_indicator(); }
int _ExportPDF(FILE *pdf,SplineChar *sc,int layer) { /* TODO: Note, maybe this routine can be combined with print.c dump_pdfprologue() */ DBounds b; time_t now; struct tm *tm; int ret; char oldloc[24]; int _objlocs[8], xrefloc, streamstart, streamlength, resid = 0, nextobj; int *objlocs = _objlocs; const char *author = GetAuthor(); int i; SFUntickAll(sc->parent); locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage. switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale. fprintf( pdf, "%%PDF-1.4\n%%\201\342\202\203\n" ); /* Header comment + binary comment */ /* Every document contains a catalog which points to a page tree, which */ /* in our case, points to a single page */ objlocs[1] = ftell(pdf); fprintf( pdf, "1 0 obj\n << /Type /Catalog\n /Pages 2 0 R\n /PageMode /UseNone\n >>\nendobj\n" ); objlocs[2] = ftell(pdf); fprintf( pdf, "2 0 obj\n << /Type /Pages\n /Kids [ 3 0 R ]\n /Count 1\n >>\nendobj\n" ); /* And our single page points to its contents */ objlocs[3] = ftell(pdf); fprintf( pdf, "3 0 obj\n" ); fprintf( pdf, " << /Type /Page\n" ); fprintf( pdf, " /Parent 2 0 R\n" ); fprintf( pdf, " /Resources " ); if ( sc->parent->multilayer ) { resid = ftell(pdf); fprintf( pdf, "000000 0 R\n" ); } else fprintf( pdf, "<< >>\n" ); SplineCharLayerFindBounds(sc,layer,&b); fprintf( pdf, " /MediaBox [%g %g %g %g]\n", (double) b.minx, (double) b.miny, (double) b.maxx, (double) b.maxy ); fprintf( pdf, " /Contents 4 0 R\n" ); fprintf( pdf, " >>\n" ); fprintf( pdf, "endobj\n" ); /* And the contents are the interesting stuff */ objlocs[4] = ftell(pdf); fprintf( pdf, "4 0 obj\n" ); fprintf( pdf, " << /Length 5 0 R >> \n" ); fprintf( pdf, " stream \n" ); streamstart = ftell(pdf); SC_PSDump((void (*)(int,void *)) fputc,pdf,sc,true,true,layer); if ( sc->parent->multilayer ) /* Already filled or stroked */; else if ( sc->parent->strokedfont ) fprintf( pdf, "%g w S\n", (double) sc->parent->strokewidth ); else fprintf( pdf, "f\n" ); streamlength = ftell(pdf)-streamstart; fprintf( pdf, " endstream\n" ); fprintf( pdf, "endobj\n" ); objlocs[5] = ftell(pdf); fprintf( pdf, "5 0 obj\n" ); fprintf( pdf, " %d\n", (int) streamlength ); fprintf( pdf, "endobj\n" ); /* Optional Info dict */ objlocs[6] = ftell(pdf); fprintf( pdf, "6 0 obj\n" ); fprintf( pdf, " <<\n" ); fprintf( pdf, " /Creator (FontForge)\n" ); time(&now); tm = localtime(&now); fprintf( pdf, " /CreationDate (D:%04d%02d%02d%02d%02d%02d", 1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec ); #ifdef _NO_TZSET fprintf( pdf, "Z)\n" ); #else tzset(); if ( timezone==0 ) fprintf( pdf, "Z)\n" ); else { if ( timezone<0 ) /* fprintf bug - this is a kludge to print +/- in front of a %02d-padded value */ fprintf( pdf, "-" ); else fprintf( pdf, "+" ); fprintf( pdf, "%02d'%02d')\n", (int)(timezone/3600),(int)(timezone/60-(timezone/3600)*60) ); } #endif fprintf( pdf, " /Title (%s from %s)\n", sc->name, sc->parent->fontname ); if ( author!=NULL ) fprintf( pdf, " /Author (%s)\n", author ); fprintf( pdf, " >>\n" ); nextobj = 7; if ( sc->parent->multilayer ) { PI pi; int resobj; memset(&pi,0,sizeof(pi)); pi.out = pdf; pi.max_object = 100; pi.object_offsets = malloc(pi.max_object*sizeof(int)); memcpy(pi.object_offsets,objlocs,nextobj*sizeof(int)); pi.next_object = nextobj; resobj = PdfDumpGlyphResources(&pi,sc); nextobj = pi.next_object; objlocs = pi.object_offsets; fseek(pdf,resid,SEEK_SET); fprintf(pdf,"%06d", resobj ); fseek(pdf,0,SEEK_END); } xrefloc = ftell(pdf); fprintf( pdf, "xref\n" ); fprintf( pdf, " 0 %d\n", nextobj ); fprintf( pdf, "0000000000 65535 f \n" ); for ( i=1; i<nextobj; ++i ) fprintf( pdf, "%010d %05d n \n", (int) objlocs[i], 0 ); fprintf( pdf, "trailer\n" ); fprintf( pdf, " <<\n" ); fprintf( pdf, " /Size %d\n", nextobj ); fprintf( pdf, " /Root 1 0 R\n" ); fprintf( pdf, " /Info 6 0 R\n" ); fprintf( pdf, " >>\n" ); fprintf( pdf, "startxref\n" ); fprintf( pdf, "%d\n", (int) xrefloc ); fprintf( pdf, "%%%%EOF\n" ); if ( objlocs!=_objlocs ) free(objlocs); ret = !ferror(pdf); switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale. return( ret ); }