Back to index

texmacs  1.0.7.15
Defines | Functions
cff_dict.h File Reference
#include "cff_types.h"
#include "cff.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CFF_NOMINALWIDTHX_DEFAULT   0.0
#define CFF_DEFAULTWIDTHX_DEFAULT   0.0

Functions

cff_dictcff_new_dict (void)
void cff_release_dict (cff_dict *dict)
void cff_dict_set (cff_dict *dict, const char *key, int idx, double value)
double cff_dict_get (cff_dict *dict, const char *key, int idx)
void cff_dict_add (cff_dict *dict, const char *key, int count)
void cff_dict_remove (cff_dict *dict, const char *key)
int cff_dict_known (cff_dict *dict, const char *key)
cff_dictcff_dict_unpack (card8 *data, card8 *endptr)
long cff_dict_pack (cff_dict *dict, card8 *dest, long destlen)
void cff_dict_update (cff_dict *dict, cff_font *cff)

Define Documentation

#define CFF_DEFAULTWIDTHX_DEFAULT   0.0

Definition at line 30 of file cff_dict.h.

#define CFF_NOMINALWIDTHX_DEFAULT   0.0

Definition at line 29 of file cff_dict.h.


Function Documentation

void cff_dict_add ( cff_dict dict,
const char *  key,
int  count 
)

Definition at line 580 of file cff_dict.c.

{
  int id, i;

  for (id=0;id<CFF_LAST_DICT_OP;id++) {
    if (key && dict_operator[id].opname &&
       strcmp(dict_operator[id].opname, key) == 0)
      break;
  }

  if (id == CFF_LAST_DICT_OP)
    ERROR("%s: Unknown CFF DICT operator.", CFF_DEBUG_STR);

  for (i=0;i<dict->count;i++) {
    if ((dict->entries)[i].id == id) {
      if ((dict->entries)[i].count != count)
       ERROR("%s: Inconsistent DICT argument number.", CFF_DEBUG_STR);
      return;
    }
  }

  if (dict->count + 1 >= dict->max) {
    dict->max += 8;
    dict->entries = RENEW(dict->entries, dict->max, cff_dict_entry);
  }

  (dict->entries)[dict->count].id    = id;
  (dict->entries)[dict->count].key   = (char *) dict_operator[id].opname;
  (dict->entries)[dict->count].count = count;
  if (count > 0) {
    (dict->entries)[dict->count].values = NEW(count, double);
    memset((dict->entries)[dict->count].values,
          0, sizeof(double)*count);
  } else {
    (dict->entries)[dict->count].values = NULL;
  }
  dict->count += 1;

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double cff_dict_get ( cff_dict dict,
const char *  key,
int  idx 
)

Definition at line 647 of file cff_dict.c.

{
  double value = 0.0;
  int    i;

  ASSERT(key && dict);

  for (i = 0; i < dict->count; i++) {
    if (strcmp(key, (dict->entries)[i].key) == 0) {
      if ((dict->entries)[i].count > idx)
       value = (dict->entries)[i].values[idx];
      else
       ERROR("%s: Invalid index number.", CFF_DEBUG_STR);
      break;
    }
  }

  if (i == dict->count)
    ERROR("%s: DICT entry \"%s\" not found.", CFF_DEBUG_STR, key);

  return value;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int cff_dict_known ( cff_dict dict,
const char *  key 
)

Definition at line 634 of file cff_dict.c.

{
  int i;

  for (i = 0; i < dict->count; i++) {
    if (key && strcmp(key, (dict->entries)[i].key) == 0
       && (dict->entries)[i].count > 0)
      return 1;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long cff_dict_pack ( cff_dict dict,
card8 dest,
long  destlen 
)

Definition at line 560 of file cff_dict.c.

{
  long len = 0;
  int  i;

  for (i = 0; i < dict->count; i++) {
    if (!strcmp(dict->entries[i].key, "ROS")) {
      len += put_dict_entry(&dict->entries[i], dest, destlen);
      break;
    }
  }
  for (i = 0; i < dict->count; i++) {
    if (strcmp(dict->entries[i].key, "ROS")) {
      len += put_dict_entry(&dict->entries[i], dest+len, destlen-len);
    }
  }

  return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cff_dict_remove ( cff_dict dict,
const char *  key 
)

Definition at line 621 of file cff_dict.c.

{
  int i;
  for (i = 0; i < dict->count; i++) {
    if (key && strcmp(key, (dict->entries)[i].key) == 0) {
      (dict->entries)[i].count = 0;
      if ((dict->entries)[i].values)
       RELEASE((dict->entries)[i].values);
      (dict->entries)[i].values = NULL;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cff_dict_set ( cff_dict dict,
const char *  key,
int  idx,
double  value 
)

Definition at line 670 of file cff_dict.c.

{
  int i;

  ASSERT(dict && key);

  for (i = 0 ; i < dict->count; i++) {
    if (strcmp(key, (dict->entries)[i].key) == 0) {
      if ((dict->entries)[i].count > idx)
       (dict->entries)[i].values[idx] = value;
      else
       ERROR("%s: Invalid index number.", CFF_DEBUG_STR);
      break;
    }
  }

  if (i == dict->count)
    ERROR("%s: DICT entry \"%s\" not found.", CFF_DEBUG_STR, key);
}

Here is the call graph for this function:

Here is the caller graph for this function:

cff_dict* cff_dict_unpack ( card8 data,
card8 endptr 
)

Definition at line 345 of file cff_dict.c.

{
  cff_dict *dict;
  int status = CFF_PARSE_OK;

  stack_top = 0;

  dict = cff_new_dict();
  while (data < endptr && status == CFF_PARSE_OK) {
    if (*data < 22) { /* operator */
      add_dict(dict, &data, endptr, &status);
    } else if (*data == 30) { /* real - First byte of a sequence (variable) */
      if (stack_top < CFF_DICT_STACK_LIMIT) {
       arg_stack[stack_top] = get_real(&data, endptr, &status);
       stack_top++;
      } else {
       status = CFF_ERROR_STACK_OVERFLOW;
      }
    } else if (*data == 255 || (*data >= 22 && *data <= 27)) { /* reserved */
      data++;
    } else { /* everything else are integer */
      if (stack_top < CFF_DICT_STACK_LIMIT) {
       arg_stack[stack_top] = get_integer(&data, endptr, &status);
       stack_top++;
      } else {
       status = CFF_ERROR_STACK_OVERFLOW;
      }
    }
  }

  if (status != CFF_PARSE_OK) {
    ERROR("%s: Parsing CFF DICT failed. (error=%d)", CFF_DEBUG_STR, status);
  } else if (stack_top != 0) {
    WARN("%s: Garbage in CFF DICT data.", CFF_DEBUG_STR);
    stack_top = 0;
  }

  return dict;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cff_dict_update ( cff_dict dict,
cff_font cff 
)

Definition at line 690 of file cff_dict.c.

{
  int i;

  for (i = 0;i < dict->count; i++) {
    if ((dict->entries)[i].count > 0) {
      char *str;
      int   id;

      id = (dict->entries)[i].id;
      if (dict_operator[id].argtype == CFF_TYPE_SID) {
       str = cff_get_string(cff, (dict->entries)[i].values[0]);
       (dict->entries)[i].values[0] = cff_add_string(cff, str, 1);
       RELEASE(str);
      } else if (dict_operator[id].argtype == CFF_TYPE_ROS) {
       str = cff_get_string(cff, (dict->entries)[i].values[0]);
       (dict->entries)[i].values[0] = cff_add_string(cff, str, 1);
       RELEASE(str);
       str = cff_get_string(cff, (dict->entries)[i].values[1]);
       (dict->entries)[i].values[1] = cff_add_string(cff, str, 1);
       RELEASE(str);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

cff_dict* cff_new_dict ( void  )

Definition at line 60 of file cff_dict.c.

{
  cff_dict *dict;

  dict = NEW(1, cff_dict);
  dict->max     = DICT_ENTRY_MAX;
  dict->count   = 0;
  dict->entries = NEW(dict->max, cff_dict_entry);

  return dict;
}

Here is the caller graph for this function:

void cff_release_dict ( cff_dict dict)

Definition at line 72 of file cff_dict.c.

{
  if (dict) {
    if (dict->entries) {
      int i;
      for (i=0;i<dict->count;i++) {
       if ((dict->entries)[i].values)
         RELEASE((dict->entries)[i].values);
      }
      RELEASE(dict->entries);
    }
  RELEASE(dict);
  }
}

Here is the caller graph for this function: