X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_text.cpp;h=59915160c1cb3c12bbe3f71ddae95f458330d7df;hb=20cce16e98fc9b052c5862efa6394a285971e846;hp=56a8cf75e5135a847956ef164191610ac9c7d91f;hpb=89e127aa3dbd74d3158e6dbe0ca1703420c04395;p=architektonas diff --git a/src/base/rs_text.cpp b/src/base/rs_text.cpp index 56a8cf7..5991516 100644 --- a/src/base/rs_text.cpp +++ b/src/base/rs_text.cpp @@ -3,7 +3,9 @@ // Part of the Architektonas Project // Originally part of QCad Community Edition by Andrew Mustun // Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software +// Portions copyright (C) 2001-2003 RibbonSoft +// Copyright (C) 2010 Underground Software +// See the README and GPLv2 files for licensing and warranty information // // JLH = James L. Hammons // @@ -61,12 +63,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 +79,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 +184,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 +223,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 +260,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 +588,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); }