How to grow/shrink a TextBlock (Font Size) to the available space in WPF?

The WPF Viewbox control will grow / shrink its contents to the available space: http://www.wpftutorial.net/ViewBox.html Just place your TextBlock within a ViewBox: <Viewbox Stretch=”Uniform” Width=”50″ Height=”50″> <TextBlock Text=”Test” /> </Viewbox> Of course, your Viewbox is typically scaled by its container, but hopefully you get the idea!

Why do and have smaller font sizes than in most user agent default stylesheets?

I’ve been searching through W3C mailing lists but haven’t found any debate on this decision. Here’s what I can infer: 1995 The first published version of the HTML spec (before CSS came into play) actually specified that h4 and h5 should be “normal font” size. The font size for h6 wasn’t explicitly specified, but I … Read more

How to convert to px?

<font size=1>- font size 1</font><br> <span style=”font-size:0.63em”>- font size: 0.63em</span><br> <font size=2>- font size 2</font><br> <span style=”font-size: 0.82em”>- font size: 0.82em</span><br> <font size=3>- font size 3</font><br> <span style=”font-size: 1.0em”>- font size: 1.0em</span><br> <font size=4>- font size 4</font><br> <span style=”font-size: 1.13em”>- font size: 1.13em</span><br> <font size=5>- font size 5</font><br> <span style=”font-size: 1.5em”>- font size: 1.5em</span><br> <font … Read more

Get computed font size for DOM element in JS

You could try to use the non-standard IE element.currentStyle property, otherwise you can look for the DOM Level 2 standard getComputedStyle method if available : function getStyle(el,styleProp) { var camelize = function (str) { return str.replace(/\-(\w)/g, function(str, letter){ return letter.toUpperCase(); }); }; if (el.currentStyle) { return el.currentStyle[camelize(styleProp)]; } else if (document.defaultView && document.defaultView.getComputedStyle) { return … Read more