Index: doc-rnd/TODO =================================================================== --- doc-rnd/TODO (revision 1315) +++ doc-rnd/TODO (revision 1316) @@ -1,9 +1,6 @@ UNGLIB: - test transition (after glib removal is finished so that valgrind works reasonably well again): - test gpmi search - - obsolete functions: - - ExpandFilename() - - CreateQuotedString() - get rid of gcode/lists.h, and vector.[ch] (autorouter) - move fontmode Index: scconfig/hooks.c =================================================================== --- scconfig/hooks.c (revision 1315) +++ scconfig/hooks.c (revision 1316) @@ -67,6 +67,10 @@ {"buildin-oldactions", "/local/pcb/oldactions/buildin", arg_true, "$static link the oldactions plugin into the executable"}, {"plugin-oldactions", "/local/pcb/oldactions/buildin", arg_false, "$the oldactions plugin is a dynamic loadable"}, + {"disable-fontmode", "/local/pcb/fontmode/enable", arg_false, "$do not compile the fontmode"}, + {"buildin-fontmode", "/local/pcb/fontmode/buildin", arg_true, "$static link the fontmode plugin into the executable"}, + {"plugin-fontmode", "/local/pcb/fontmode/buildin", arg_false, "$the fontmode plugin is a dynamic loadable"}, + {"disable-legacy_func", "/local/pcb/legacy_func/enable", arg_false, "$do not compile the legacy functions"}, {"buildin-legacy_func", "/local/pcb/legacy_func/buildin", arg_true, "$static link the legacy functions plugin into the executable"}, {"plugin-legacy_func", "/local/pcb/legacy_func/buildin", arg_false, "$the legacy functions plugin is a dynamic loadable"}, @@ -208,6 +212,10 @@ put("/local/pcb/oldactions/enable", strue); put("/local/pcb/oldactions/buildin", strue); + db_mkdir("/local/pcb/fontmode"); + put("/local/pcb/fontmode/enable", strue); + put("/local/pcb/fontmode/buildin", strue); + db_mkdir("/local/pcb/legacy_func"); put("/local/pcb/legacy_func/enable", strue); put("/local/pcb/legacy_func/buildin", strue); @@ -537,6 +545,7 @@ plugin_stat("Mincut: ", "/local/pcb/mincut"); plugin_stat("renumber:", "/local/pcb/renumber"); plugin_stat("old actions:", "/local/pcb/oldactions"); + plugin_stat("fontmode:", "/local/pcb/fontmode"); plugin_stat("legacy functions:", "/local/pcb/legacy_func"); plugin_stat("stroke:", "/local/pcb/stroke"); printf("\n"); Index: src/fontmode.c =================================================================== --- src/fontmode.c (revision 1315) +++ src/fontmode.c (nonexistent) @@ -1,232 +0,0 @@ -/* $Id$ */ - -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 2006 DJ Delorie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA - * dj@delorie.com - * - */ - -#include "config.h" - -#include "global.h" - -#include -#include -#include - - -#include "create.h" -#include "data.h" -#include "draw.h" -#include "misc.h" -#include "move.h" -#include "remove.h" -#include "rtree.h" -#include "strflags.h" -#include "undo.h" -#include "pcb-printf.h" - - -RCSID("$Id$"); - -/* FIXME - we currently hardcode the grid and PCB size. What we - should do in the future is scan the font for its extents, and size - the grid appropriately. Also, when we convert back to a font, we - should search the grid for the gridlines and use them to figure out - where the symbols are. */ - -#define CELL_SIZE MIL_TO_COORD (100) -#define CELL_OFFSET MIL_TO_COORD (10) - -#define XYtoSym(x,y) ((x1 + CELL_OFFSET) / CELL_SIZE - 1 \ - + 16 * ((y1 + CELL_OFFSET) / CELL_SIZE - 1)) - -static const char fontedit_syntax[] = "FontEdit()"; - -static const char fontedit_help[] = "Convert the current font to a PCB for editing."; - -/* %start-doc actions FontEdit - -%end-doc */ - -static int FontEdit(int argc, char **argv, Coord Ux, Coord Uy) -{ - FontType *font; - SymbolType *symbol; - LayerTypePtr lfont, lorig, lwidth, lgrid; - int s, l; - - if (hid_actionl("New", "Font", 0)) - return 1; - - Settings.grid_unit = get_unit_struct("mil"); - Settings.Bloat = PCB->Bloat = 1; - Settings.Shrink = PCB->Shrink = 1; - Settings.minWid = PCB->minWid = 1; - Settings.minSlk = PCB->minSlk = 1; - - MoveLayerToGroup(max_copper_layer + COMPONENT_LAYER, 0); - MoveLayerToGroup(max_copper_layer + SOLDER_LAYER, 1); - - while (PCB->Data->LayerN > 4) - MoveLayer(4, -1); - for (l = 0; l < 4; l++) { - MoveLayerToGroup(l, l); - } - PCB->MaxWidth = CELL_SIZE * 18; - PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2); - PCB->Grid = MIL_TO_COORD(5); - PCB->Data->Layer[0].Name = strdup("Font"); - PCB->Data->Layer[1].Name = strdup("OrigFont"); - PCB->Data->Layer[2].Name = strdup("Width"); - PCB->Data->Layer[3].Name = strdup("Grid"); - hid_action("PCBChanged"); - hid_action("LayersChanged"); - - lfont = PCB->Data->Layer + 0; - lorig = PCB->Data->Layer + 1; - lwidth = PCB->Data->Layer + 2; - lgrid = PCB->Data->Layer + 3; - - font = &PCB->Font; - for (s = 0; s <= MAX_FONTPOSITION; s++) { - Coord ox = (s % 16 + 1) * CELL_SIZE; - Coord oy = (s / 16 + 1) * CELL_SIZE; - Coord w, miny, maxy, maxx = 0; - - symbol = &font->Symbol[s]; - - miny = MIL_TO_COORD(5); - maxy = font->MaxHeight; - - for (l = 0; l < symbol->LineN; l++) { - CreateDrawnLineOnLayer(lfont, - symbol->Line[l].Point1.X + ox, - symbol->Line[l].Point1.Y + oy, - symbol->Line[l].Point2.X + ox, - symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); - CreateDrawnLineOnLayer(lorig, symbol->Line[l].Point1.X + ox, - symbol->Line[l].Point1.Y + oy, - symbol->Line[l].Point2.X + ox, - symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); - if (maxx < symbol->Line[l].Point1.X) - maxx = symbol->Line[l].Point1.X; - if (maxx < symbol->Line[l].Point2.X) - maxx = symbol->Line[l].Point2.X; - } - w = maxx + symbol->Delta + ox; - CreateDrawnLineOnLayer(lwidth, w, miny + oy, w, maxy + oy, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); - } - - for (l = 0; l < 16; l++) { - int x = (l + 1) * CELL_SIZE; - CreateDrawnLineOnLayer(lgrid, x, 0, x, PCB->MaxHeight, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); - } - for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) { - int y = (l + 1) * CELL_SIZE; - CreateDrawnLineOnLayer(lgrid, 0, y, PCB->MaxWidth, y, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); - } - return 0; -} - -static const char fontsave_syntax[] = "FontSave()"; - -static const char fontsave_help[] = "Convert the current PCB back to a font."; - -/* %start-doc actions FontSave - -%end-doc */ - -static int FontSave(int argc, char **argv, Coord Ux, Coord Uy) -{ - FontTypePtr font; - SymbolTypePtr symbol; - int i; - LineType *l; - gdl_iterator_t it; - LayerTypePtr lfont, lwidth; - - font = &PCB->Font; - lfont = PCB->Data->Layer + 0; - lwidth = PCB->Data->Layer + 2; - - for (i = 0; i <= MAX_FONTPOSITION; i++) { - font->Symbol[i].LineN = 0; - font->Symbol[i].Valid = 0; - font->Symbol[i].Width = 0; - } - - linelist_foreach(&lfont->Line, &it, l) { - int x1 = l->Point1.X; - int y1 = l->Point1.Y; - int x2 = l->Point2.X; - int y2 = l->Point2.Y; - int ox, oy, s; - - s = XYtoSym(x1, y1); - ox = (s % 16 + 1) * CELL_SIZE; - oy = (s / 16 + 1) * CELL_SIZE; - symbol = &PCB->Font.Symbol[s]; - - x1 -= ox; - y1 -= oy; - x2 -= ox; - y2 -= oy; - - if (symbol->Width < x1) - symbol->Width = x1; - if (symbol->Width < x2) - symbol->Width = x2; - symbol->Valid = 1; - - CreateNewLineInSymbol(symbol, x1, y1, x2, y2, l->Thickness); - } - - linelist_foreach(&lwidth->Line, &it, l) { - Coord x1 = l->Point1.X; - Coord y1 = l->Point1.Y; - Coord ox, s; - - s = XYtoSym(x1, y1); - ox = (s % 16 + 1) * CELL_SIZE; - symbol = &PCB->Font.Symbol[s]; - - x1 -= ox; - - symbol->Delta = x1 - symbol->Width; - } - - SetFontInfo(font); - - return 0; -} - -HID_Action fontmode_action_list[] = { - {"FontEdit", 0, FontEdit, - fontedit_help, fontedit_syntax} - , - {"FontSave", 0, FontSave, - fontsave_help, fontsave_syntax} -}; - -REGISTER_ACTIONS(fontmode_action_list, NULL) Index: src/Makefile.dep =================================================================== --- src/Makefile.dep (revision 1315) +++ src/Makefile.dep (revision 1316) @@ -216,17 +216,6 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h pcb-printf.h \ ../src_3rd/genvector/gds_char.h -fontmode.o: fontmode.c ../config.h ../config.manual.h ../config.auto.h \ - global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ - global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ - list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h create.h data.h draw.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h move.h remove.h rtree.h \ - strflags.h undo.h pcb-printf.h free_atexit.o: free_atexit.c gui_act.o: gui_act.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ @@ -1326,6 +1315,18 @@ list_element.h libpcb_fp.h data.h draw.h error.h global.h resource.h \ set.h undo.h ../src_plugins/vendordrill/vendor.h stub_vendor.h plugins.h \ dolists.h +../src_plugins/puller/puller.o: ../src_plugins/puller/puller.c \ + ../config.h ../config.manual.h ../config.auto.h global.h const.h \ + ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ + ../src_3rd/genlist/gendlist.h polyarea.h list_common.h list_line.h \ + ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ + ../src_3rd/genlist/gentdlist_undef.h list_arc.h list_text.h list_poly.h \ + list_pad.h list_pin.h list_rat.h vtonpoint.h \ + ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h create.h global.h data.h draw.h misc.h \ + ../src_3rd/genvector/gds_char.h mymem.h move.h pcb-printf.h remove.h \ + rtree.h strflags.h undo.h plugins.h dolists.h ../src_plugins/import_edif/edif.o: ../src_plugins/import_edif/edif.c \ global.h ../config.h ../config.manual.h ../config.auto.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1381,6 +1382,30 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h action.h action_funclist.h \ action_funchash.h change.h error.h undo.h plugins.h dolists.h +../src_plugins/fontmode/fontmode.o: ../src_plugins/fontmode/fontmode.c \ + ../config.h ../config.manual.h ../config.auto.h global.h const.h \ + ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ + ../src_3rd/genlist/gendlist.h polyarea.h list_common.h list_line.h \ + ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ + ../src_3rd/genlist/gentdlist_undef.h list_arc.h list_text.h list_poly.h \ + list_pad.h list_pin.h list_rat.h vtonpoint.h \ + ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h create.h global.h data.h draw.h misc.h \ + ../src_3rd/genvector/gds_char.h mymem.h move.h remove.h rtree.h \ + strflags.h undo.h pcb-printf.h plugins.h dolists.h +../src_plugins/legacy_func/legacy_func.o: \ + ../src_plugins/legacy_func/legacy_func.c ../src_3rd/genvector/gds_char.h \ + ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h ../config.h ../config.manual.h \ + ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ + global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ + list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ + vtonpoint.h hid.h global_element.h list_element.h libpcb_fp.h data.h \ + global.h action.h action_funclist.h action_funchash.h change.h error.h \ + undo.h plugins.h ../src_plugins/renumber/renumber.o: ../src_plugins/renumber/renumber.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1543,18 +1568,6 @@ list_element.h libpcb_fp.h data.h global.h error.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h plugins.h hid.h \ hid/common/hidnogui.h hid/gtk/../hidint.h -../src_plugins/puller/puller.o: ../src_plugins/puller/puller.c \ - ../config.h ../config.manual.h ../config.auto.h global.h const.h \ - ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ - ../src_3rd/genlist/gendlist.h polyarea.h list_common.h list_line.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h list_arc.h list_text.h list_poly.h \ - list_pad.h list_pin.h list_rat.h vtonpoint.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h create.h global.h data.h draw.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h move.h pcb-printf.h remove.h \ - rtree.h strflags.h undo.h dolists.h ../src_plugins/toporouter/toporouter.o: \ ../src_plugins/toporouter/toporouter.c \ ../src_plugins/toporouter/toporouter.h data.h global.h ../config.h \ Index: src/Makefile.in =================================================================== --- src/Makefile.in (revision 1315) +++ src/Makefile.in (revision 1316) @@ -30,7 +30,6 @@ find.o find_act.o flags.o - fontmode.o free_atexit.o gui_act.o heap.o @@ -144,6 +143,7 @@ include {../src_plugins/gpmi/Plug.tmpasm} include {../src_plugins/toporouter/Plug.tmpasm} include {../src_plugins/oldactions/Plug.tmpasm} +include {../src_plugins/fontmode/Plug.tmpasm} include {../src_plugins/legacy_func/Plug.tmpasm} include {../src_plugins/renumber/Plug.tmpasm} include {../src_plugins/stroke/Plug.tmpasm} Index: src_plugins/fontmode/Makefile =================================================================== --- src_plugins/fontmode/Makefile (nonexistent) +++ src_plugins/fontmode/Makefile (revision 1316) @@ -0,0 +1,5 @@ +all: + cd ../../src && make mod_fontmode + +clean: + rm *.o *.so 2>/dev/null ; true Index: src_plugins/fontmode/Plug.tmpasm =================================================================== --- src_plugins/fontmode/Plug.tmpasm (nonexistent) +++ src_plugins/fontmode/Plug.tmpasm (revision 1316) @@ -0,0 +1,18 @@ +append /local/pcb/fontmode/enable {} +append /local/pcb/fontmode/buildin {} + +put /local/pcb/mod {fontmode} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/fontmode/fontmode.o @] + +if /local/pcb/fontmode/enable then + if /local/pcb/fontmode/buildin then + include {Makefile.in.mod/Buildin} + else + include {Makefile.in.mod/Plugin} + end +else + include {Makefile.in.mod/Disable} +end + + + Index: src_plugins/fontmode/README =================================================================== --- src_plugins/fontmode/README (nonexistent) +++ src_plugins/fontmode/README (revision 1316) @@ -0,0 +1,4 @@ +Font editing actions. + +#state: works +#default: disabled Index: src_plugins/fontmode/fontmode.c =================================================================== --- src_plugins/fontmode/fontmode.c (nonexistent) +++ src_plugins/fontmode/fontmode.c (revision 1316) @@ -0,0 +1,248 @@ +/* $Id$ */ + +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2006 DJ Delorie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA + * dj@delorie.com + * + */ + +#include "config.h" + +#include "global.h" + +#include +#include +#include + + +#include "create.h" +#include "data.h" +#include "draw.h" +#include "misc.h" +#include "move.h" +#include "remove.h" +#include "rtree.h" +#include "strflags.h" +#include "undo.h" +#include "pcb-printf.h" +#include "plugins.h" + + +RCSID("$Id$"); + +/* FIXME - we currently hardcode the grid and PCB size. What we + should do in the future is scan the font for its extents, and size + the grid appropriately. Also, when we convert back to a font, we + should search the grid for the gridlines and use them to figure out + where the symbols are. */ + +#define CELL_SIZE MIL_TO_COORD (100) +#define CELL_OFFSET MIL_TO_COORD (10) + +#define XYtoSym(x,y) ((x1 + CELL_OFFSET) / CELL_SIZE - 1 \ + + 16 * ((y1 + CELL_OFFSET) / CELL_SIZE - 1)) + +static const char fontedit_syntax[] = "FontEdit()"; + +static const char fontedit_help[] = "Convert the current font to a PCB for editing."; + +/* %start-doc actions FontEdit + +%end-doc */ + +static int FontEdit(int argc, char **argv, Coord Ux, Coord Uy) +{ + FontType *font; + SymbolType *symbol; + LayerTypePtr lfont, lorig, lwidth, lgrid; + int s, l; + + if (hid_actionl("New", "Font", 0)) + return 1; + + Settings.grid_unit = get_unit_struct("mil"); + Settings.Bloat = PCB->Bloat = 1; + Settings.Shrink = PCB->Shrink = 1; + Settings.minWid = PCB->minWid = 1; + Settings.minSlk = PCB->minSlk = 1; + + MoveLayerToGroup(max_copper_layer + COMPONENT_LAYER, 0); + MoveLayerToGroup(max_copper_layer + SOLDER_LAYER, 1); + + while (PCB->Data->LayerN > 4) + MoveLayer(4, -1); + for (l = 0; l < 4; l++) { + MoveLayerToGroup(l, l); + } + PCB->MaxWidth = CELL_SIZE * 18; + PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2); + PCB->Grid = MIL_TO_COORD(5); + PCB->Data->Layer[0].Name = strdup("Font"); + PCB->Data->Layer[1].Name = strdup("OrigFont"); + PCB->Data->Layer[2].Name = strdup("Width"); + PCB->Data->Layer[3].Name = strdup("Grid"); + hid_action("PCBChanged"); + hid_action("LayersChanged"); + + lfont = PCB->Data->Layer + 0; + lorig = PCB->Data->Layer + 1; + lwidth = PCB->Data->Layer + 2; + lgrid = PCB->Data->Layer + 3; + + font = &PCB->Font; + for (s = 0; s <= MAX_FONTPOSITION; s++) { + Coord ox = (s % 16 + 1) * CELL_SIZE; + Coord oy = (s / 16 + 1) * CELL_SIZE; + Coord w, miny, maxy, maxx = 0; + + symbol = &font->Symbol[s]; + + miny = MIL_TO_COORD(5); + maxy = font->MaxHeight; + + for (l = 0; l < symbol->LineN; l++) { + CreateDrawnLineOnLayer(lfont, + symbol->Line[l].Point1.X + ox, + symbol->Line[l].Point1.Y + oy, + symbol->Line[l].Point2.X + ox, + symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); + CreateDrawnLineOnLayer(lorig, symbol->Line[l].Point1.X + ox, + symbol->Line[l].Point1.Y + oy, + symbol->Line[l].Point2.X + ox, + symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags()); + if (maxx < symbol->Line[l].Point1.X) + maxx = symbol->Line[l].Point1.X; + if (maxx < symbol->Line[l].Point2.X) + maxx = symbol->Line[l].Point2.X; + } + w = maxx + symbol->Delta + ox; + CreateDrawnLineOnLayer(lwidth, w, miny + oy, w, maxy + oy, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); + } + + for (l = 0; l < 16; l++) { + int x = (l + 1) * CELL_SIZE; + CreateDrawnLineOnLayer(lgrid, x, 0, x, PCB->MaxHeight, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); + } + for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) { + int y = (l + 1) * CELL_SIZE; + CreateDrawnLineOnLayer(lgrid, 0, y, PCB->MaxWidth, y, MIL_TO_COORD(1), MIL_TO_COORD(1), NoFlags()); + } + return 0; +} + +static const char fontsave_syntax[] = "FontSave()"; + +static const char fontsave_help[] = "Convert the current PCB back to a font."; + +/* %start-doc actions FontSave + +%end-doc */ + +static int FontSave(int argc, char **argv, Coord Ux, Coord Uy) +{ + FontTypePtr font; + SymbolTypePtr symbol; + int i; + LineType *l; + gdl_iterator_t it; + LayerTypePtr lfont, lwidth; + + font = &PCB->Font; + lfont = PCB->Data->Layer + 0; + lwidth = PCB->Data->Layer + 2; + + for (i = 0; i <= MAX_FONTPOSITION; i++) { + font->Symbol[i].LineN = 0; + font->Symbol[i].Valid = 0; + font->Symbol[i].Width = 0; + } + + linelist_foreach(&lfont->Line, &it, l) { + int x1 = l->Point1.X; + int y1 = l->Point1.Y; + int x2 = l->Point2.X; + int y2 = l->Point2.Y; + int ox, oy, s; + + s = XYtoSym(x1, y1); + ox = (s % 16 + 1) * CELL_SIZE; + oy = (s / 16 + 1) * CELL_SIZE; + symbol = &PCB->Font.Symbol[s]; + + x1 -= ox; + y1 -= oy; + x2 -= ox; + y2 -= oy; + + if (symbol->Width < x1) + symbol->Width = x1; + if (symbol->Width < x2) + symbol->Width = x2; + symbol->Valid = 1; + + CreateNewLineInSymbol(symbol, x1, y1, x2, y2, l->Thickness); + } + + linelist_foreach(&lwidth->Line, &it, l) { + Coord x1 = l->Point1.X; + Coord y1 = l->Point1.Y; + Coord ox, s; + + s = XYtoSym(x1, y1); + ox = (s % 16 + 1) * CELL_SIZE; + symbol = &PCB->Font.Symbol[s]; + + x1 -= ox; + + symbol->Delta = x1 - symbol->Width; + } + + SetFontInfo(font); + + return 0; +} + +HID_Action fontmode_action_list[] = { + {"FontEdit", 0, FontEdit, + fontedit_help, fontedit_syntax} + , + {"FontSave", 0, FontSave, + fontsave_help, fontsave_syntax} +}; + +static const char *fontmode_cookie = "fontmode plugin"; + +REGISTER_ACTIONS(fontmode_action_list, fontmode_cookie) + +static void hid_fontmode_uninit(void) +{ + hid_remove_actions_by_cookie(fontmode_cookie); +} + +#include "dolists.h" +pcb_uninit_t hid_fontmode_init(void) +{ + REGISTER_ACTIONS(fontmode_action_list, fontmode_cookie) + return hid_fontmode_uninit; +} +