MCPcopy Create free account
hub / github.com/audacity/audacity / ChooseFonts

Method ChooseFonts

src/widgets/Ruler.cpp:354–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353
354void Ruler::ChooseFonts( wxDC &dc ) const
355{
356 const RulerStruct::Fonts* pUserFonts = mpUserFonts.get();
357 int desiredPixelHeight = mRulerStruct.mOrientation == wxHORIZONTAL
358 ? mRulerStruct.mBottom - mRulerStruct.mTop - 5 // height less ticks and 1px gap
359 : MaxPixelHeight;
360
361 if (mRulerStruct.mpFonts)
362 return;
363
364 if (pUserFonts) {
365 mRulerStruct.mpFonts = std::make_unique<RulerStruct::Fonts>(*pUserFonts);
366 return;
367 }
368
369 mRulerStruct.mpFonts = std::make_unique<RulerStruct::Fonts>(RulerStruct::Fonts{ {}, {}, {}, 0 });
370 auto& fonts = *(mRulerStruct.mpFonts);
371
372 int fontSize = 4;
373
374 desiredPixelHeight =
375 std::max(MinPixelHeight, std::min(MaxPixelHeight, -desiredPixelHeight));
376
377 // Keep making the font bigger until it's too big, then subtract one.
378 wxCoord height;
379 FindFontHeights(height, fonts.lead, dc, fontSize, wxFONTWEIGHT_BOLD);
380 while (height <= desiredPixelHeight && fontSize < 40) {
381 fontSize++;
382 FindFontHeights(height, fonts.lead, dc, fontSize, wxFONTWEIGHT_BOLD);
383 }
384 fontSize--;
385 FindFontHeights(height, fonts.lead, dc, fontSize);
386
387 fonts.major = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
388 fonts.minor = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
389 fonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
390
391}
392
393void Ruler::UpdateCache(
394 wxDC &dc, const Envelope* envelope )

Callers

nothing calls this directly

Calls 4

maxFunction · 0.85
FindFontHeightsFunction · 0.85
minFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected