예제 #1
0
void GfxFontFromResource::draw(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput) {
	// Make sure we're comparing against the correct dimensions
	// If the font we're drawing is already upscaled, make sure we use the full screen width/height
	uint16 screenWidth = _screen->fontIsUpscaled() ? _screen->getDisplayWidth() : _screen->getWidth();
	uint16 screenHeight = _screen->fontIsUpscaled() ? _screen->getDisplayHeight() : _screen->getHeight();

	int charWidth = MIN<int>(getCharWidth(chr), screenWidth - left);
	int charHeight = MIN<int>(getCharHeight(chr), screenHeight - top);
	byte b = 0, mask = 0xFF;
	int y = 0;
	int16 greyedTop = top;

	byte *pIn = getCharData(chr);
	for (int i = 0; i < charHeight; i++, y++) {
		if (greyedOutput)
			mask = ((greyedTop++) % 2) ? 0xAA : 0x55;
		for (int done = 0; done < charWidth; done++) {
			if ((done & 7) == 0) // fetching next data byte
				b = *(pIn++) & mask;
			if (b & 0x80) // if MSB is set - paint it
				_screen->putFontPixel(top, left + done, y, color);
			b = b << 1;
		}
	}
}
예제 #2
0
const Common::Rect FontResource::calculateRectForText(uint16 *text, uint textLength) {
	int16 width = 0;
	for (uint i = 0; i < textLength && *text; i++) {
		width += getCharInfo(*text)->_width;
		text++;
	}
	return Common::Rect(width, getCharHeight() + getLineIncr());
}
예제 #3
0
int SmushFont::getStringHeight(const char *str) {
	assert(str);
	if (!_loaded) {
		error("SmushFont::getStringHeight() Font is not loaded");
		return 0;
	}

	int height = 0;
	while (*str) {
		int charHeight = getCharHeight(*str++);
		if (height < charHeight)
			height = charHeight;
	}
	return height;
}
예제 #4
0
  MoveMapBox::MoveMapBox (MoveLayer* pMoveLayer) : BitArray<unsigned char, 8 > ()
  {
    pMoveLayer->getBounds (iBounds);
    float sizediff = iBounds.high ().x - iBounds.low ().x;
    if (sizediff > ((float) ((int) sizediff)))
      {
        sizediff += 1;
      }
    int sizeX = (int) sizediff;

    sizediff = iBounds.high ().z - iBounds.low ().z;
    if (sizediff > ((float) ((int) sizediff)))
      {
        sizediff += 1;
      }
    int sizeY = (int) sizediff;
    const PositionControlArray<unsigned short, 16 > * pcArray = pMoveLayer->getMovePointsArray ();
    initArray (sizeX, sizeY);
    Vector3 diffBaseV = iBounds.low () - pMoveLayer->getMovePointsArray ()->getBasePos ();
    float debugheight = 0;
    for (int y = 0; y < sizeY; ++y)
      {
        for (int x = 0; x < sizeX; ++x)
          {
            unsigned short val = pcArray->directGet (x + diffBaseV.x, y + diffBaseV.z, 0);
            if (val != MAP_VALUE_UNDEF && val != MAP_VALUE_CANT_REACH)
              {
                float height = SHORTHEIGHT2FLOAT (val);
                set (getCharHeight (height), x, y);
                debugheight = height;
              }
            else
              {
                //debugPrintf("MoveMapBox::MoveMapBox() out not reached x=%d, y=%d\n",x,y);

                //set(getCharHeight(debugheight), x,y);
                set (MOVEMAP_VALUE_CANT_REACH, x, y);
              }
          }
      }

  }
예제 #5
0
void GfxFontFromResource::drawToBuffer(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput, byte *buffer, int16 bufWidth, int16 bufHeight) {
	int charWidth = MIN<int>(getCharWidth(chr), bufWidth - left);
	int charHeight = MIN<int>(getCharHeight(chr), bufHeight - top);
	byte b = 0, mask = 0xFF;
	int y = 0;
	int16 greyedTop = top;

	byte *pIn = getCharData(chr);
	for (int i = 0; i < charHeight; i++, y++) {
		if (greyedOutput)
			mask = ((greyedTop++) % 2) ? 0xAA : 0x55;
		for (int done = 0; done < charWidth; done++) {
			if ((done & 7) == 0) // fetching next data byte
				b = *(pIn++) & mask;
			if (b & 0x80) {	// if MSB is set - paint it
				int offset = (top + y) * bufWidth + (left + done);
				buffer[offset] = color;
			}
			b = b << 1;
		}
	}
}
예제 #6
0
float Text::getTextHeight() { return getCharHeight(); }