MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / DrawGlyph

Function DrawGlyph

xgeneral.cpp:477–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475// sign, planet, aspect, and Nakshatra glyphs from these fonts within charts.
476
477flag DrawGlyph(int ch, int x, int y, int fi, int nScale)
478{
479 HFONT hfont, hfontPrev;
480 SIZE size;
481 char sz[3];
482 WCHAR wz[2];
483 KV kvSav;
484 int cch = 1 + (fi == fiArial && ch < 0), nSav;
485
486 // Fonts: 1=Wingdings, 2=Astro, 3=EnigmaAstrology, 4=HamburgSymbols,
487 // 5=Astronomicon, 6=StarFont Sans, 7=StarFont Serif, 8=HanksNakshatra,
488 // 9=Arial, 10=Courier New, 11=Consolas, 12=Lucida Console, 13=Cascadia Mono
489#ifdef WIN
490 FEnsureFontInstalled(fi);
491#endif
492 hfont = CreateFont(12*gi.nScale*nScale/100, 0, 0, 0, !gs.fThick ? 400 : 800,
493 fFalse, fFalse, fFalse, FBetween(fi, fiArial, fiCascadia) ?
494 DEFAULT_CHARSET : (fi >= fiAstro && fi != fiNakshatr ? ANSI_CHARSET :
495 SYMBOL_CHARSET), OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
496 VARIABLE_PITCH | FF_DONTCARE, rgszFontName[fi]);
497 if (hfont == NULL)
498 return fFalse;
499 hfontPrev = (HFONT)SelectObject(wi.hdc, hfont);
500 kvSav = SetTextColor(wi.hdc, gi.kvCur);
501 nSav = SetBkMode(wi.hdc, TRANSPARENT);
502 if (fi >= fiArial && cch <= 1) {
503 // Draw a single (potentially Unicode) character.
504 wz[0] = ch; wz[1] = chNull;
505 GetTextExtentPointW(wi.hdc, wz, cch, &size);
506 TextOutW(wi.hdc, x - (size.cx >> 1), y - (size.cy >> 1), wz, cch);
507 } else {
508 // Draw a special symbol character or a multi-character number.
509 if (cch <= 1) {
510 sz[0] = ch; sz[1] = chNull;
511 } else
512 sprintf(sz, "%d", -ch);
513 GetTextExtentPoint(wi.hdc, sz, cch, &size);
514 TextOut(wi.hdc, x - (size.cx >> 1), y - (size.cy >> 1), sz, cch);
515 }
516 SetBkMode(wi.hdc, nSav);
517 SetTextColor(wi.hdc, kvSav);
518 SelectObject(wi.hdc, hfontPrev);
519 DeleteObject(hfont);
520 return fTrue;
521}
522
523
524// Clear and erase the entire graphics screen on Windows.

Callers 6

DrawSignFunction · 0.85
DrawHouseFunction · 0.85
DrawObjectFunction · 0.85
DrawAspectFunction · 0.85
DrawNakshatraFunction · 0.85
DrawSidebarFunction · 0.85

Calls 1

FEnsureFontInstalledFunction · 0.85

Tested by

no test coverage detected