示例#1
0
void
checkligkern(char *s, Font *fnt)
{
  char *mlist[5];
  char *os;
  char *orig_s, *pos;
  size_t offset[5];
  int n;


  os = newstring(s);
  orig_s = s;

  s++;
  while (isspace(*s))
    s++;
  if (strncmp(s, "LIGKERN", 7) == 0)
  {
    fnt->sawligkern = True;
    s += 7;
    while (isspace(*s))
      s++;
    pos = s;
    while (*pos)
    {
      for (n = 0; n < 5;)
      {
        if (*pos == '\0')
          break;
        offset[n] = pos - orig_s;
        mlist[n] = paramstring(&pos);
        if (strcmp(mlist[n], ";") == 0)
          break;
        n++;
      }

      if (n > 4)
        boops(os, pos - orig_s, "Too many parameters in lig kern data.");
      if (n < 3)
        boops(os, pos - orig_s, "Too few parameters in lig kern data.");

      if (n == 3 && strcmp(mlist[1], "{}") == 0)        /* rmkern command */
        rmkern(mlist[0], mlist[2], (ttfinfo *)0, fnt);
      else if (n == 3 && strcmp(mlist[1], "<>") == 0)   /* addkern */
        addkern(mlist[0], mlist[2], fnt);
      else if (n == 3 && strcmp(mlist[0], "||") == 0 &&
               strcmp(mlist[1], "=") == 0)              /* bc command */
      {
        ttfinfo *ti = findadobe("||", fnt->charlist);


        if (fnt->boundarychar != -1)
          boops(os, offset[0], "Multiple boundary character commands?");
        if (sscanf(mlist[2], "%d", &n) != 1)
          boops(os, offset[2],
                "Expected number assignment for boundary char.");
        if (n < 0 || n > 0xFF)
          boops(os, offset[2], "Boundary character number must be 0..0xFF.");

        fnt->boundarychar = n;
        if (ti == NULL)
          oops("Internal error: boundary char.");
        ti->outcode = n; /* prime the pump, so to speak, for lig/kerns */
      }
      else if (n == 4)
      {
        int op = -1;
        ttfinfo *ti;


        for (n = 0; encligops[n]; n++)
          if (strcmp(mlist[2], encligops[n]) == 0)
          {
            op = n;
            break;
          }
        if (op < 0)
          boops(os, offset[2], "Bad ligature op specified.");

        if (NULL != (ti = findadobe(mlist[0], fnt->charlist)))
        {
          lig *lig;


          if (findadobe(mlist[1], fnt->charlist))
                                                /* remove coincident kerns */
            rmkern(mlist[0], mlist[1], ti, fnt);

          if (strcmp(mlist[3], "||") == 0)
            boops(os, offset[3], "You can't lig to the boundary character!");

          if (!fnt->fixedpitch)         /* fixed pitch fonts get *0* ligs */
          {
            for (lig = ti->ligs; lig; lig = lig->next)
              if (strcmp(lig->succ, mlist[1]) == 0)
                break;                  /* we'll re-use this structure */

            if (lig == NULL)
            {
              lig = newlig();
              lig->succ = newstring(mlist[1]);
              lig->next = ti->ligs;
              ti->ligs = lig;
            }
            lig->sub = newstring(mlist[3]);
            lig->op = op;
 
            if (strcmp(mlist[1], "||") == 0)
            {
              lig->boundleft = 1;
              if (strcmp(mlist[0], "||") == 0)
                boops(os, offset[0],
                      "You can't lig boundarychar boundarychar!");
            }
            else
              lig->boundleft = 0;
          }
        }
      }
      else
        boops(os, offset[0], "Bad form in LIGKERN command.");
    }
  }

  free(os);
}
示例#2
0
int GBLCOCreateError::BehaviourFunction( const CKBehaviorContext& behContext )
{
	CKBehavior	*behaviour = behContext.Behavior;
	CKContext	*context = behContext.Context;

	if ( behaviour == NULL || context == NULL )
		return CKBR_GENERICERROR;

	behaviour->ActivateInput(ECGBLCOCreateErrorBehInputs::In, FALSE);

	CGBLCOErrorManager *errorManager = (CGBLCOErrorManager *)context->GetManagerByGuid(CGBLCOErrorManagerGUID);
	if ( errorManager == NULL )
		return CKBR_GENERICERROR;

	// Get Parameters Inputs Source.
	CKParameterOut *poutError = behaviour->GetOutputParameter(ECGBLCOCreateErrorParamOutputs::GetError);
	if ( poutError == NULL )
		return CKBR_GENERICERROR;
	
	CKParameterIn*pinCode = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorCode);
	CKParameterIn*pinDesc = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorDescription);
	CKParameterIn*pinType = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorType);
	 
	if ( pinCode == NULL || pinDesc == NULL || pinType == NULL )
		return CKBR_GENERICERROR;
	
	CKParameter*paraCode = pinCode->GetRealSource();
	CKParameter*paraDesc = pinDesc->GetRealSource();
	CKParameter*paraType = pinType->GetRealSource();

	if ( paraCode == NULL || paraDesc == NULL || paraType == NULL )
		return CKBR_GENERICERROR;
	
	// Get Parameters Inputs Values (code,desc,type).
	int code = 0;
	paraCode->GetValue(&code);

	XString desc;
	int paramsize = paraDesc->GetStringValue(NULL);
	if (paramsize) 
	{
		XAP<char> paramstring(new char[paramsize]);
		paraDesc->GetStringValue(paramstring,TRUE);
		desc << (char*)paramstring;
	} 

	CGBLCOError::EGBLCOErrorType type;
	paraType->GetValue(&type);
	
	// Create the TGBLError parameter output.
	TGBLError::SetTGBLError(poutError,type,code,(CKSTRING)desc.CStr());
	CK_CLASSID cid = poutError->GetClassID();
	
	// 
	if ( type != CGBLCOError::EGBLCOErrorType::GBLCO_FATAL )
	{
		behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, FALSE);
		behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, TRUE);
		return CKBR_OK;
	}

	errorManager->NotifyError(type,code,(CKSTRING)desc.CStr());
	behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, TRUE);
	behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, FALSE);
  	
	return CKBR_OK;
}