void SVGTextContentElement::setFont(svgl::Context * svglContext, svgl::GLInfo* glinfo, svgl::TextInfo*) { const css::CSSStyleDeclaration& style = getStyle().getValue(); //const css::Color * fill = style.getFill(); // test if it's a gradient... css::CSSStyle::FontFamilyType fontfamily = style.getFontFamily(); css::CSSStyle::FontStyleType fontstyle = style.getFontStyle(); css::CSSStyle::FontWeightType fontweight = style.getFontWeight(); css::CSSStyle::FontSizeType sizel = style.getFontSize(); unsigned int size = (unsigned int) svglContext->computeWidthLength(sizel); // int bbx=0,bby=0,width=0,height=0; //std::cerr << fontfamily << __FL__; #if 1 glft::FontInfo f; //std::cerr << DBGVAR(fontfamily) << DBGVAR(fontstyle) << DBGVAR(fontweight) << __FL__; setFontInfo(f, fontfamily, fontstyle, fontweight); //std::cerr << f.family << " " << glft::FontInfo::styleDesc[f.style] << " " << glft::FontInfo::weightDesc[f.weight] << __FL__; svglContext->fontManager->setCurrentFont(f, size); svglContext->fontSize=size; #if 0 const css::URIColor * gradColor = dynamic_cast<const css::URIColor *>(fill); if(!gradColor) { svglContext->fontManager->setAutoScale(true); } else { svglContext->fontManager->setAutoScale(false); svglContext->fontManager->setFontType(svgl::FontManager::vector); } #endif #else // if size if small and this is not a gradient svgl::FontInfo f; setFontInfo(f, fontfamily, fontstyle, fontweight); svglContext->fontManager->setCurrentFont(f, size); svglContext->fontSize=size; if(size<20 && !gradColor) { svglContext->fontManager->setFontType(svgl::FontManager::texture); } else { svglContext->fontManager->setFontType(svgl::FontManager::vector); } //svglContext->fontManager->setCurrentFont(unicode::String::internString(fontname), static_cast<int>(size)); #endif }
rspfAnnotationFontObject::rspfAnnotationFontObject(const rspfIpt& upperLeft, const rspfString& s, const rspfIpt& pixelSize, double rotation, const rspfDpt& scale, const rspfDpt& shear, unsigned char r, unsigned char g, unsigned char b) :rspfAnnotationObject(r,g,b), theFont(rspfFontFactoryRegistry::instance()->getDefaultFont()), theString(s), thePixelSize(pixelSize), theRotation(rotation), theHorizontalScale(scale.x), theVerticalScale(scale.y), theHorizontalShear(shear.x), theVerticalShear(shear.y) { setFontInfo(); thePosition = upperLeft; computeBoundingRect(); #if 0 if (theFont) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += upperLeft; thePosition = theBoundingRect.ul(); #endif }
void Display::loadSettings() { fstream file("Settings.txt"); if (!file) { file.open("Settings.txt", ios::app); file << "Settings" << endl; file << "Font: 0" << endl; file << "FontSize: 28" << endl; file << "FullScreen: 1" << endl; } else { string none; file >> none; file >> none; file >> font_; file >> none; file >> fontSize_; file >> none; file >> isFullscreen_; setFontInfo(fontSize_, font_); if (isFullscreen_) { HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); DWORD flags = CONSOLE_FULLSCREEN_MODE; COORD pos; SetConsoleDisplayMode(h, flags, &pos); } } }
void rspfAnnotationFontObject::applyScale(double x, double y) { thePosition.x = rspf::round<int>(thePosition.x *x); thePosition.y = rspf::round<int>(thePosition.y *y); setFontInfo(); computeBoundingRect(); }
void rspfAnnotationFontObject::setRotation(double rotation) { theRotation = rotation; setFontInfo(); if (theFont.valid()) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += (thePosition - theBoundingRect.ul()); thePosition = theBoundingRect.ul(); }
void rspfAnnotationFontObject::setPointSize(const rspfIpt& size) { thePixelSize = size; setFontInfo(); if (theFont.valid()) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += (thePosition - theBoundingRect.ul()); thePosition = theBoundingRect.ul(); }
void rspfAnnotationFontObject::setShear(const rspfDpt& shear) { theHorizontalShear = shear.x; theVerticalShear = shear.y; setFontInfo(); if (theFont.valid()) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += (thePosition - theBoundingRect.ul()); thePosition = theBoundingRect.ul(); }
void ossimAnnotationFontObject::setScale(const ossimDpt& scale) { theHorizontalScale = scale.x; theVerticalScale = scale.y; setFontInfo(); if (theFont.valid()) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += (thePosition - theBoundingRect.ul()); thePosition = theBoundingRect.ul(); }
rspfAnnotationFontObject::rspfAnnotationFontObject() :rspfAnnotationObject(), theFont(rspfFontFactoryRegistry::instance()->getDefaultFont()), thePosition(0,0), theString(""), theRotation(0.0), theHorizontalScale(0.0), theVerticalScale(0.0), theHorizontalShear(0.0), theVerticalShear(0.0) { setFontInfo(); theBoundingRect.makeNan(); }
rspfAnnotationFontObject::rspfAnnotationFontObject(const rspfAnnotationFontObject& rhs) :rspfAnnotationObject(rhs), thePosition(rhs.thePosition), theString(rhs.theString), thePixelSize(rhs.thePixelSize), theRotation(rhs.theRotation), theHorizontalScale(rhs.theHorizontalScale), theVerticalScale(rhs.theVerticalScale), theHorizontalShear(rhs.theHorizontalShear), theVerticalShear(rhs.theVerticalShear), theBoundingRect(rhs.theBoundingRect) { theFont = rhs.theFont; setFontInfo(); }
void rspfAnnotationFontObject::setGeometryInformation(const rspfFontInformation& info) { thePixelSize = info.thePointSize; theRotation = info.theRotation; theHorizontalScale = info.theScale.x; theVerticalScale = info.theScale.y; theHorizontalShear = info.theShear.x; theVerticalShear = info.theShear.y; setFontInfo(); if (theFont.valid()) { theFont->getBoundingBox(theBoundingRect); } theBoundingRect += (thePosition - theBoundingRect.ul()); thePosition = theBoundingRect.ul(); }
void rspfAnnotationFontObject::computeBoundingRect() { setFontInfo(); if(theFont.valid()) { rspfIrect textRect; theFont->getBoundingBox(textRect); rspf_int32 w = textRect.width(); rspf_int32 h = textRect.height(); rspf_int32 ulx = thePosition.x; rspf_int32 uly = thePosition.y; theBoundingRect = rspfIrect(ulx, uly, ulx + w - 1, uly + h - 1); } }
void rspfAnnotationFontObject::draw(rspfRgbImage& anImage)const { if(theBoundingRect.hasNans()) { return; } if (!theFont) { return; } if(!thePixelSize.x || !thePixelSize.y) { return; // (DAH) we have to have some demension to write! } rspfRefPtr<rspfImageData> destination = anImage.getImageData(); if(destination.valid()) { rspfIrect destRect = anImage.getImageData()->getImageRectangle(); rspfIpt shift(-theBoundingRect.ul().x, -theBoundingRect.ul().y); destRect += shift; rspfIrect boundingRect = theBoundingRect + shift; if(boundingRect.intersects(destRect)) { setFontInfo(); rspfIrect fontBufferRect; rspfIrect boundingFontBox; theFont->setClippingBox(destRect); theFont->getBoundingBox(boundingFontBox); const rspf_uint8* srcBuf = theFont->rasterize(); if (!srcBuf) { return; } theFont->getBufferRect(fontBufferRect); rspfIrect clipRect = boundingRect.clipToRect(fontBufferRect); long clipHeight = clipRect.height(); long clipWidth = clipRect.width(); long destinationOffset = (long)(((clipRect.ul().y - destRect.ul().y)* destRect.width()) + (clipRect.ul().x - destRect.ul().x)); long fontBufferOffset = (long)(((clipRect.ul().y - fontBufferRect.ul().y)*fontBufferRect.width()) + (clipRect.ul().x - fontBufferRect.ul().x)); long destinationIndex = destinationOffset; long srcIndex = fontBufferOffset; long num_bands = destination->getNumberOfBands(); rspf_int32 s_width = (rspf_int32)fontBufferRect.width(); rspf_int32 d_width = (rspf_int32)destRect.width(); num_bands = num_bands > 3? 3:num_bands; unsigned char colorArray[3]; long band = 0; colorArray[0] = theRed; colorArray[1] = theGreen; colorArray[2] = theBlue; rspf_uint8** destBuf = new rspf_uint8*[num_bands]; for(band = 0; band < num_bands;++band) { destBuf[band] = static_cast<rspf_uint8*>(destination->getBuf(band)); if (!destBuf[band]) { delete [] destBuf; return; } } for(long line = 0; line < clipHeight; ++line) { for(long col = 0; col < clipWidth; ++col) { if(srcBuf[srcIndex + col]) { for (band=0; band<num_bands; ++band) { *(destBuf[band] + destinationIndex + col) = colorArray[band]; } } } srcIndex += s_width; destinationIndex += d_width; } delete [] destBuf; } } }