Class FontScale


  • public class FontScale
    extends Object
    Simple static font scale methods for unit conversions. PostScript - current DTP point system used e.g in CSS (Cascading Style Sheets). - 1 point = 1pt = 1/72in (cala) = 0.3528 mm - 1 pica = 1pc = 12pt= 1/6in (cala) = 4.233(3) mm
    • Constructor Summary

      Constructors 
      Constructor Description
      FontScale()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static float[] ppiToPPMM​(float[] ppi)
      Converts [1/inch] to [1/mm] in place
      static float[] ppiToPPMM​(float[] ppi, float[] res)
      Converts [1/inch] to [1/mm] into res storage
      static float[] ppmmToPPI​(float[] ppmm)
      Converts [1/mm] to [1/inch] in place
      static float[] ppmmToPPI​(float[] ppmm, float[] res)
      Converts [1/mm] to [1/inch] into res storage
      static float ptToInch​(float points)
      Converts the the given points size to inch, dividing by 72 points per inch.
      static float ptToMM​(float points)
      Converts the the given points size to mm, dividing by 72 * 25.4 points per inch.
      static float toPixels​(float points, float res_dpi)
      Converts typical font size in points and screen resolution in dpi (pixels-per-inch) to font size in pixels, which can be used for pixel-size font scaling operations.
      static float toPixels2​(float points, float res_ppmm)
      Converts typical font size in points and screen resolution in pixels (pixels-per-mm) to font size in pixels, which can be used for pixel-size font scaling operations.
    • Constructor Detail

      • FontScale

        public FontScale()
    • Method Detail

      • ptToInch

        public static float ptToInch​(float points)
        Converts the the given points size to inch, dividing by 72 points per inch.
                 1 points = 1/72 inch
        
         
      • ptToMM

        public static float ptToMM​(float points)
        Converts the the given points size to mm, dividing by 72 * 25.4 points per inch.
                 1 inch = 25.4 mm
                 1 points = 1/72 inch
                 1 points = 1/72 * 25.4 mm
        
         
      • toPixels

        public static float toPixels​(float points,
                                     float res_dpi)
        Converts typical font size in points and screen resolution in dpi (pixels-per-inch) to font size in pixels, which can be used for pixel-size font scaling operations.
                Font Scale Formula:
                 1 points = 1/72 inch
        
                 pixels = points / 72 * res_dpi
         
        Parameters:
        points - in points
        res_dpi - display resolution in pixels-per-inch
        Returns:
        pixelSize scale factor for font operations.
        See Also:
        toPixels2(float, float)
      • toPixels2

        public static float toPixels2​(float points,
                                      float res_ppmm)
        Converts typical font size in points and screen resolution in pixels (pixels-per-mm) to font size in pixels, which can be used for pixel-size font scaling operations.
                Font Scale Formula:
                 1 inch = 25.4 mm
                 1 points = 1/72 inch
                 1 points = 1/72 * 25.4 mm
        
                 pixels = points / 72 * 25.4 * res_ppmm
         
        Parameters:
        points - in points
        res_ppmm - display resolution in pixels-per-mm
        Returns:
        pixelSize scale factor for font operations.
        See Also:
        toPixels(float, float)
      • ppmmToPPI

        public static float[] ppmmToPPI​(float[] ppmm)
        Converts [1/mm] to [1/inch] in place
        Parameters:
        ppmm - float[2] [1/mm] value
        Returns:
        return [1/inch] value
      • ppmmToPPI

        public static float[] ppmmToPPI​(float[] ppmm,
                                        float[] res)
        Converts [1/mm] to [1/inch] into res storage
        Parameters:
        ppmm - float[2] [1/mm] value
        res - the float[2] result storage
        Returns:
        return [1/inch] value, i.e. the given res storage
      • ppiToPPMM

        public static float[] ppiToPPMM​(float[] ppi)
        Converts [1/inch] to [1/mm] in place
        Parameters:
        ppi - float[2] [1/inch] value
        Returns:
        return [1/mm] value
      • ppiToPPMM

        public static float[] ppiToPPMM​(float[] ppi,
                                        float[] res)
        Converts [1/inch] to [1/mm] into res storage
        Parameters:
        ppi - float[2] [1/inch] value
        res - the float[2] result storage
        Returns:
        return [1/mm] value, i.e. the given res storage