Logo Search packages:      
Sourcecode: yudit version File versions

void SFontTTF::getBaseOffsets ( const SS_Matrix2D m,
SS_UCS4  _uch,
double *  offx,
double *  offy 
)

Get the x,y offset for better positioning of diacritical marks. This routine is supposed to be

Definition at line 665 of file SFontTTF.cpp.

References SString::append(), findGlyph(), SBinHashtable< Type >::get(), getGlyphWidth(), getOTFMarkToBase(), isLeftAligned(), SBinHashtable< Type >::put(), setBaseCharacter, SBinVector< Type >::size(), SS_Matrix2D::x0, and SS_Matrix2D::y1.

Referenced by SFontImpl::draw().

{
  *offx = 0.0;
  *offy = 0.0;
  if (!isOK() || setBaseCharacter==0 
      || setBaseCharacter==_uch) return;

  if (setBaseCharacter == baseCharacter && baseGlyph==0)
  {
      return;
  }

  if (setBaseCharacter != baseCharacter)
  {
    baseCharacter = setBaseCharacter;
    if (fontencoding.size()!=0 || baseCharacter >= 0x80000000 
       || !isOK() || hardWire == SS_MSLVT || hardWire == SS_NOJAMO)
    {
      baseGlyph = 0;
      return;
    }
    baseGlyph = findGlyph (baseCharacter);
    if (baseGlyph==0) 
    {
      return;
    }
//fprintf (stderr, "baseCharacter=%04X glyph=%04X\n", baseCharacter, baseGlyph);
    /* get the width of the base char */  
    baseWidth = getGlyphWidth (baseGlyph);
  }
  SString key ((char*)&baseGlyph, sizeof (SS_GlyphIndex));
  key.append (SString ((char*)&_uch, sizeof (SS_UCS4)));

  int cxy = mark2Base.get (key);
  if (cxy == SD_TTF_NAN) return;

  /* we had it not found. SGC */
  int cx = cxy & 0xffff;
  if (cx > 0x7fff) cx -= 0x10000 ;
  int cy = (cxy >> 16) & 0xffff;
  if (cy > 0x7fff) cy -= 0x10000;

  if (cx != 0 || cy != 0)
  {
    *offx =  cx * m.x0;
    *offy =  cy * m.y1;
    return;
  }
  SS_GlyphIndex gi = findGlyph(_uch);
  if (gi==0)
  {
    mark2Base.put (key, SD_TTF_NAN);
    return;
  }
  getOTFMarkToBase (baseGlyph, gi, &cx, &cy);
  if (cx==0 && cy==0)
  {
    mark2Base.put (key, SD_TTF_NAN);
    return;
  }
  /* In sync with SFont.cpp - we need to undo fallback positioning  */
  if (!isLeftAligned(_uch))
  {
    cx -= (baseWidth - getGlyphWidth (gi));
  }
  cxy = (cy << 16) & 0xffff0000;
  cxy = cxy | (cx & 0xffff);
  mark2Base.put (key, cxy);

  *offx =  (double)cx * m.x0;
  *offy =  (double)cy * m.y1;
  return;
}


Generated by  Doxygen 1.6.0   Back to index