[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (cc9904cb4abee08306127dc85f1a8e523db5651f)
The branch, master has been updated
via cc9904cb4abee08306127dc85f1a8e523db5651f (commit)
via 9baa48602f5253ca71301585ddd7bb1a3b761981 (commit)
via 55f95c6cd266a261961245f9571ff91bcc45c74d (commit)
from 2d21a8ad8f38e07b17450450a096f1ce4b3bef0e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
globalconst.h | 3 +
src/change.c | 4 +-
src/draw.c | 6 ++-
src/misc.c | 115 ++++++++++++++++++++++++++++++--------------------------
src/report.c | 4 +-
5 files changed, 73 insertions(+), 59 deletions(-)
=================
Commit Messages
=================
commit cc9904cb4abee08306127dc85f1a8e523db5651f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
misc.c: Rework SetTextBoundingBox() to make it more clear how it works.
Add lots of comments, change the coding style and rename variables to make
them more obvious.
:100644 100644 7c6f958... af1e58f... M src/misc.c
commit 9baa48602f5253ca71301585ddd7bb1a3b761981
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Redefine pin / pad name label text size in terms of FONT_CAPHEIGHT
This reduces the proliferation of various "magic numbers" which
combine constants from several sources and aren't appearent why
they are a particular number. There is a slight rounding error
in the converted pin label size, but it is insignificant.
:100644 100644 1315707... 7d7a594... M src/draw.c
commit 55f95c6cd266a261961245f9571ff91bcc45c74d
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Introduce global #define for the text cap-height of the PCB font.
This should save the proliferation of rather opaque MIL_TO_COORD(45)'s
in various places.
:100755 100755 1cf29b6... e85b360... M globalconst.h
:100644 100644 97154fd... 5d44355... M src/change.c
:100644 100644 deb6095... f640ef0... M src/report.c
=========
Changes
=========
commit cc9904cb4abee08306127dc85f1a8e523db5651f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
misc.c: Rework SetTextBoundingBox() to make it more clear how it works.
Add lots of comments, change the coding style and rename variables to make
them more obvious.
diff --git a/src/misc.c b/src/misc.c
index 7c6f958..af1e58f 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -497,76 +497,85 @@ SetTextBoundingBox (FontTypePtr FontPtr, TextTypePtr Text)
{
SymbolTypePtr symbol = FontPtr->Symbol;
unsigned char *s = (unsigned char *) Text->TextString;
- Coord minThick = 0;
int i;
- int space = 0;
+ int space;
Coord minx, miny, maxx, maxy, tx;
- int first_time = 1;
+ Coord min_final_radius;
+ Coord min_unscaled_radius;
+ bool first_time = true;
minx = miny = maxx = maxy = tx = 0;
- if (PCB->minSlk < PCB->minWid)
- minThick = PCB->minWid;
- else
- minThick = PCB->minSlk;
+ /* Calculate the bounding box based on the larger of the thicknesses
+ * the text might clamped at on silk or copper layers.
+ */
+ min_final_radius = MAX (PCB->minWid, PCB->minSlk) / 2;
- minThick /= Text->Scale / 50.0;
+ /* Pre-adjust the line radius for the fact we are initially computing the
+ * bounds of the un-scaled text, and the thickness clamping applies to
+ * scaled text.
+ */
+ min_unscaled_radius = min_final_radius * 100 / Text->Scale;
/* calculate size of the bounding box */
for (; s && *s; s++)
{
if (*s <= MAX_FONTPOSITION && symbol[*s].Valid)
- {
- LineTypePtr line = symbol[*s].Line;
- for (i = 0; i < symbol[*s].LineN; line++, i++)
- {
- Coord t = line->Thickness / 4;
- if (t < minThick)
- t = minThick;
-
- if (first_time)
- {
- minx = maxx = line->Point1.X;
- miny = maxy = line->Point1.Y;
- first_time = 0;
- }
+ {
+ LineTypePtr line = symbol[*s].Line;
+ for (i = 0; i < symbol[*s].LineN; line++, i++)
+ {
+ /* Clamp the width of text lines at the minimum thickness.
+ * NB: Divide 4 in thickness calculation is comprised of a factor
+ * of 1/2 to get a radius from the center-line, and a factor
+ * of 1/2 because some stupid reason we render our glyphs
+ * at half their defined stroke-width.
+ */
+ Coord unscaled_radius = MAX (min_unscaled_radius, line->Thickness / 4);
+
+ if (first_time)
+ {
+ minx = maxx = line->Point1.X;
+ miny = maxy = line->Point1.Y;
+ first_time = false;
+ }
- minx = MIN (minx, line->Point1.X - t + tx);
- miny = MIN (miny, line->Point1.Y - t);
- minx = MIN (minx, line->Point2.X - t + tx);
- miny = MIN (miny, line->Point2.Y - t);
- maxx = MAX (maxx, line->Point1.X + t + tx);
- maxy = MAX (maxy, line->Point1.Y + t);
- maxx = MAX (maxx, line->Point2.X + t + tx);
- maxy = MAX (maxy, line->Point2.Y + t);
- }
- space = symbol[*s].Delta;
- }
+ minx = MIN (minx, line->Point1.X - unscaled_radius + tx);
+ miny = MIN (miny, line->Point1.Y - unscaled_radius);
+ minx = MIN (minx, line->Point2.X - unscaled_radius + tx);
+ miny = MIN (miny, line->Point2.Y - unscaled_radius);
+ maxx = MAX (maxx, line->Point1.X + unscaled_radius + tx);
+ maxy = MAX (maxy, line->Point1.Y + unscaled_radius);
+ maxx = MAX (maxx, line->Point2.X + unscaled_radius + tx);
+ maxy = MAX (maxy, line->Point2.Y + unscaled_radius);
+ }
+ space = symbol[*s].Delta;
+ }
else
- {
- BoxType *ds = &FontPtr->DefaultSymbol;
- Coord w = ds->X2 - ds->X1;
-
- minx = MIN (minx, ds->X1 + tx);
- miny = MIN (miny, ds->Y1);
- minx = MIN (minx, ds->X2 + tx);
- miny = MIN (miny, ds->Y2);
- maxx = MAX (maxx, ds->X1 + tx);
- maxy = MAX (maxy, ds->Y1);
- maxx = MAX (maxx, ds->X2 + tx);
- maxy = MAX (maxy, ds->Y2);
-
- space = w / 5;
- }
+ {
+ BoxType *ds = &FontPtr->DefaultSymbol;
+ Coord w = ds->X2 - ds->X1;
+
+ minx = MIN (minx, ds->X1 + tx);
+ miny = MIN (miny, ds->Y1);
+ minx = MIN (minx, ds->X2 + tx);
+ miny = MIN (miny, ds->Y2);
+ maxx = MAX (maxx, ds->X1 + tx);
+ maxy = MAX (maxy, ds->Y1);
+ maxx = MAX (maxx, ds->X2 + tx);
+ maxy = MAX (maxy, ds->Y2);
+
+ space = w / 5;
+ }
tx += symbol[*s].Width + space;
}
/* scale values */
- minx *= Text->Scale / 100.;
- miny *= Text->Scale / 100.;
- maxx *= Text->Scale / 100.;
- maxy *= Text->Scale / 100.;
+ minx = minx * Text->Scale / 100;
+ miny = miny * Text->Scale / 100;
+ maxx = maxx * Text->Scale / 100;
+ maxy = maxy * Text->Scale / 100;
/* set upper-left and lower-right corner;
* swap coordinates if necessary (origin is already in 'swapped')
commit 9baa48602f5253ca71301585ddd7bb1a3b761981
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Redefine pin / pad name label text size in terms of FONT_CAPHEIGHT
This reduces the proliferation of various "magic numbers" which
combine constants from several sources and aren't appearent why
they are a particular number. There is a slight rounding error
in the converted pin label size, but it is insignificant.
diff --git a/src/draw.c b/src/draw.c
index 1315707..7d7a594 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -199,7 +199,8 @@ _draw_pv_name (PinType *pv)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = 100 * pv->Thickness / MIL_TO_COORD (80);
+ /* Set font height to approx 56% of pin thickness */
+ text.Scale = 56 * pv->Thickness / FONT_CAPHEIGHT;
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
@@ -284,7 +285,8 @@ draw_pad_name (PadType *pad)
gui->set_color (Output.fgGC, PCB->PinNameColor);
text.Flags = NoFlags ();
- text.Scale = 100 * pad->Thickness / MIL_TO_COORD (50);
+ /* Set font height to approx 90% of pin thickness */
+ text.Scale = 90 * pad->Thickness / FONT_CAPHEIGHT;
text.X = box.X1;
text.Y = box.Y1;
text.Direction = vert ? 1 : 0;
commit 55f95c6cd266a261961245f9571ff91bcc45c74d
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
Introduce global #define for the text cap-height of the PCB font.
This should save the proliferation of rather opaque MIL_TO_COORD(45)'s
in various places.
diff --git a/globalconst.h b/globalconst.h
index 1cf29b6..e85b360 100755
--- a/globalconst.h
+++ b/globalconst.h
@@ -126,4 +126,7 @@
/* to enable grid drawing */
/* size of diamond element mark */
#define EMARK_SIZE MIL_TO_COORD (10)
+
+/* (Approximate) capheight size of the default PCB font */
+#define FONT_CAPHEIGHT MIL_TO_COORD (45)
#endif
diff --git a/src/change.c b/src/change.c
index 97154fd..5d44355 100644
--- a/src/change.c
+++ b/src/change.c
@@ -839,7 +839,7 @@ static void *
ChangeTextSize (LayerTypePtr Layer, TextTypePtr Text)
{
int value = (Absolute != 0 ? Text->Scale : 0) +
- (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
+ (Absolute != 0 ? Absolute : Delta) * 100 / FONT_CAPHEIGHT;
if (TEST_FLAG (LOCKFLAG, Text))
return (NULL);
@@ -915,7 +915,7 @@ static void *
ChangeElementNameSize (ElementTypePtr Element)
{
int value = (Absolute != 0 ? DESCRIPTION_TEXT (Element).Scale : 0) +
- (Absolute != 0 ? Absolute : Delta) * 100 / MIL_TO_COORD (45);
+ (Absolute != 0 ? Absolute : Delta) * 100 / FONT_CAPHEIGHT;
if (TEST_FLAG (LOCKFLAG, &Element->Name[0]))
return (NULL);
diff --git a/src/report.c b/src/report.c
index deb6095..f640ef0 100644
--- a/src/report.c
+++ b/src/report.c
@@ -423,7 +423,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
EMPTY (element->Name[0].TextString),
EMPTY (element->Name[1].TextString),
EMPTY (element->Name[2].TextString),
- (Coord) (MIL_TO_COORD (45) * element->Name[1].Scale / 100.),
+ (Coord) (FONT_CAPHEIGHT * element->Name[1].Scale / 100.),
element->Name[1].X, element->Name[1].Y,
TEST_FLAG (HIDENAMEFLAG, element) ? ",\n but it's hidden" : "",
element->MarkX, element->MarkY,
@@ -464,7 +464,7 @@ ReportDialog (int argc, char **argv, Coord x, Coord y)
"The bounding box is %$mD %$mD.\n"
"%s\n"
"%s", USER_UNITMASK, text->ID, flags_to_string (text->Flags, TEXT_TYPE),
- text->X, text->Y, (Coord) (MIL_TO_COORD (45) * (float)text->Scale / 100.),
+ text->X, text->Y, (Coord) (FONT_CAPHEIGHT * (float)text->Scale / 100.),
text->TextString, text->Direction,
text->BoundingBox.X1, text->BoundingBox.Y1,
text->BoundingBox.X2, text->BoundingBox.Y2,
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs