MHB Solving the Font Size Puzzle for Thumbnail Layers

  • Thread starter Thread starter Echilon1
  • Start date Start date
  • Tags Tags
    Font Puzzle
AI Thread Summary
The discussion revolves around calculating the appropriate font size for a label in both full-size and thumbnail layers. The user aims to maintain a consistent font size ratio when scaling down the layer, specifically needing to adjust a font size of 30 points for a thumbnail that is one-third the size of the full version. Despite attempts to derive a formula using the parent size and ratios, the user struggles to achieve the desired outcome. The current approach involves adjusting the font size based on the layer's width and the specified font size, but it has not yielded the correct results. The goal is to ensure that the font size scales proportionately with the layer dimensions.
Echilon1
Messages
2
Reaction score
0
I'm drawing a scene with, trying to size my font correctly. I have both a big and small version of the layer on the screen at the same time.

I want to set the font in a label on this layer (both the thumbnail and the full size version) to, for example, size 30. This works fine for the full size layer (call it ratio 1), but if I make the thumbnail 1/3 as big, how do I calculate that the font should be 1/3 as big? I can't get the logic right despite multiplying these numbers all ways.

The properties which the user can change are:

- Font size (pts)
- Thumbnail size (px wide)

To position the label correctly I'm using this (which works):

Code:
// 'element' is the customizable element. element.location is  the percentage across the layer where it's located. Eg: 50 is half way
        CGPoint relativeCoords = ccp (self.contentSize.width/(100/element.location.x),
                                      self.contentSize.height/(100/element.location.y));
        layer.position = relativeCoords;

To determine the right font size, I've tried, among other variants, this (to no avail):

Code:
-(void)sizeToRelative(CGSize)parentSize {
      // self.lbl is the layer within my element
      CGFloat ratioWidth = (parentSize.width/100);
      CGFloat ratioFontSize = (textEle.textProperties.fontSize/100)*(1/3)*(parentSize.width/100);
      [self.lbl setFontSize:ratioFontSize*element.textProperties.fontSize];

The idea is that if I pass in a `parentSize`, to calculate the relative font size. The 'default' size should be as big as 30px in a 100px wide layer. If I have a layer 200px wide, it should return 60 if the user sets the font at size 30.
 
Mathematics news on Phys.org
In psuedo code, this would be:
Code:
        // 'element' is the customizable element. element.location is   the percentage across the layer where it's located. Eg: 50 is half way
        xFromOrigin = width/(100/location.x)
        yFromOrigin = height/(100/location.y));

To determine the right font size, I've tried, among other variants, this (to no avail):
Code:
Given a parentSize with a width and height:
       ratioWidth = (parentSize.width/100);
       ratioFontSize = (fontSize/100)*(1/3)*(parentSize.width/100);
       adjustedFontSize = ratioFontSize*fontSize];
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...

Similar threads

Replies
1
Views
4K
Back
Top