User Tools

Site Tools


geda:pcb_fonts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
geda:pcb_fonts [2016/12/01 09:12]
cparker [File Load]
geda:pcb_fonts [2016/12/06 09:03] (current)
cparker [File Load]
Line 96: Line 96:
 A font file can have one or more fonts defined in succession. A font file can have one or more fonts defined in succession.
 ====PCB File Format Changes==== ====PCB File Format Changes====
 +===Embedded Font Syntax===
 A single addition to the file format has been implemented. That's the Font directive that was described above. That directive can have two meanings. Fonts can be embedded in regular pcb files using the same syntax as above. The only caveat is that the font must be defined early in the file, between the styles and the layout data. A single addition to the file format has been implemented. That's the Font directive that was described above. That directive can have two meanings. Fonts can be embedded in regular pcb files using the same syntax as above. The only caveat is that the font must be defined early in the file, between the styles and the layout data.
  
 The Font directive can also be included without symbols. If it appears this way, then the argument is considered to be the PCB Default Font. This font is made the current font and is used for all reference designators and for any text objects that are not explicitly assigned a font. The Font directive can also be included without symbols. If it appears this way, then the argument is considered to be the PCB Default Font. This font is made the current font and is used for all reference designators and for any text objects that are not explicitly assigned a font.
 +
 +===Text Syntax===
 +There is also an addition to the text syntax. It's labeled in ''​parse_y.y''​ as ''​text_20161008_format''​. This is the same as ''​text_hi_format''​ with the addition of a second string field. The second string field is interpreted as the font. Here's the syntax definition:
 +<​code>​
 +text_20161008_format
 + /* x, y, direction, scale, text, font, flags */
 + : T_TEXT '​['​ measure measure number number STRING STRING flags '​]'​
 + {
 +                FontType * font = FindFont($8);​
 +                if(!font) Message(_("​Warning:​ Could not find font %s for text \"​%s\"​\n"​),​ $8, $7);
 + CreateNewText(Layer,​ font, NU ($3), NU ($4), $5, $6, $7, $9);
 + free ($7);
 +                free ($8);
 + }
 + ;
 +
 +</​code>​
 =====Actions===== =====Actions=====
 ====Change Font==== ====Change Font====
Line 164: Line 182:
 The font system is initialized in the ''​settings_post_process''​ function (''​main.c''​). Here, the ''​font-file''​ is searched for in the ''​font-path''​(s) and loaded. Then the ''​font-path''​(s) are searched by the ''​ScanFontPaths''​ function (''​font.c''​) for any files that have a ''​.pcb_font''​ extension, and these files are read looking for font information. The font system is initialized in the ''​settings_post_process''​ function (''​main.c''​). Here, the ''​font-file''​ is searched for in the ''​font-path''​(s) and loaded. Then the ''​font-path''​(s) are searched by the ''​ScanFontPaths''​ function (''​font.c''​) for any files that have a ''​.pcb_font''​ extension, and these files are read looking for font information.
 ====File Load==== ====File Load====
-The loading of a pcb file has two parts: 1. the actual reading of data from the file and converting it into pcb data structures, and 2. initializing pcb with the new data. (1) is implemented using bison/flex in ''​parse_y.y''​ and ''​parse_l.l''​. (2) is implemented in ''​file.c''​ in the ''​real_load_pcb''​ function.+The loading of a pcb file has two parts: 1. the actual reading of data from the file and converting it into pcb data structures, and 2. applying policy to the loaded ​data. (1) is implemented using bison/flex in ''​parse_y.y''​ and ''​parse_l.l''​. (2) is implemented in ''​file.c''​ in the ''​real_load_pcb''​ function.
  
 ===Reading Data From Files Into Data Structures=== ===Reading Data From Files Into Data Structures===
 ==Font Data== ==Font Data==
-Font data is required to be located after style data and before object data in the pcb file (this is a requirement from before the font system that results from the definition of the file grammar). The variable ''​yyFont''​ acts as the global pointer to the current font. When font data (an embedded font or floating symbols) is found a new font instance is created in the appropriate library (depending on whether ''​yyPCB''​ is NULL), and subsequent symbols are added to that. If a new font is found, a new font instance is created and yyFont is updated to point at the new font. If only the font directive is found (no symbols), then the ''​DefaultFontName''​ field of the PCBType structure is updated with the name. (I've been inconsistent in the docs about referring to this font name as both the ''​PCBDefaultFont''​ and the ''​DefaultPCBFont''​)+Font data is required to be located after style data and before object data in the pcb file (this is a requirement from before the font system that results from the definition of the file grammar). The variable ''​yyFont''​ acts as the global pointer to the current font. When font data (an embedded font or floating symbols) is found a new font instance is created in the appropriate library (depending on whether ''​yyPCB''​ is NULL, if not we're loading a pcb file, otherwise we're loading a font file), and subsequent symbols are added to that. If a new font is found, a new font instance is created and yyFont is updated to point at the new font. If only the font directive is found (no symbols), then the ''​DefaultFontName''​ field of the PCBType structure is updated with the name. (I've been inconsistent in the docs about referring to this font name as both the ''​PCBDefaultFont''​ and the ''​DefaultPCBFont''​)
 ==Text Data== ==Text Data==
 When text data is read from the file, it will either use the standard format, in which case the font pointer is initially set to NULL, or it will have a font specified, in which case the specified font is searched for in the font library (embedded library first). If the font is not found, then the font pointer is set to NULL. In post processing, any text object that has a NULL font pointer is set to the ''​DefaultPCBFont''​. If the ''​DefaultPCBFont''​ is NULL, then the font pointers remain set to NULL. This could happen if this is a pcb file from an older version that has no font information. When the font pointer of a text object is NULL, it is displayed using the system font instead. So, it's possible to completely ignore the font system, change the system font, and in doing so change the font of every bit of text on the board (including refdes). When text data is read from the file, it will either use the standard format, in which case the font pointer is initially set to NULL, or it will have a font specified, in which case the specified font is searched for in the font library (embedded library first). If the font is not found, then the font pointer is set to NULL. In post processing, any text object that has a NULL font pointer is set to the ''​DefaultPCBFont''​. If the ''​DefaultPCBFont''​ is NULL, then the font pointers remain set to NULL. This could happen if this is a pcb file from an older version that has no font information. When the font pointer of a text object is NULL, it is displayed using the system font instead. So, it's possible to completely ignore the font system, change the system font, and in doing so change the font of every bit of text on the board (including refdes).
Line 174: Line 192:
 ==Element Data== ==Element Data==
 The format of element data in pcb files doesn'​t presently include font information,​ so individual font cannot be stored for individual ref des. New elements are created via the ''​CreateNewElement''​ function (''​create.c''​) which adds text to the element via the ''​AddTextToElement''​ function (''​create.c''​). This function searches for the ''​PCBDefaultFont'',​ and assigns that if it's found, or NULL otherwise. The format of element data in pcb files doesn'​t presently include font information,​ so individual font cannot be stored for individual ref des. New elements are created via the ''​CreateNewElement''​ function (''​create.c''​) which adds text to the element via the ''​AddTextToElement''​ function (''​create.c''​). This function searches for the ''​PCBDefaultFont'',​ and assigns that if it's found, or NULL otherwise.
 +
 +===Post Loading Policy===
 +The policy defines how to handle objects that need fonts but were not assigned one during load. This is the magic that will hopefully make pcb "do the right thing" when loading older versions of pcb files.
 +
 +==System Font and Default Font Name==
 +The first (font related) thing pcb tries to do after loading all the data from a pcb file is figure out if it needs to change the current system font. If a ''​DefaultFontName''​ was specified, the system font is changed to this font. If we're dealing with an older file, there will be no ''​DefaultFontName''​ specified, but there still might be font data in the file (as loose symbols), and if there is, then it should be used. Symbol data gets loaded as a font in the embedded library, so if there are any fonts in the embedded library, the first one is set to be the system font. (Is this behavior okay if there are embedded fonts but no default font?)
 +
 +==Text Data==
 +After loading all data, 
 +
 ====File Save==== ====File Save====
 =====To Do List===== =====To Do List=====
 These are tasks and ideas related to the font subsystem that still need to be done, could be done, or are in progress: These are tasks and ideas related to the font subsystem that still need to be done, could be done, or are in progress:
 +  * Move work done in ChangeFontAction to separate function to isolate the work from the undo serial number increment
 +  * Check what happens when loading a font file if a ''​DefaultFontName''​ is specified
 +  * Add licensing info to font files
   * Add fonts to install (and figure out where they should go)   * Add fonts to install (and figure out where they should go)
   * Write test scripts   * Write test scripts
Line 183: Line 214:
   * Font preview in settings window   * Font preview in settings window
   * Character map for selecting non standard characters   * Character map for selecting non standard characters
-  * Add licensing info to font files 
   * User control of fonts in embedded library   * User control of fonts in embedded library
   * Save font(s) to a file   * Save font(s) to a file
   * "Font mode" saving of fonts to font files.   * "Font mode" saving of fonts to font files.
geda/pcb_fonts.1480601564.txt.gz ยท Last modified: 2016/12/01 09:12 by cparker