void QTextEngine::shape( int item ) const { assert( item < items.size() ); QScriptItem &si = items[item]; if ( si.num_glyphs ) return; QFont::Script script = (QFont::Script)si.analysis.script; si.glyph_data_offset = used; if ( !si.fontEngine ) si.fontEngine = fnt->engineForScript( script ); si.fontEngine->ref(); si.ascent = si.fontEngine->ascent(); si.descent = si.fontEngine->descent(); si.num_glyphs = 0; if ( si.fontEngine && si.fontEngine != (QFontEngine*)-1 ) { QShaperItem shaper_item; shaper_item.script = si.analysis.script; shaper_item.string = &string; shaper_item.from = si.position; shaper_item.length = length(item); shaper_item.font = si.fontEngine; shaper_item.num_glyphs = QMAX(int(num_glyphs - used), shaper_item.length); shaper_item.flags = si.analysis.bidiLevel % 2 ? RightToLeft : 0; while (1) { // qDebug(" . num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs); ensureSpace(shaper_item.num_glyphs); shaper_item.num_glyphs = num_glyphs - used; // qDebug(" .. num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs); shaper_item.glyphs = glyphs(&si); shaper_item.advances = advances(&si); shaper_item.offsets = offsets(&si); shaper_item.attributes = glyphAttributes(&si); shaper_item.log_clusters = logClusters(&si); if (scriptEngines[shaper_item.script].shape(&shaper_item)) break; } si.num_glyphs = shaper_item.num_glyphs; } ((QTextEngine *)this)->used += si.num_glyphs; si.width = 0; advance_t *advances = this->advances( &si ); advance_t *end = advances + si.num_glyphs; while ( advances < end ) si.width += *(advances++); return; }
void QFontEngineMac::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight) { QVarLengthArray<QFixedPoint> positions; QVarLengthArray<glyph_t> glyphs; QTransform matrix; matrix.translate(x, y); getGlyphPositions(ti.glyphs, ti.num_glyphs, matrix, ti.flags, glyphs, positions); if (glyphs.size() == 0) return; CGContextSetFontSize(ctx, fontDef.pixelSize); CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx); CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight); CGAffineTransformConcat(cgMatrix, oldTextMatrix); if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0)); cgMatrix = CGAffineTransformConcat(cgMatrix, multiEngine->transform); CGContextSetTextMatrix(ctx, cgMatrix); CGContextSetTextDrawingMode(ctx, kCGTextFill); QVarLengthArray<CGSize> advances(glyphs.size()); QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size()); for (int i = 0; i < glyphs.size() - 1; ++i) { advances[i].width = (positions[i + 1].x - positions[i].x).toReal(); advances[i].height = (positions[i + 1].y - positions[i].y).toReal(); cgGlyphs[i] = glyphs[i]; } advances[glyphs.size() - 1].width = 0; advances[glyphs.size() - 1].height = 0; cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1]; CGContextSetFont(ctx, cgFont); CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal()); CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size()); if (synthesisFlags & QFontEngine::SynthesizedBold) { CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(), positions[0].y.toReal()); CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size()); } CGContextSetTextMatrix(ctx, oldTextMatrix); }
void advances(View* view, int lastInd = 0) { vector<View::ListElem> options; vector<Technology*> techs = Technology::getSorted(); for (Technology* tech : techs) options.push_back(tech->getName()); auto index = view->chooseFromList("Advances", options, lastInd); if (!index) return; advance(view, techs[*index]); advances(view, *index); }
void Encyclopedia::present(View* view, int lastInd) { auto index = view->chooseFromList("Choose topic:", {"Advances", /*"Workshop",*/ "Deities", "Skills"}, lastInd); if (!index) return; switch (*index) { case 0: advances(view); break; // case 1: workshop(view); break; case 1: deities(view); break; case 2: skills(view); break; default: FAIL << "wfepok"; } present(view, *index); }
/** * Adds 'xp' points to the units experience; returns true if advancement * should occur */ bool get_experience(int xp) { experience_ += xp; return advances(); }