]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_text.cpp
Fixed problem with dimensions not showing up.
[architektonas] / src / base / rs_text.cpp
index 56a8cf75e5135a847956ef164191610ac9c7d91f..9d1c4066936f850485589f3fb44c64cb38df4dbe 100644 (file)
@@ -61,12 +61,10 @@ int RS_Text::getNumberOfLines()
 {
        int c = 1;
 
-       for(int i=0; i<(int)data.text.length(); ++i)
+       for(int i=0; i<(int)data.text.length(); i++)
        {
                if (data.text.at(i).unicode() == 0x0A)
-               {
                        c++;
-               }
        }
 
        return c;
@@ -79,19 +77,30 @@ int RS_Text::getNumberOfLines()
  */
 void RS_Text::update()
 {
+#if 0
+printf("RS_Text::update(): ");
+#endif
        RS_DEBUG->print("RS_Text::update");
-
        clear();
 
+#if 0
+printf("isUndone=%s, ", (isUndone() ? "true" : "false"));
+#endif
        if (isUndone())
                return;
 
        usedTextWidth = 0.0;
        usedTextHeight = 0.0;
 
+#if 0
+printf("data.style=\"%s\", ", data.style.toAscii().data());
+#endif
        RS_Font * font = RS_FONTLIST->requestFont(data.style);
 
-       if (font == NULL)
+#if 0
+printf("font=%08X\n", (unsigned int)font);
+#endif
+       if (!font)
                return;
 
        Vector letterPos = Vector(0.0, -9.0);
@@ -173,23 +182,17 @@ void RS_Text::update()
 
                                // add texts:
                                RS_Text * upper = new RS_Text(oneLine,
-                                       RS_TextData(letterPos + Vector(0.0, 9.0),
-                                               4.0, 100.0, RS2::VAlignTop,
-                                               RS2::HAlignLeft,
-                                               RS2::LeftToRight, RS2::Exact,
-                                               1.0, up, data.style,
-                                               0.0, RS2::Update));
+                                       RS_TextData(letterPos + Vector(0.0, 9.0), 4.0, 100.0,
+                                               RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight,
+                                               RS2::Exact, 1.0, up, data.style, 0.0, RS2::Update));
                                upper->setLayer(NULL);
                                upper->setPen(RS_Pen(RS2::FlagInvalid));
                                oneLine->addEntity(upper);
 
                                RS_Text * lower = new RS_Text(oneLine,
-                                       RS_TextData(letterPos+Vector(0.0, 4.0),
-                                               4.0, 100.0, RS2::VAlignTop,
-                                               RS2::HAlignLeft,
-                                               RS2::LeftToRight, RS2::Exact,
-                                               1.0, dw, data.style,
-                                               0.0, RS2::Update));
+                                       RS_TextData(letterPos+Vector(0.0, 4.0), 4.0, 100.0,
+                                               RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight,
+                                               RS2::Exact, 1.0, dw, data.style, 0.0, RS2::Update));
                                lower->setLayer(NULL);
                                lower->setPen(RS_Pen(RS2::FlagInvalid));
                                oneLine->addEntity(lower);
@@ -218,14 +221,32 @@ void RS_Text::update()
 
                default:
                {
+// Regular text works because the .style is "normallatin1" while the dimensions are done
+// using "standard"... So that's why it doesn't work.
+// "standard" exists, but it seems that no characters are loaded from it...
+//count() == 0...
+//printf("--> default: pos=%d, char=%04X, font size=%d\n", i, data.text.at(i).unicode(), font->getLetterList()->count());
                        // One Letter:
-                       if (font->findLetter(QString(data.text.at(i))) != NULL)
+//#warning "!!! font->findLetter() not working correctly !!!"
+                       if (font->findLetter(QString(data.text.at(i))))
                        {
-                               RS_DEBUG->print("RS_Text::update: insert a "
-                               "letter at pos: %f/%f", letterPos.x, letterPos.y);
-
+//We ain't getting here:
+/*
+About to draw TEXT entity... TEXT="107.25"
+RS_Dimension::updateCreateDimensionLine()...
+--> 107.25
+RS_Text::update(): isUndone=false, font=094C1020
+--> default: pos=0, char=0031
+--> default: pos=1, char=0030
+--> default: pos=2, char=0037
+--> default: pos=3, char=002E
+--> default: pos=4, char=0032
+--> default: pos=5, char=0035
+*/
+//printf("             char=%s\n", QString(data.text.at(i)).toAscii().data());
+                               RS_DEBUG->print("RS_Text::update: insert a letter at pos: %f/%f", letterPos.x, letterPos.y);
                                RS_InsertData d(QString(data.text.at(i)), letterPos, Vector(1.0, 1.0),
-                                       0.0, 1,1, Vector(0.0, 0.0), font->getLetterList(), RS2::NoUpdate);
+                                       0.0, 1, 1, Vector(0.0, 0.0), font->getLetterList(), RS2::NoUpdate);
 
                                RS_Insert * letter = new RS_Insert(this, d);
                                letter->setPen(RS_Pen(RS2::FlagInvalid));
@@ -237,7 +258,6 @@ void RS_Text::update()
                                //letterWidth = Vector(letter->getSize().x, 0.0);
                                // from 2.0.4.6:
                                Vector letterWidth = Vector(letter->getMax().x - letterPos.x, 0.0);
-
                                oneLine->addEntity(letter);
 
                                // next letter position:
@@ -566,7 +586,6 @@ VectorSolutions RS_Text::getRefPoints()
 
 Vector RS_Text::getNearestRef(const Vector & coord, double * dist)
 {
-       //return getRefPoints().getClosest(coord, dist);
        return RS_Entity::getNearestRef(coord, dist);
 }