void RenderAddGlyphs (FD fd, const unsigned char *buf) { RenderRequestHeader (fd, buf); if (Verbose < 1) return; printreqlen(buf, fd, CONST2(2)); PrintField(buf, 4, 4, GLYPHSET, "glyphset"); PrintField(buf, 8, 4, CARD32, "nglyphs"); PrintGlyphs(&buf[12], ILong(&buf[8]), "glyphs"); }
void nuiTextLayout::Print(nuiDrawContext* pContext, float X, float Y, bool AlignGlyphPixels) const { bool blendsaved = pContext->GetState().mBlending; bool texturesaved = pContext->GetState().mTexturing; pContext->EnableBlending(true); pContext->EnableTexturing(true); nuiColor SavedColor = pContext->GetFillColor(); nuiColor oldcolor(pContext->GetStrokeColor()); pContext->SetStrokeColor(pContext->GetTextColor()); pContext->SetFillColor(pContext->GetTextColor()); pContext->SetBlendFunc(nuiBlendTransp); std::map<nuiTexture*, std::vector<nuiTextGlyph*> > Glyphs; float x = X; float y = Y; // Iterate runs: for (int32 p = 0; p < GetParagraphCount(); p++) { for (int32 l = 0; l < GetLineCount(p); l++) { x = X; nuiTextLine* pLine = GetLine(p, l); for (int32 r = 0; r < pLine->GetRunCount(); r++) { nuiTextRun* pRun = pLine->GetRun(r); std::vector<nuiTextGlyph>& rGlyphs(pRun->GetGlyphs()); nuiFontBase* pFont = pRun->GetFont(); for (int32 g = 0; g < rGlyphs.size(); g++) { nuiTextGlyph& rGlyph(rGlyphs.at(g)); Glyphs[rGlyph.mpTexture].push_back(&rGlyph); } // Draw underlines and strike through if needed if (pRun->GetUnderline() || pRun->GetStrikeThrough()) { nuiFontInfo info; pFont->GetInfo(info); float thickness = ToNearest(info.UnderlineThick); pContext->SetLineWidth(thickness); const float x1 = x; const float x2 = x + pRun->GetAdvanceX(); if (pRun->GetUnderline()) { const float pos = -info.UnderlinePos; const float _y = ToNearest(y + pos); if (x1 != x2) pContext->DrawLine(x1, _y, x2, _y); } if (pRun->GetStrikeThrough()) { const float pos = -info.Ascender * .4f; const float _y = ToNearest(y + pos); if (x1 != x2) pContext->DrawLine(x1, _y, x2, _y); } } //x += pRun->GetAdvanceX(); } //y += pLine->GetAdvanceY(); } } PrintGlyphs(pContext, X, Y, Glyphs, AlignGlyphPixels); pContext->EnableBlending(blendsaved); pContext->EnableTexturing(texturesaved); pContext->SetFillColor(SavedColor); pContext->SetStrokeColor(oldcolor); }