Bug 691225 - pjl_set_next_fontsource not working
Summary: pjl_set_next_fontsource not working
Status: NOTIFIED FIXED
Alias: None
Product: GhostPCL
Classification: Unclassified
Component: PCL interpreter (show other bugs)
Version: master
Hardware: PC Windows XP
: P2 normal
Assignee: Henry Stiles
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-29 12:09 UTC by norbert.janssen
Modified: 2011-09-18 21:46 UTC (History)
0 users

See Also:
Customer: 661
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description norbert.janssen 2010-03-29 12:09:52 UTC
I implemented pl_load_cartridge_fonts() (which scans the CART0 directory for Truetype fonts). When I set @PJL DEFAULT FONTSOURCE='C', then the pcl_set_current_font_environment() should first scan the pcs->cartridge_fonts for the default_fontnumber, and if not found is uses pjl_proc_set_next_fontsource() to go to the next fontsource (being 'I').
However, pjl_proc_set_next_fontsource() does not work (it results in a hangup).

It starts in the current_fontsource ('C' == pst->font_envir[1]
and iff there are fonts in 'CART0' then the pst->font_envir[current_source].fontnumber[0] != 0)
so the current_source is not update to the next. I.e. there is no switch to the next fontsource.

pjl_set_next_fontsource(pjl_parser_state_t* pst)
{
    int current_source;
    pjl_envvar_t *current_font_source = pjl_get_envvar(pst, "fontsource");

    /* find the index of the current resource then work backwards
       until we find font resources.  We assume the internal source
       will have fonts */
    for (current_source = 0; pst->font_envir[current_source].designator[0]; current_source++ )
	if (!pjl_compare(pst->font_envir[current_source].designator, current_font_source))
	    break;

    /* next resource is not internal 'I' */
    if ( current_source != 0 ) {
	while( current_source > 0 ) {
	    /* valid font number found */
	    if ( pst->font_envir[current_source].fontnumber[0] )
		break;
	    current_source--;
	}
    }
    /* set both default and environment font source, the spec is not clear about this */
    pjl_set(pst, (char *)"fontsource", pst->font_envir[current_source].designator, true);
    pjl_set(pst, (char *)"fontsource", pst->font_defaults[current_source].designator, false);
}


BETTER WORKING CODE:

pjl_set_next_fontsource(pjl_parser_state_t* pst)
{
    int current_source;
    pjl_envvar_t *current_font_source = pjl_get_envvar(pst, "fontsource");

    /* find the index of the current resource then work backwards
       until we find font resources.  We assume the internal source
       will have fonts */
    for (current_source = 0; pst->font_envir[current_source].designator[0]; current_source++ )
	if (!pjl_compare(pst->font_envir[current_source].designator, current_font_source))
	    break;

    /* next resource is not internal 'I' */
    if ( current_source != 0 ) {
	while( current_source > 0 ) {
	    current_source--;	/* go to next fontsource */
	    /* check if it contains fonts, i.e. fontnumber != null */
	    if ( pst->font_envir[current_source].fontnumber[0] )
		break;
	}
    }
    /* set both default and environment font source, the spec is not clear about this */
    pjl_set(pst, (char *)"fontsource", pst->font_envir[current_source].designator, true);
    pjl_set(pst, (char *)"fontsource", pst->font_defaults[current_source].designator, false);
}
Comment 1 Henry Stiles 2010-05-21 13:40:39 UTC
revision 11298
Comment 2 Marcos H. Woehrmann 2011-09-18 21:46:15 UTC
Changing customer bugs that have been resolved more than a year ago to closed.