diff --git a/src/g_all_guis.c b/src/g_all_guis.c index 2aa2ecaa8db5fed272aa2c9ad8092cd814334dbf..9f2c27cc6596f529914e42a70af8c1a92e60eb14 100644 --- a/src/g_all_guis.c +++ b/src/g_all_guis.c @@ -449,7 +449,7 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a f = 4; iemgui->x_fontsize = f; if(glist_isvisible(iemgui->x_glist)) - sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s}\n", + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n", glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, iemgui->x_fontsize, sys_fontweight); } diff --git a/src/g_magicglass.c b/src/g_magicglass.c index 3fbde9a7a3adbac9b83105d87810a8964580bcc4..1c62f59fbacbd3a1229cf9d056c85a502ceba70d 100644 --- a/src/g_magicglass.c +++ b/src/g_magicglass.c @@ -251,6 +251,7 @@ void magicGlass_show(t_magicGlass *x) //fprintf(stderr,"magicglass_show\n"); if (!x->x_visible) { x->x_sampleCount = 0; + x->x_minSample = 999999; x->x_maxSample = -999999; x->x_string[0] = 0; x->x_visible = 1; @@ -264,6 +265,7 @@ void magicGlass_hide(t_magicGlass *x) if (x->x_visible) { magicGlass_undraw(x); x->x_sampleCount = 0; + x->x_minSample = 999999; x->x_maxSample = -999999; x->x_string[0] = 0; x->x_visible = 0; @@ -319,6 +321,7 @@ void magicGlass_setDsp(t_magicGlass *x, int i) { x->x_dspOn = 1; x->x_sampleCount = 0; + x->x_minSample = 999999; x->x_maxSample = -999999; } else @@ -341,12 +344,22 @@ t_int *magicGlass_perform(t_int *w) { if (in[i] > x->x_maxSample) x->x_maxSample = in[i]; + if (in[i] < x->x_minSample) + x->x_minSample = in[i]; x->x_sampleCount++; if (x->x_sampleCount >= MG_SAMPLE_COUNT) { - sprintf(x->x_string, "~ %g", x->x_maxSample); + char l[64], m[64], h[64]; + sprintf(l, "%s%#g", (x->x_minSample < 0.0f ? "" : " "), x->x_minSample); + l[6] = '\0'; + sprintf(m, "%s%#g", (in[i] < 0.0f ? "" : " "), in[i]); + m[6] = '\0'; + sprintf(h, "%s%#g", (x->x_maxSample < 0.0f ? "" : " "), x->x_maxSample); + h[6] = '\0'; + sprintf(x->x_string, "~ %s %s %s", l, m, h); magicGlass_updateText(x, 0); - x->x_maxSample = -999999; + //x->x_minSample = 999999; + //x->x_maxSample = -999999; x->x_sampleCount = 0; } } diff --git a/src/g_magicglass.h b/src/g_magicglass.h index 92df1f58923aa082101489b890fc1d6d6ca32f11..7510993a9178f3321dc2338d7b493636fc47cc2c 100644 --- a/src/g_magicglass.h +++ b/src/g_magicglass.h @@ -16,6 +16,7 @@ typedef struct _magicGlass float x_sigF; int x_dspOn; int x_viewOn; + float x_minSample; float x_maxSample; int x_sampleCount; t_clock *x_clearClock; diff --git a/src/pd.tk b/src/pd.tk index f5424c8614312f8e43bce35efdd920e80177bae8..38ea09cf57831b22ab3af815189f2d35377be0ed 100644 --- a/src/pd.tk +++ b/src/pd.tk @@ -2104,6 +2104,7 @@ proc put_K12_objects {name object} { global pointer_y_local if { $k12_mode == 1 } { + pd [concat $name dirty 1 \;] pd [concat $name obj_abstraction K12/$object 0 20 \;] } } @@ -5646,30 +5647,44 @@ set font_fixed_metrics { 30 18 37 36 22 44 } - -proc get_font_for_size {size} { - return "::pd_font_${size}" -} +set font_measured_metrics {} # creates all the base fonts (i.e. pd_font_8 thru pd_font_36) so that they fit # into the metrics given by $::font_fixed_metrics for any given font/weight proc fit_font_into_metrics {} { +# TODO the fonts picked seem too small, probably on fixed width foreach {size width height} $::font_fixed_metrics { - set pixelheight [expr -1 * $height] - font create tmpfont -family $::font_family -weight $::font_weight \ - -size $pixelheight - while {[font measure tmpfont M] > $width || \ - [font metrics tmpfont -linespace] > $height} { - # this actually makes it smaller since pixel heights are negative - incr pixelheight 1 - font configure tmpfont -size $pixelheight + set myfont [get_font_for_size $size] + font create $myfont -family $::font_family -weight $::font_weight \ + -size [expr {-$height}] + set height2 $height + set giveup 0 + while {[font measure $myfont M] > $width || \ + [font metrics $myfont -linespace] > $height} { + incr height2 -1 + font configure $myfont -size [expr {-$height2}] + if {$height2 * 2 <= $height} { + set giveup 1 + set ::font_measured_metrics $::font_fixed_metrics + break + } + } + set ::font_measured_metrics \ + "$::font_measured_metrics $size\ + [font measure $myfont M] [font metrics $myfont -linespace]" + if {$giveup} { + ::pdwindow::post [format \ + [_ "WARNING: %s failed to find font size (%s) that fits into %sx%s!\n"]\ + [lindex [info level 0] 0] $size $width $height] + continue } - font create [get_font_for_size $size] \ - -family $::font_family -weight $::font_weight -size $pixelheight - font delete tmpfont } } +proc get_font_for_size {size} { + return "::pd_font_${size}" +} + proc find_default_font {} { set testfonts {"DejaVu Sans Mono" "Bitstream Vera Sans Mono" \ "Inconsolata" "Courier 10 Pitch" "Andale Mono" "Droid Sans Mono"} diff --git a/src/s_main.c b/src/s_main.c index 5e3cb97419471b89b28d6468c10f165a9df3cf51..7f4079e49bdd8e36684e3abfa852fea81fcb349e 100644 --- a/src/s_main.c +++ b/src/s_main.c @@ -120,6 +120,9 @@ typedef struct _fontinfo static t_fontinfo sys_fontlist[] = { \ {8, 6, 10, 1, 1, 1}, {10, 7, 13, 1, 1, 1}, {12, 9, 16, 1, 1, 1}, {16, 10, 20, 1, 1, 1}, {24, 15, 25, 1, 1, 1}, {36, 25, 45, 1, 1, 1}}; +//0.43 values +// {8, 6, 10, 0, 0, 0}, {10, 7, 13, 0, 0, 0}, {12, 9, 16, 0, 0, 0}, +// {16, 10, 20, 0, 0, 0}, {24, 15, 25, 0, 0, 0}, {36, 25, 45, 0, 0, 0}}; #define NFONT (sizeof(sys_fontlist)/sizeof(*sys_fontlist)) static t_fontinfo *sys_findfont(int fontsize)