libgeda
|
functions for the text and fonts More...
#include <config.h>
#include <missing.h>
#include <stdio.h>
#include <math.h>
#include <sys/stat.h>
#include "libgeda_priv.h"
Go to the source code of this file.
Defines | |
#define | GEDA_FONT_FACTOR 1.3 |
Scale factor between legacy gschem font units and postscript points. | |
#define | PRINT_LINE_SPACING 1.12 |
Scale factor font height and line-spacing (for print only) | |
Functions | |
static void | update_disp_string (OBJECT *object) |
update the visible part of a string | |
int | world_get_text_bounds (TOPLEVEL *toplevel, OBJECT *o_current, int *left, int *top, int *right, int *bottom) |
calculate and return the boundaries of a text object | |
gboolean | o_text_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object) |
get the position of a text object | |
int | o_text_num_lines (const char *string) |
count the lines of a text string | |
OBJECT * | o_text_new (TOPLEVEL *toplevel, char type, int color, int x, int y, int alignment, int angle, const char *string, int size, int visibility, int show_name_value) |
Creates a text OBJECT and the graphical objects representing it. | |
void | o_text_recalc (TOPLEVEL *toplevel, OBJECT *o_current) |
update the visual boundaries of the text object | |
OBJECT * | o_text_read (TOPLEVEL *toplevel, const char *first_line, TextBuffer *tb, unsigned int release_ver, unsigned int fileformat_ver, GError **err) |
read a text object from a char buffer | |
char * | o_text_save (TOPLEVEL *toplevel, OBJECT *object) |
Create a string representation of the text object. | |
void | o_text_recreate (TOPLEVEL *toplevel, OBJECT *o_current) |
recreate the graphics of a text object | |
void | o_text_translate_world (TOPLEVEL *toplevel, int dx, int dy, OBJECT *o_current) |
move a text object | |
OBJECT * | o_text_copy (TOPLEVEL *toplevel, OBJECT *o_current) |
create a copy of a text object | |
void | o_text_print_text_string (FILE *fp, char *string, int unicode_count, gunichar *unicode_table) |
write a text string to a postscript file | |
void | o_text_print (TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y, int unicode_count, gunichar *unicode_table) |
print a text object into a postscript file | |
void | o_text_rotate_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object) |
rotate a text object around a centerpoint | |
void | o_text_mirror_world (TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object) |
mirror a text object horizontaly at a centerpoint | |
double | o_text_shortest_distance (OBJECT *object, int x, int y, int force_solid) |
Calculates the distance between the given point and the closest point on the text. | |
void | o_text_set_string (TOPLEVEL *toplevel, OBJECT *obj, const gchar *new_string) |
Set the string displayed by a text object. | |
const gchar * | o_text_get_string (TOPLEVEL *toplevel, OBJECT *obj) |
Get the string displayed by a text object. | |
void | o_text_set_rendered_bounds_func (TOPLEVEL *toplevel, RenderedBoundsFunc func, void *user_data) |
Set the font-renderer-specific bounds function. | |
double | o_text_get_font_size_in_points (TOPLEVEL *toplevel, OBJECT *object) |
Return font size of a text object in postscript points. | |
Variables | |
int | tab_in_chars = 8 |
Each letter of the font is defined in a single font symbol file. In the font symbol file, the character width is defined in the second line. The first line contains the file format version.
All remaining lines are basic graphical lines. They build the appearance of the character.
The height of capital characters in the font files is 26. The size of small letters is 16. The space below the zero line is used by characters like g, p or q. The space above 26 is used by diacritic marks like accents, breve, circumflex mostly in european characters.
The text is stored and printed in several different representations.
In the gEDA files the text is just a string. It is stored unmodified in OBJECT->text->string.
If the string is an attribute with an equal sign as delimiter between an attribute name and an attribute value, then it is possible to hide some parts of the text. The still visible part of an attribute is stored in OBJECT->text->disp_string.
To draw the text in gschem, the string is interpreted and converted to a list of basic graphical objects. The basic line objects are collected from the font character objects.
Definition in file o_text_basic.c.
#define GEDA_FONT_FACTOR 1.3 |
The following factor was impirically determined to approximately match the cap-height between the legacy gschem font, and fonts rendered using pango.
Definition at line 91 of file o_text_basic.c.
#define PRINT_LINE_SPACING 1.12 |
Definition at line 99 of file o_text_basic.c.
static void update_disp_string | ( | OBJECT * | object | ) | [static] |
[in] | object | The OBJECT to update |
Definition at line 113 of file o_text_basic.c.
int world_get_text_bounds | ( | TOPLEVEL * | toplevel, |
OBJECT * | o_current, | ||
int * | left, | ||
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | o_current | a text object |
[out] | left | the left world coord |
[out] | top | the top world coord |
[out] | right | the right world coord |
[out] | bottom | the bottom world coord |
Definition at line 166 of file o_text_basic.c.
[in] | toplevel | The toplevel environment. |
[out] | x | pointer to the x-position |
[out] | y | pointer to the y-position |
[in] | object | The object to get the position. |
Definition at line 189 of file o_text_basic.c.
int o_text_num_lines | ( | const char * | string | ) |
[in] | string | text string to count the lines |
Definition at line 206 of file o_text_basic.c.
OBJECT* o_text_new | ( | TOPLEVEL * | toplevel, |
char | type, | ||
int | color, | ||
int | x, | ||
int | y, | ||
int | alignment, | ||
int | angle, | ||
const char * | string, | ||
int | size, | ||
int | visibility, | ||
int | show_name_value | ||
) |
[in] | toplevel | The TOPLEVEL object. |
[in] | type | OBJ_TEXT (TODO: why bother) |
[in] | color | The color of the text. |
[in] | x | World x coord of text. |
[in] | y | World y coord of text. |
[in] | alignment | How text bounding box aligns on (x, y). |
[in] | angle | Angle at which text will appear. |
[in] | string | The text (TODO: can be char const *)! |
[in] | size | Text size. |
[in] | visibility | VISIBLE or INVISIBLE. |
[in] | show_name_value | SHOW_NAME_VALUE or friends. |
Definition at line 251 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object |
[in] | o_current | The OBJECT to update |
Definition at line 297 of file o_text_basic.c.
OBJECT* o_text_read | ( | TOPLEVEL * | toplevel, |
const char * | first_line, | ||
TextBuffer * | tb, | ||
unsigned int | release_ver, | ||
unsigned int | fileformat_ver, | ||
GError ** | err | ||
) |
[in] | toplevel | The TOPLEVEL object |
[in] | first_line | the first line of the text |
[in] | tb | a text buffer (usually a line of a schematic file) |
[in] | release_ver | The release number gEDA |
[in] | fileformat_ver | a integer value of the file format |
Definition at line 330 of file o_text_basic.c.
[in] | toplevel | a TOPLEVEL structure |
[in] | object | a text OBJECT |
Definition at line 485 of file o_text_basic.c.
toplevel | The TOPLEVEL object |
o_current | The text object to update |
Definition at line 519 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object |
[in] | dx | The x-distance to move the object |
[in] | dy | The y-distance to move the object |
[in] | o_current | The text OBJECT to be moved |
Definition at line 536 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object |
[in] | o_current | The object that is copied |
Definition at line 554 of file o_text_basic.c.
void o_text_print_text_string | ( | FILE * | fp, |
char * | string, | ||
int | unicode_count, | ||
gunichar * | unicode_table | ||
) |
[in] | fp | pointer to a FILE structure |
[in] | string | The string to print |
[in] | unicode_count | Number of items in the unicode table |
[in] | unicode_table | Table of unicode items |
Definition at line 582 of file o_text_basic.c.
void o_text_print | ( | TOPLEVEL * | toplevel, |
FILE * | fp, | ||
OBJECT * | o_current, | ||
int | origin_x, | ||
int | origin_y, | ||
int | unicode_count, | ||
gunichar * | unicode_table | ||
) |
[in] | toplevel | The TOPLEVEL object |
[in] | fp | pointer to a FILE structure |
[in] | o_current | The OBJECT to print |
[in] | origin_x | x-coord of the postscript origin |
[in] | origin_y | y-coord of the postscript origin |
[in] | unicode_count | Number of items in the unicode table |
[in] | unicode_table | Table of unicode items |
Definition at line 643 of file o_text_basic.c.
void o_text_rotate_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
int | angle, | ||
OBJECT * | object | ||
) |
[in] | toplevel | The TOPLEVEL object |
[in] | world_centerx | x-coord of the rotation center |
[in] | world_centery | y-coord of the rotation center |
[in] | angle | The angle to rotate the text object |
[in] | object | The text object |
Definition at line 808 of file o_text_basic.c.
void o_text_mirror_world | ( | TOPLEVEL * | toplevel, |
int | world_centerx, | ||
int | world_centery, | ||
OBJECT * | object | ||
) |
[in] | toplevel | The TOPLEVEL object |
[in] | world_centerx | x-coord of the mirror position |
[in] | world_centery | y-coord of the mirror position |
[in] | object | The text object |
Definition at line 844 of file o_text_basic.c.
double o_text_shortest_distance | ( | OBJECT * | object, |
int | x, | ||
int | y, | ||
int | force_solid | ||
) |
This function will calculate the distance to the text regardless if the text is visible or not.
[in] | object | The text OBJECT. |
[in] | x | The x coordinate of the given point. |
[in] | y | The y coordinate of the given point. |
[in] | force_solid | If true, force treating the object as solid. |
Definition at line 938 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | obj | The text object. |
[in] | new_string | The new value. |
Definition at line 961 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object. |
[in] | obj | The text object. |
Definition at line 990 of file o_text_basic.c.
void o_text_set_rendered_bounds_func | ( | TOPLEVEL * | toplevel, |
RenderedBoundsFunc | func, | ||
void * | user_data | ||
) |
[in] | toplevel | The TOPLEVEL object |
[in] | func | Function to use. |
[in] | user_data | User data to be passed to the function. |
Definition at line 1009 of file o_text_basic.c.
[in] | toplevel | The TOPLEVEL object |
[in] | object | The text OBJECT whos font size to return |
Definition at line 1028 of file o_text_basic.c.
int tab_in_chars = 8 |
Size of a tab in characters
Definition at line 102 of file o_text_basic.c.