Index: read.c =================================================================== --- read.c (revision 36672) +++ read.c (revision 36673) @@ -2151,105 +2151,7 @@ return dt; } -static int parse_symbol(pcb_symbol_t *sym, lht_node_t *nd) -{ - lht_node_t *grp, *obj, *n; - lht_dom_iterator_t it; - int err = 0; - err |= parse_coord(&sym->Width, hash_get(nd, "width", 0)); - err |= parse_coord(&sym->Height, hash_get(nd, "height", 0)); - err |= parse_coord(&sym->Delta, hash_get(nd, "delta", 0)); - - grp = lht_dom_hash_get(nd, "objects"); - for(obj = lht_dom_first(&it, grp); obj != NULL; obj = lht_dom_next(&it)) { - rnd_coord_t x1, y1, x2, y2, th, r; - double sa, da; - - if (strncmp(obj->name, "line.", 5) == 0) { - err |= parse_coord(&x1, hash_get(obj, "x1", 0)); - err |= parse_coord(&y1, hash_get(obj, "y1", 0)); - err |= parse_coord(&x2, hash_get(obj, "x2", 0)); - err |= parse_coord(&y2, hash_get(obj, "y2", 0)); - err |= parse_coord(&th, hash_get(obj, "thickness", 0)); - if (err != 0) - return -1; - pcb_font_new_line_in_sym(sym, x1, y1, x2, y2, th); - } - else if (strncmp(obj->name, "simplearc.", 10) == 0) { - err |= parse_coord(&x1, hash_get(obj, "x", 0)); - err |= parse_coord(&y1, hash_get(obj, "y", 0)); - err |= parse_coord(&r, hash_get(obj, "r", 0)); - err |= parse_coord(&th, hash_get(obj, "thickness", 0)); - err |= parse_double(&sa, hash_get(obj, "astart", 0)); - err |= parse_double(&da, hash_get(obj, "adelta", 0)); - if (err != 0) - return -1; - pcb_font_new_arc_in_sym(sym, x1, y1, r, sa, da, th); - } - else if (strncmp(obj->name, "simplepoly.", 11) == 0) { - int len; - pcb_poly_t *sp; - if (obj->type != LHT_LIST) { - iolht_error(obj, "Symbol error: simplepoly is not a list! (ignoring this poly)\n"); - continue; - } - for(len = 0, n = obj->data.list.first; n != NULL; len++, n = n->next) ; - if ((len % 2 != 0) || (len < 6)) { - iolht_error(obj, "Symbol error: simplepoly has wrong number of points (%d, expected an even integer >= 6)! (ignoring this poly)\n", len); - continue; - } - sp = pcb_font_new_poly_in_sym(sym, len/2); - for(len = 0, n = obj->data.list.first; n != NULL; len++, n = n->next) { - parse_coord(&x1, n); - n = n->next; - parse_coord(&y1, n); - sp->Points[len].X = x1; - sp->Points[len].Y = y1; - } - } - } - - sym->Valid = 1; - return 0; -} - -static int parse_font(pcb_font_t *font, lht_node_t *nd) -{ - lht_node_t *grp, *sym; - lht_dom_iterator_t it; - int err = 0; - - if (nd->type != LHT_HASH) - return iolht_error(nd, "font must be a hash\n"); - - err |= parse_coord(&font->MaxHeight, hash_get(nd, "cell_height", 0)); - err |= parse_coord(&font->MaxWidth, hash_get(nd, "cell_width", 0)); - - grp = lht_dom_hash_get(nd, "symbols"); - - for(sym = lht_dom_first(&it, grp); sym != NULL; sym = lht_dom_next(&it)) { - int chr; - if (sym->type != LHT_HASH) - continue; - if (*sym->name == '&') { - char *end; - chr = strtol(sym->name+1, &end, 16); - if (*end != '\0') { - iolht_error(sym, "Ignoring symbol with invalid symbol name '%s'.\n", sym->name); - continue; - } - } - else - chr = *sym->name; - if ((chr >= 0) && (chr < sizeof(font->Symbol) / sizeof(font->Symbol[0]))) { - parse_symbol(font->Symbol+chr, sym); - } - } - - return err; -} - #define PARSE_COORD(dst, src) parse_coord(dst, src) #define PARSE_DOUBLE(dst, src) parse_double(dst, src) #define HASH_GET(hash, name) hash_get(hash, name, 0) @@ -2285,14 +2187,11 @@ return iolht_error(nd, "Failed to allocate font id %d (name '%s').\n", id, n->name); } else { - pcb_font_free(&fk->dflt); rnd_font_free(&fk->dflt.rnd_font); fk->dflt.id = 0; /* restore default font's ID */ f = &fk->dflt; } - if (parse_font(f, n) != 0) - return -1; if (rnd_font_lht_parse_font(&f->rnd_font, n) != 0) return -1; } @@ -2902,8 +2801,7 @@ } else { TODO("font: remove this whole function and call rnd_font_load(Ptr, Filanem, pcb_io_err_inhibit) instead"); - res = parse_font(Ptr, doc->root->data.list.first); - rnd_font_lht_parse_font(&Ptr->rnd_font, doc->root->data.list.first); + res = rnd_font_lht_parse_font(&Ptr->rnd_font, doc->root->data.list.first); } free(errmsg); Index: write.c =================================================================== --- write.c (revision 36672) +++ write.c (revision 36673) @@ -1396,76 +1396,6 @@ return ndt; } -/* font: remove */ -static lht_node_t *build_symbol(pcb_symbol_t *sym, const char *name) -{ - lht_node_t *lst, *ndt; - pcb_line_t *li; - pcb_poly_t *poly; - pcb_arc_t *arc; - int n; - - ndt = lht_dom_node_alloc(LHT_HASH, name); - lht_dom_hash_put(ndt, build_textf("width", CFMT, sym->Width)); - lht_dom_hash_put(ndt, build_textf("height", CFMT, sym->Height)); - lht_dom_hash_put(ndt, build_textf("delta", CFMT, sym->Delta)); - - lst = lht_dom_node_alloc(LHT_LIST, "objects"); - lht_dom_hash_put(ndt, lst); - for(n = 0, li = sym->Line; n < sym->LineN; n++, li++) - lht_dom_list_append(lst, build_line(li, n, 0, 0, 1)); - - for(arc = arclist_first(&sym->arcs); arc != NULL; arc = arclist_next(arc), n++) - lht_dom_list_append(lst, build_simplearc(arc, n)); - - for(poly = polylist_first(&sym->polys); poly != NULL; poly = polylist_next(poly), n++) - lht_dom_list_append(lst, build_simplepoly(poly, n)); - - return ndt; -} - -/* font: remove */ -static lht_node_t *build_font_old(pcb_font_t *font) -{ - lht_node_t *syms, *ndt; - char *sid, sidbuff[64]; - int n; - - if (font->id > 0) { - sprintf(sidbuff, "%ld", font->id); - sid = sidbuff; - } - else - sid = "geda_pcb"; /* special case for comaptibility: font 0 is the geda_pcb font */ - - ndt = lht_dom_node_alloc(LHT_HASH, sid); - - lht_dom_hash_put(ndt, build_textf("cell_height", CFMT, font->MaxHeight)); - lht_dom_hash_put(ndt, build_textf("cell_width", CFMT, font->MaxWidth)); - lht_dom_hash_put(ndt, build_textf("id", "%ld", font->id)); - if (font->name != NULL) - lht_dom_hash_put(ndt, build_text("name", font->name)); -/* lht_dom_hash_put(ndt, build_symbol(&font->DefaultSymbol)); */ - - - syms = lht_dom_node_alloc(LHT_HASH, "symbols"); - lht_dom_hash_put(ndt, syms); - for(n = 0; n < PCB_MAX_FONTPOSITION + 1; n++) { - char sname[32]; - if (!font->Symbol[n].Valid) - continue; - if ((n <= 32) || (n > 126) || (n == '&') || (n == '#') || (n == '{') || (n == '}') || (n == '/') || (n == ':') || (n == ';') || (n == '=') || (n == '\\') || (n == ':')) { - sprintf(sname, "&%02x", n); - } - else { - sname[0] = n; - sname[1] = '\0'; - } - lht_dom_hash_put(syms, build_symbol(&font->Symbol[n], sname)); - } - return ndt; -} - static lht_node_t *build_glyph_line(rnd_glyph_line_t *line, long local_id) { char buff[128]; @@ -1586,10 +1516,7 @@ static lht_node_t *build_font(pcb_font_t *font) { - if (!(pcb_brave & PCB_BRAVE_OLDFONT)) - return build_font_rnd(&font->rnd_font); - else - return build_font_old(font); + return build_font_rnd(&font->rnd_font); }