From: Adam T. (List) <lis...@tw...> - 2011-10-04 00:35:30
|
On 11-10-03 15:37, Khaled Hosny wrote: > FontForge uses the syntax filename(subfont) to access subfonts (even > from command line), where subfont can be either index or font name, > e.g: font = fontforge.open("%s(%s)" %(fontpath, fontindex)) font = > fontforge.open("%s(%s)" %(fontpath, fontname)) That is only theoretically true. I've looked at the code and the support for that selection method is rather spotty. It seems to work for TTC (using the name, but I believe not the index) and perhaps for Mac binaries, but it does not for example for for PDF. With PDF, the problem is that the parsing of the (subfont) selector is implemented in SplineFont *SFReadPdfFont within parsepdf.c but _ReadSplineFont from splinefont.c in line 1086 calls the SplineFont *_SFReadPdfFont method directly (with a pointer to the file), so it always passes NULL as the select_this_font argument. I've done some copy-paste patching in my copy by reusing some code present in SFReadPdfFont, i.e. rather than: [splinefont.c:1085] } else if ( ch1=='%' && ch2=='P' && ch3=='D' && ch4=='F' ) { sf = _SFReadPdfFont(file,fullname,NULL,openflags); checked = 'P'; } else if ( ch1==1 && ch2==0 && ch3==4 ) { My code now looks like: [splinefont.c:1085] } else if ( ch1=='%' && ch2=='P' && ch3=='D' && ch4=='F' ) { char *pt, *freeme=NULL, *freeme2=NULL, *select_this_font=NULL; if ( (pt=strchr(fullname,'('))!=NULL ) { freeme = fullname = copyn(fullname,pt-filename); freeme2 = select_this_font = copy(pt+1); if ( (pt=strchr(select_this_font,')'))!=NULL ) *pt = '\0'; } sf = _SFReadPdfFont(file,fullname,select_this_font,openflags); checked = 'P'; } else if ( ch1==1 && ch2==0 && ch3==4 ) { But it's possibly not the most elegant solution. In any way, the patched code works. Could you fix this "properly" in the code? Best, Adam -- May success attend your efforts, -- Adam Twardoch (Remove "list." from e-mail address to contact me directly.) |