deca5eaeff633b054ba0091c391298fc7dc34377
braney
  Sat Nov 21 12:29:43 2020 -0800
finalizing freeType font work

diff --git src/hg/hgTracks/config.c src/hg/hgTracks/config.c
index 3c3a62f..1d4024f 100644
--- src/hg/hgTracks/config.c
+++ src/hg/hgTracks/config.c
@@ -115,34 +115,94 @@
 "n021003l.pfb",
 "n021004l.pfb",
 "n021023l.pfb",
 "n021024l.pfb",
 "n022003l.pfb",
 "n022004l.pfb",
 "n022023l.pfb",
 "n022024l.pfb",
 "p052003l.pfb",
 "p052004l.pfb",
 "p052023l.pfb",
 "p052024l.pfb",
 "z003034l.pfb",
 };
 
+char *emptyStyles[] = {
+"Normal"
+};
+
 static void textFontDropDown()
 /* Create drop down for font size. */
 {
-hDropList(textFontVar, freeTypeFontNames, ArraySize(freeTypeFontNames), tl.textFont);
+char *faceNames[sizeof(freeTypeFontNames)];
+int ii;
+int numFonts = 0;
+struct dyString *dy = dyStringNew(1024);
+dyStringPrintf(dy, "  fontStyles = [];\n");
+
+int numStyle = 0;
+char *lastName = NULL;
+
+faceNames[numFonts++] = "Bitmap";
+dyStringPrintf(dy, "  fontStyles['Bitmap'] = ['Normal'];");
+
+for (ii=0; ii < ArraySize(freeTypeFontNames); ii++)
+    {
+    char *fontName = cloneString(freeTypeFontNames[ii]);
+    char *style = strchr(fontName, '-');
+
+    if (style)
+        *style++ = 0;
+
+    if ((lastName == NULL) || differentString(lastName, fontName))
+        {
+        faceNames[numFonts] = fontName;
+        if (lastName != NULL)
+            dyStringPrintf(dy, "  ];\n");
+
+        dyStringPrintf(dy, "  fontStyles['%s'] = [", fontName);
+        numStyle = 0;
+        numFonts++;
+        }
+
+    if (style == NULL)
+        style = cloneString("Normal");
+    if (numStyle)
+        dyStringPrintf(dy, ",");
+    dyStringPrintf(dy, "'%s'", style);
+    numStyle++;
+
+    lastName = fontName;
+    }
+    dyStringPrintf(dy, "  ];\n");
+
+dyStringPrintf(dy, "  $(\"[name='%s']\").change(function()\n", textFontVar);
+dyStringPrintf(dy, "  {\n");
+dyStringPrintf(dy, "$(\"[name='textStyle']\").empty();");
+dyStringPrintf(dy, "  val= $(this).find(':selected').val(); \n");
+dyStringPrintf(dy, "  for(ii=0; ii < fontStyles[val].length; ii++) { $(\"[name='textStyle']\").append( new Option(fontStyles[val][ii],fontStyles[val][ii],))};\n");
+dyStringPrintf(dy, "  });\n");
+dyStringPrintf(dy, "$(\"[name='textFont']\").change();\n");
+jsInline(dy->string);
+hDropList(textFontVar, faceNames, numFonts, tl.textFont);
+}
+
+static void textStyleDropDown()
+/* Create drop down for font size. */
+{
+hDropList(textStyleVar, emptyStyles, ArraySize(emptyStyles), emptyStyles[0]);
 }
 
 static void textSizeDropDown()
 /* Create drop down for font size. */
 {
 static char *sizes[] = {"6", "8", "10", "12", "14", "18", "24", "34"};
 hDropList(textSizeVar, sizes, ArraySize(sizes), tl.textSize);
 }
 
 static void trackConfig(struct track *trackList, struct group *groupList,
 	char *groupTarget,  int changeVis)
 /* Put up track configurations. If groupTarget is
  * NULL then set visibility for tracks in all groups.  Otherwise,
  * just set it for the given group.  If vis is -2, then visibility is
  * unchanged.  If -1 then set visibility to default, otherwise it should
@@ -522,31 +582,35 @@
     hPrintf("&nbsp;medium&nbsp;");
     cartMakeRadioButton(cart, "fontType", "fixed", defaultStyle);
     hPrintf("&nbsp;fixed&nbsp;");
     cartMakeRadioButton(cart, "fontType", "bold", defaultStyle);
     hPrintf("&nbsp;bold&nbsp;");
     hPrintf("&nbsp;");
     hPrintf("</TD>");
     }
 hPrintf("</TR>");
 
 if (sameString(cfgOptionDefault("freeType", "off"), "on"))
     {
     hPrintf("<TR><TD>font:");
     hPrintf("<TD style=\"text-align: right\">");
     textFontDropDown();
-    hPrintf("</TD>");
+    hPrintf("</TD></TR>");
+    hPrintf("<TR><TD>style:");
+    hPrintf("<TD style=\"text-align: right\">");
+    textStyleDropDown();
+    hPrintf("</TR>");
     hPrintf("</TR>");
     }
 
 themeDropDown(cart);
 
 hTableStart();
 if (ideoTrack != NULL)
     {
     hPrintf("<TR><TD>");
     hCheckBox("ideogram", cartUsualBoolean(cart, "ideogram", TRUE));
     hPrintf("</TD><TD>");
     hPrintf("Display chromosome ideogram above main graphic");
     hPrintf("</TD></TR>\n");
     }
 hPrintf("<TR><TD>");