[PD-dev] adding fontpath
james tittle
tigital at mac.com
Tue Apr 4 18:54:11 CEST 2006
hey ben,
On Apr 4, 2006, at 12:08 PM, B. Bogart wrote:
> This sounds really interesting, where can I get more info on what
> Johannes's has done?
...hmm, it's in Manips/vertex_program.cpp, specifically:
void vertex_program :: openMess(t_symbol *filename)
{
char buf2[MAXPDSTRING];
char *bufptr=NULL;
if(NULL==filename || NULL==filename->s_name || &s_==filename ||
0==*filename->s_name)return;
// Clean up any open files
closeMess();
int fd=-1;
if ((fd=open_via_path(canvas_getdir(getCanvas())->s_name, filename-
>s_name, "",
buf2, &bufptr, MAXPDSTRING, 1))>=0){
close(fd);
sprintf(m_buf, "%s/%s", buf2, bufptr);
} else
canvas_makefilename(getCanvas(), filename->s_name, m_buf,
MAXPDSTRING);
FILE *file = fopen(m_buf,"r");
if(file) {
fseek(file,0,SEEK_END);
int size = ftell(file);
m_programString = new char[size + 1];
memset(m_programString,0,size + 1);
fseek(file,0,SEEK_SET);
fread(m_programString,1,size,file);
fclose(file);
} else {
m_programString = new char[strlen(m_buf) + 1];
strcpy(m_programString,m_buf);
}
m_size=strlen(m_programString);
m_programType=queryProgramtype(m_programString);
if(m_programType==GEM_PROGRAM_none){
m_programID = 0;
char *s = m_programString;
while(*s && *s != '\n') s++;
*s = '\0';
post("[%s]: unknown program header \"%s\" or error open \"%s\"
file\n",
m_objectname->s_name,
m_programString,filename->s_name);
delete m_programString; m_programString=NULL;
m_size=0;
return;
}
post("[%s]: Loaded file: %s\n", m_objectname->s_name, m_buf);
}
...I think the part to focus on here would be "open_via_path()"...
> Clearly it makes sense for pT to use the same font-handling setup
> as Gem.
>
> though I'm not convinced by the fonts living in the extra/ path, since
> this is what I've been doing in pT and it only makes sense if Gem is
> distributed with fonts, pT still has only two, the ones that are
> distributed with Gem... Much more logical to allow Gem (or an
> abstraction) to deal with fonts on the system...
...the only fonts that are distributed with Gem are the ones in the
examples/data folder, and the help files are setup to reference them
there...but it makes more sense to have the normal pd paths looked in
when search for a font: perhaps we should add the system fonts to
(ie. /Library/Fonts, /System/Library/Fonts, ~/Library/Fonts )?
jamie
> james tittle wrote:
>> On Apr 3, 2006, at 7:36 PM, Hans-Christoph Steiner wrote:
>>
>>> It seems that many parts of Pd use fonts: Gem, PDP/PiDiP,
>>> pixelTANGO,
>>> etc. It would be handy to have a centralized system for specifying
>>> where the fonts are located.
>>>
>>> What about adding a fontpath var to Pd-core, like "path" and
>>> "helppath"?
>>
>>
>> ...a fontpath would be good, but it'd also be nice if it just found
>> them within the normal "path" setup: IOhannes has done something
>> similar in Gem for finding programs/shaders, so I'll put this on the
>> "to-do-0.91" for gem's font-handling...
>>
>> jamie
>>
>>
>> _______________________________________________
>> PD-dev mailing list
>> PD-dev at iem.at
>> http://lists.puredata.info/listinfo/pd-dev
>>
More information about the Pd-dev
mailing list