b01267e746a100118ca7045113d78b5fa588e685
braney
  Fri May 30 17:10:30 2025 -0700
when a composite has dense tracks the way we deal with center labels
the draw routine leaves grek in the track when the decenders of the
center label have been drawn even though the center label is not
actually drawn, but hidden via CSS.
Now in this condition we're drawing slightly smaller fonts for the
center labels so they don't exceed the drawing box.  refs #29500

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 035f72b289e..758bf4db4b7 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -1620,53 +1620,64 @@
 
 safef(buttonText, ArraySize(buttonText), "hgt.nextItem=%s", track->track);
 mapBoxReinvoke(hvg, portX + portWidth - arrowButtonWidth, y + 1, arrowButtonWidth, insideHeight,
                track, FALSE, NULL, 0, 0, (revCmplDisp ? "Prev item" : "Next item"), buttonText);
 
 setGlobalsFromWindow(windows); // restore first window
 
 }
 
 static int doCenterLabels(struct track *track, struct track *parentTrack,
                                 struct hvGfx *hvg, MgFont *font, int y, int fullInsideWidth )
 /* Draw center labels.  Return y coord */
 {
 if (track->limitedVis != tvHide)
     {
+    MgFont *labelfont;
     if (isCenterLabelIncluded(track))
         {
         int trackPastTabX = (withLeftLabels ? trackTabWidth : 0);
         int trackPastTabWidth = tl.picWidth - trackPastTabX;
         int fontHeight = mgFontLineHeight(font);
         int insideHeight = fontHeight-1;
 	boolean toggleDone = FALSE;
         char *label = track->longLabel;
         Color labelColor = (track->labelColor ?
                             track->labelColor : track->ixColor);
         if (isCenterLabelConditional(track))
             {
             struct trackDb* tdbComposite = tdbGetComposite(track->tdb);
             if (tdbComposite != NULL)
                 {
                 label = tdbComposite->longLabel;
                 labelColor = hvGfxFindColorIx(hvg, tdbComposite->colorR,
                                                 tdbComposite->colorG, tdbComposite->colorB);
+
+                // under this condition the characters that have descenders end up bleeding
+                // over into tracks that don't actually draw the label which 
+                // results in grek.  In this condition make the center label font smaller
+                int fontsize = findBiggest(fontHeight - 4);
+                char size[1024];
+                safef(size, sizeof size, "%d", fontsize);
+                labelfont = mgFontForSizeAndStyle(size, "medium");
                 }
             }
+        else
+            labelfont = font;
         labelColor = maybeDarkerLabels(track, hvg, labelColor);
         hvGfxTextCentered(hvg, insideX, y+1, fullInsideWidth, insideHeight,
-                          labelColor, font, label);
+                          labelColor, labelfont, label);
         if (track->nextItemButtonable && track->nextPrevItem && !tdbIsComposite(track->tdb))
             {
             if (withNextItemArrows || trackDbSettingOn(track->tdb, "nextItemButton"))
                 {
                 doLabelNextItemButtons(track, parentTrack, hvg, font, y, trackPastTabX,
                                        trackPastTabWidth, fontHeight, insideHeight, labelColor);
                 toggleDone = TRUE;
                 }
             }
         if (!toggleDone)
             {
         #ifdef IMAGEv2_SHORT_TOGGLE
             // make toggle cover only actual label
             int size = mgFontStringWidth(font,label) + 12;  // get close enough to the label
             if (trackPastTabWidth > size)