Logo Search packages:      
Sourcecode: yudit version File versions

bool SFontImpl::draw ( SCanvas canvas,
const SPen pen,
const SS_Matrix2D m,
SS_UCS4  uch 

Try to draw one single glyph.

canvas is the canvas to draw to
m is the conversion matrix
uch is the array containing ucs4 len is the length of the array
true is drawn.

Definition at line 531 of file SFontImpl.cpp.

References SString::append(), SFontDelegate::bdf, SFontBDF::draw(), SUniFont::draw(), SFontNative::draw(), SFontTTF::draw(), SCanvas::fill(), SFontTTF::getBaseOffsets(), SPen::getForeground(), SFontTTF::isOK(), SFontDelegate::native, SCanvas::newpath(), SS_Matrix2D::t0, SS_Matrix2D::t1, SFontDelegate::ttf, SFontDelegate::type, SFontDelegate::u, SFontDelegate::unifont, SFontBDF::width(), SUniFont::width(), SFontTTF::width(), SS_Matrix2D::x0, and SS_Matrix2D::y1.

  if (!delegate) return 0;

  SFontDelegate* d = (SFontDelegate*) delegate;;
  SS_Matrix2D sd = m * matrix;
  switch (d->type)
  case SFontDelegate::SE_TTF:
    if (d->u.ttf->isOK())
        if (!d->u.ttf->width (m, uch, 0)) return 0;
        long larr[8];
        larr[0] = 'T' ; larr[1] = 'T'; larr[2] = 'F';
        larr[3] = (long)d->u.ttf; larr[4] = (long)uch;
        SString key((char*) larr, 5 * sizeof (long));

        /* FIXME: you should in fact use an instance counter. */
        key.append ((long)(sd.x0*16000.0)); /* scale-x */
        key.append ((long)(sd.y1*16000.0)); /* scale-y */
        double offsetX = 0.0;
        double offsetY = 0.0;
        /* for better positioning of diacritical marks */
        d->u.ttf->getBaseOffsets (sd, uch, &offsetX, &offsetY);
        // No need to be part of the key 
        //key.append ((long)(offsetX*16000.0)); 
        //key.append ((long)(offsetY*16000.0)); 
        sd.t0  += offsetX;
        sd.t1  += offsetY;
        /* reverse coordinates Y, negative m.t1 */
        if (!canvas->newpath (m.t0+offsetX, m.t1+offsetY, key))
          /* not cached yet */
          d->u.ttf->draw (canvas, sd, uch);
        canvas->fill (pen);
        return true;
  case SFontDelegate::SE_NATIVE:
    if (d->u.native==0) break;
    return (d->u.native->draw (xlfd, canvas, pen, sd, uch));
  case SFontDelegate::SE_UNIFONT:
    if (d->u.unifont)
        if (!d->u.unifont->width (matrix.y1, uch, 0)) return 0;
        d->u.unifont->draw (matrix.y1, canvas, pen.getForeground(), sd, uch,
           (m.x0 < 0));
        return true;
  case SFontDelegate::SE_BDF:
    if (d->u.bdf)
        if (!d->u.bdf->width (matrix.y1, uch, 0)) return 0;
        d->u.bdf->draw (matrix.y1, canvas, pen.getForeground(), sd, uch, 
          (m.x0 < 0));
        return true;
  case SFontDelegate::SE_NONE:
  return false;

Generated by  Doxygen 1.6.0   Back to index