Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Track Info Panel with ability to change font (Read 724981 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Track Info Panel with ability to change font

Reply #275
it seems I can not get this one to work , doesn't $font support functions inside it ?

Quote
$puts(size,$div($calcwidth(%_path%),100))

$font(Arial,$get(size),,)



or is there any better way to fit a text line to 1 line only (reduce font size if wider than panel size)

thanks

Track Info Panel with ability to change font

Reply #276
The $font() function does indeed support functions inside of it, however the size parameter you are specifying is in font point sizes not pixel size, and the size you are generating with $calcwidth() is pixel size not font point size.  terrestrial actually had it written the other way originally but we encouraged him to change is so that for example $font(tahoma,8,,) would appear the same size as 8pt tahoma in every other plugin.

What you need to do is convert your pixel size to font size. There is a formula pasted somewhere earlier in this thread. Or you can do something like:

$font(Arial,$ifgreater($calcwidth(%path%),%_width%,7,12),,)%path%

though it's hard to give a good example without knowing your application I think maybe you can see where I'm going.

Track Info Panel with ability to change font

Reply #277
Those CWB hooks keep adding more and more useful functions I need to start checking for updates more often.. that hook was added just this past week

DIN1031: Make sure you update your hooks to the latest version, I just tested kockroach's suggestion and it is working fine here.


Thx a lot it work fine .

Bye
DIN1031

Track Info Panel with ability to change font

Reply #278
Code: [Select]
$padding(0,49)
$padding(0,29)
$drawrect(,,,12,brushcolor-null pencolor-255-255-255)

$puts(progress,$muldiv(%playback_time_seconds%,$sub(%_width%,24),%length_seconds%))
$ifgreater($get(progress),0,
$padding(2,2)$drawrect(,,$get(progress),8,brushcolor-255-255-255 pencolor-null),)
$alignabs(5,80,60,60,60,60)$font(,8,bold,128-128-128)[%playback_time%]$alignabs(275,80,60,60,60,60)%length%
$alignabs(110,80,600,600,60,60)$font(,8,bold,128-128-128)$upper(%_trackinfo_mode%)
$alignabs(5,100,%_width%,%_height%,left,top)
$font(Lucida Sans Unicode,8,bold,100-100-100)$upper(%bitrate% %codec% %channels% - $if(%play_count%,$if($strcmp(%play_count%,1),PLAYED 1 TIME,PLAYED %play_count% TIMES),NOT PLAYED YET))

I half-stole-half-created that code. Anyway, I want to make the two pieces of text inside the progress bar - %_trackinfo_mode% and %length% to be centered and right-justified, so I can use any width in foobar I like. How would I do that?
There's a storm on the loose, there's sirens in my head...

Track Info Panel with ability to change font

Reply #279
Is this the sort of thing you are looking for?

Code: [Select]
$padding(0,49)
$padding(0,29)
$drawrect(,,,12,brushcolor-null pencolor-255-255-255)

$puts(progress,$muldiv(%playback_time_seconds%,$sub(%_width%,24),%length_seconds%))
$ifgreater($get(progress),0,
$padding(2,2)$drawrect(,,$get(progress),8,brushcolor-255-255-255 pencolor-null),)
//$alignabs(5,80,60,60,60,60)
$align(left,)$font(,8,bold,128-128-128)[%playback_time%]
//$alignabs(275,80,60,60,60,60)
$align(right,)%length%
//$alignabs(110,80,600,600,60,60)
$align(center,)$font(,8,bold,128-128-128)$upper(%_trackinfo_mode%)
$alignabs(5,100,%_width%,%_height%,left,top)
$font(Lucida Sans Unicode,8,bold,100-100-100)$upper(%bitrate% %codec% %channels% - $if(%play_count%,$if($strcmp(%play_count%,1),PLAYED 1 TIME,PLAYED %play_count% TIMES),NOT PLAYED YET))

Track Info Panel with ability to change font

Reply #280
The $font() function does indeed support functions inside of it, however the size parameter you are specifying is in font point sizes not pixel size, and the size you are generating with $calcwidth() is pixel size not font point size.  terrestrial actually had it written the other way originally but we encouraged him to change is so that for example $font(tahoma,8,,) would appear the same size as 8pt tahoma in every other plugin.

What you need to do is convert your pixel size to font size. There is a formula pasted somewhere earlier in this thread. Or you can do something like:

$font(Arial,$ifgreater($calcwidth(%path%),%_width%,7,12),,)%path%

though it's hard to give a good example without knowing your application I think maybe you can see where I'm going.


what i've been trying is to fit the txt to the panel, my code was wrong for sure  i was just trying to init some coding and test the var.

thanks for the solution. but I noticed weird behavior from calwidth function. Take a look at these 2 captures.





Quote
$calcwidth(%path%) / %_width%
$puts(txt2,$font(Trebuchet MS,$ifgreater($calcwidth(%path%),%_width%,7,10),,))
.......
$get(txt2)%_path%


my panel size is indeed 1024 (max screen). the font size was changed even when the txt width was still smaller than %width%

did I do something wrong ?

another example of long path txt (bigger than 1024) being wrapped, using the original $puts(txt2,$font(Trebuchet MS,10,,))


Track Info Panel with ability to change font

Reply #281
what is the default setting for this foo_trackinfo_mod?  I deleted it and cannot get any of the posted codes working right.  I don't know squat about writing code so I'll just stick with the default for now.

FWIW,  my track info column is set up like the above.  It goes almost across the whole screen and is a few inches high.

Thanks,


Ron

Track Info Panel with ability to change font

Reply #282
huythuy:

The font sizes used to be pixel sizes, but now are point sizes. To convert between them you can use this formula: pixels = points*dpi/72 (where dpi is normally 92). Point size seems to be consistent with Columns UI and everything else, at least to me. Are you sure you have the latest version?

You can either try to calculate the size of the font by applying the above formula or here is an alternate approach I used earlier to switch between three different font templates based on the length of text in relation to the width of the panel. Basically it sets the font to a large value, then compares the width of the text string to the width of the panel and if it's too long it knocks it down to a smaller font size, then repeats the process.


This one auto-switches between 3 font layouts based on the length of the song & album titles
Code: [Select]
$font(Tahoma,16,,)
$ifgreater($add($calcwidth(%artist%%title%%album%%date%),10),%_width%,$font(,10,shadow,),$font(,14,shadow,))
$align(left,)$rgb(233,233,233)$if(%artist%,%artist% $rgb(0,128,255)$char(47)$rgb(233,233,233) ,)$if2(%title%,)

$font(Tahoma,16,,)
$if($strcmp($left(%path%,7),http$char(58)$char(47)$char(47)),,
$ifgreater($add($calcwidth(%artist%%title%%album%%date%),10),%_width%,$font(,10,shadow,)$align(right,bottom),$font(,14,shadow,)$align(right,))
$ifgreater($add($calcwidth(%artist%%title%%album%%date%),10),%_width%,$font(,7,shadow,),)
$rgb(180,180,180)$if2(%album%,)$if(%date%, $rgb(0,128,255)$char(40)$rgb(180,180,180)%date%$rgb(0,128,255)$char(41),)
)


foreveranoob1:

To reset any component to it's default settings:
- Close foobar
- Remove the component .dll from the foobar components directory
- Restart foobar and answer [No] when prompted if you want to retain the old settings
- Close foobar
- Replace the component .dll into the foobar components directory
- Restart foobar

However to answer your question, the default settings I see for this component are:

Font: MS Shell Dlg 8pt
Default text: $rgb(0,0,0)
Background: $rgb(255,255,255)
Vertical padding: 10
Horizontal padding: 10
Minimum Height: 0
Edge Style: Sunken
  • Update every second

Formatting String:
Code: [Select]
Mode: %_trackinfo_mode%$char(10)$char(10)$if(%_trackinfo_notrack%,No track,Artist: %artist%$char(10)Title: %title%$char(10)Album: %album%)

Though to be perfectly honest the first thing I do whenever I add one of thise panels is set vertical and horizontal padding to 0 and the edge style to none.

Track Info Panel with ability to change font

Reply #283
Yotsuya,

    Thanks!

Track Info Panel with ability to change font

Reply #284
Add icons to the bottom of your trackinfo to indicate file type, tag types, and current playback mode:


Code: [Select]
// File Icon
$if($strcmp($left(%path%,7),http$char(58)$char(47)$char(47)),
$imageabs(,$sub(%_height%,52),icons\png\%codec%.png,)
,
$imageabs(,$sub(%_height%,52),icons\png\$replace(%filename_ext%,%filename%.,).png,)
)

// Tag Icons
$if($strstr($info(tagtype),id3v1),$imageabs(60,$sub(%_height%,52),icons\png\ID3v1.png,))
$if($strstr($info(tagtype),id3v2),$imageabs(110,$sub(%_height%,52),icons\png\ID3v2.png,))
$if($strstr($info(tagtype),apev2),$imageabs(160,$sub(%_height%,52),icons\png\APEv1.png,))

// Playback Icon
$imageabs($sub(%_width%,36),$sub(%_height%,47),images\
$if(%ispaused%,pause.png,$if(%isplaying%,play.png,stop.png))
,)
$font(Verdana,10,bold,128-128-128)
$if(%ispaused%,
$alignabs($sub(%_width%,47),$sub(%_height%,20),%_width%,%_height%,,)Pause
,$if(%isplaying%,
$alignabs($sub(%_width%,40),$sub(%_height%,20),%_width%,%_height%,,)Play
,
$alignabs($sub(%_width%,40),$sub(%_height%,20),%_width%,%_height%,,)Stop
))

Images Used:

The file type icons are simple png conversions of the ico files that are included with foobar.

   
ID3v1.png, ID3v2.png, APEv2.png

   
pause.png, play.png, stop.png

Track Info Panel with ability to change font

Reply #285
what is the default setting for this foo_trackinfo_mod?  I deleted it and cannot get any of the posted codes working right.  I don't know squat about writing code so I'll just stick with the default for now.

FWIW,  my track info column is set up like the above.  It goes almost across the whole screen and is a few inches high.

Thanks,
Ron


you can use mine , here is the code , there is no nuclear power here, just some simple codes allow me to read info from 2 meters away  . I prefer it spans like this in order to display long title tracks of classical music . I did not even check the tags if it available then replace with path info because I LOVE ? sign hehe it helps me know that information is missing. You should choose a different font instead of "interstate" and "Jocelyn".

Code: [Select]
$puts(txt1,$font(Interstate Light Cond,18,bold,))
$puts(txt2,$font(Trebuchet MS,10,,))
$puts(txt3,$font(Jocelyn,37,,))
$puts(color1,FFFFFF)
$puts(color2,276EB4)
$puts(color3,318CB9)
$puts(color4,7CBEDB)
$puts(bgcolor,000000)

$if(%_trackinfo_notrack%,DBBE7CNo track,
$alignset()
$alignrel(left,top)
$get(txt1)
$get(color4)$upper(%artist%) $if(%composer%,$get(color2)'['%composer%']',) $char(10)
$get(color1)%title% $get(color2)'['%tracknumber%']'$char(10)
$get(color2)%album% $get(color4)'['%date%']'$char(10)
$if(%_trackinfo_notrack%,'.',$get(txt2)$get(bgcolor).$char(10)$get(color1)%_path%)

$alignabs(right,top)
$get(txt3)$get(color3)$if(%_isplaying%,%_time_elapsed%/)%length%$char(10)
$get(txt1)$get(color4)%rating% stars
)




================

@Yotsuya ; Thanks . I'd prefer to scale down the font size to fit rather than choosing between font options. I will try to use the formula later.

Track Info Panel with ability to change font

Reply #286
This is what I've been working on.



Track Info Panel with ability to change font

Reply #288
Um, that's the default PLS icon included with foobar .. look in your icons directory. All I did was photoshop out the "PLS" and replace it with "ID3v1" "ID3v2" and "APEv2". make sure to enable thumbnail view or load the files in irfanview etc to see the full size icons.

Track Info Panel with ability to change font

Reply #289
Guess I meant something like "Vorbis" for the comments.  Oh well, no biggie.

Track Info Panel with ability to change font

Reply #290
What you need to do is convert your pixel size to font size. There is a formula pasted somewhere earlier in this thread. Or you can do something like:
$font(Arial,$ifgreater($calcwidth(%path%),%_width%,7,12),,)%path%


I used something like this:
Code: [Select]
$puts(txt1,$if($greater($mul($calcwidth(%artist% - %title%),5),%_width%), 
$if($greater($mul($calcwidth(%artist% - %title%),4),%_width%),
$if($greater($mul($calcwidth(%artist% - %title%),3),%_width%),
$if($greater($add($mul($calcwidth(%artist% - %title%),2),75),%_width%),
10,15),20),25),30))


Track Info Panel with ability to change font

Reply #292
Anyone know how to get this going from bottom to top, instead of top to bottom

Code: [Select]
$padding(0,0)

$puts(progress,$muldiv(%playback_time_seconds%,$sub(%_height%,4),%length_seconds%))

$ifgreater($get(progress),0,
$padding(0,0)$drawrect(,,4,$get(progress),brushcolor-175-175-175 pencolor-null),)

Track Info Panel with ability to change font

Reply #293
Is there a way to set the font size in pt instead of px? I can't emulate tahoma 8pt through the $font function.

Track Info Panel with ability to change font

Reply #294
Elliott:

Your code appears to be working fine on my end.  Have you tried making another panel and pasting the code? Have you tried using a different font?  Is there more code being used in the panel than what you posted?

I got the same problems as Elliott. If I have a panel which is high enough, the time appears. But when resizing the panel, the time disappears suddenly when it reaches around the middle of the panel. The progressbar is drawn even at the bottom of the panel...

Is this the sort of thing you are looking for?

Code: [Select]
$padding(0,49)
$padding(0,29)
$drawrect(,,,12,brushcolor-null pencolor-255-255-255)

$puts(progress,$muldiv(%playback_time_seconds%,$sub(%_width%,24),%length_seconds%))
$ifgreater($get(progress),0,
$padding(2,2)$drawrect(,,$get(progress),8,brushcolor-255-255-255 pencolor-null),)
//$alignabs(5,80,60,60,60,60)
$align(left,)$font(,8,bold,128-128-128)[%playback_time%]
//$alignabs(275,80,60,60,60,60)
$align(right,)%length%
//$alignabs(110,80,600,600,60,60)
$align(center,)$font(,8,bold,128-128-128)$upper(%_trackinfo_mode%)
$alignabs(5,100,%_width%,%_height%,left,top)
$font(Lucida Sans Unicode,8,bold,100-100-100)$upper(%bitrate% %codec% %channels% - $if(%play_count%,$if($strcmp(%play_count%,1),PLAYED 1 TIME,PLAYED %play_count% TIMES),NOT PLAYED YET))

I get the same problem here. If I resize my panel, at one point, the time-text disappears, while the bar (and the info below (bitrate, codec, ...)) is still visible. I make it higher again and the text reapears... Strange..
Eddie

Track Info Panel with ability to change font

Reply #295
Metal Termite:
There were a few earlier versions of this component where fonts were specified in pixel size, however afaik fonts are already changed to point size instead of pixel. Does $font(tahoma,8,,) not give you the same size text as other panels displaying Tahoma 8pt font? If not, make sure you have a recent version of this component and post some code and screenshots demonstrating the problem.

EddieFAF,Ken-chan,Eliott:
I think the problem with the disappearing text is being caused by the use of the $padding() function all that padding is adding up and if you shrink your panel I think it's clipping off the text. The progress bar itself is not affected because it uses absolute alignment. I have merged all your code and rewritten it using $alignabs() instead of $align() and $padding():
Code: [Select]
// Common Variables
$puts(progress,$muldiv(100,%playback_time_seconds%,%length_seconds%))
$puts(offset.x,20)
$puts(offset.top,10)
$puts(offset.bottom,40)

// Main Text
$font(tahoma,7,,)
$alignabs($get(offset.x),$get(offset.top),%_width%,%_height%,,)[%album%]
$alignabs($get(offset.x),$add($get(offset.top),10),%_width%,%_height%,,)[Track %tracknumber%]
$alignabs($get(offset.x),$add($get(offset.top),20),%_width%,%_height%,,)[%date%]

$alignabs($sub(%_width%,$mul($get(offset.x),2)),$get(offset.top),%_width%,%_height%,,)[CD %discnumber%]
//$alignabs($sub(%_width%,$mul($get(offset.x),2)),$add($get(offset.top),10),%_width%,%_height%,,)[]
$alignabs($sub(%_width%,$mul($get(offset.x),2)),$add($get(offset.top),20),%_width%,%_height%,,)[%genre%]


// Progress Bar
$drawrect($get(offset.x),$sub(%_height%,$get(offset.bottom)),$sub(%_width%,$mul($get(offset.x),2)),10,brushcolor-null pencolor-255-255-255)
$ifgreater($get(progress),0,
$drawrect($get(offset.x),$sub(%_height%,$sub($get(offset.bottom),2)),$muldiv($get(progress),$sub(%_width%,$mul($get(offset.x),2)),100),6,brushcolor-255-255-255 pencolor-null)
,)

// Progress Text
$font(tahoma,7,,)
$alignabs($get(offset.x),$sub(%_height%,$get(offset.bottom)),%_width%,%_height%,,)[%_time_elapsed%]
$alignabs($div($sub(%_width%,$calcwidth($upper(%_trackinfo_mode%))),2),$sub(%_height%,$get(offset.bottom)),%_width%,%_height%,,)[$upper(%_trackinfo_mode%)]
$alignabs($sub(%_width%,$calcwidth(%length%),$get(offset.x)),$sub(%_height%,$get(offset.bottom)),%_width%,%_height%,,)[%length%]

// Bottom Text
$font(Lucida Sans Unicode,8,bold,100-100-100)
$alignabs($get(offset.x),$sub(%_height%,16),%_width%,%_height%,,)
$upper(%bitrate% %codec% %channels% - $if(%play_count%,$if($strcmp(%play_count%,1),PLAYED 1 TIME,PLAYED %play_count% TIMES),NOT PLAYED YET))
Hopefully atleast one of you will find this helpful.

Track Info Panel with ability to change font

Reply #296
sorry for interrupting this thread by a stupid question, but I have to ask again....hehe

This animated "default line ending style" scroll is planed to be implemented in near future?
A simple Yes or No would be enough!

Ok another importand question for me is:
Can I run a uptodate version of "trackinfo mod panel" together with this bugfixed version of orig. Trackinfo panel (0.82) simultanious?
I tried this for a few weeks with one of the first mod-rls but it seemed not to work.

thx a lot

Track Info Panel with ability to change font

Reply #297
To Infernus' 2nd:
---> Just try it !! (and allways backup your scripts)


And here is mine:
I dont get the font-thing right ... - How are the pt or px of a font measured ? -Length or Height of a typical sign?? -Or the multiplication of its L and H ?? -Or what else ...??
(I need this to get the half-height [in px] of a variable font-size, I'm working on ... )

.THNX.

Track Info Panel with ability to change font

Reply #298
I love this new version with the image support and advanced code.
Though I think there is a bug with the font sizes in the $font function. 8 is pretty small but 9 is as large as 10 if I would use the font dialog at the top.

EDIT: I can confirm this with more than one font. I hope you understand what I mean by the way. Can anyone else confirm there is something weird here?

Track Info Panel with ability to change font

Reply #299


Code: [Select]
$font(,,nocleartype,)
default Tahoma 8pt as set in trackinfo configuration

$char(10)

$font(tahoma,8,nocleartype,)
Tahoma 8 as set by '$font' function