Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Rick C. Hodgin
  Where is Rick C. Hodgin?
 Indiana - United States
 Rick C. Hodgin
Subject: True foxels to pixels
Thread ID: 395475 Message ID: 395475 # Views: 58 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Wednesday, January 15, 2014 10:51:30 AM         

Does anyone know of a true algorithm which mimics VFP's foxels to pixels conversion?

I found this algorithm online and modified it somewhat to adjust for the font attributes bold, underline, and italics. It ranges in accuracy (depending on the font and attributes) from being perfect, to being within a few pixels of being accurate.

I can't figure out what VFP is doing to convert foxels to pixels as it does. Does anyone know?

* Converts VFP foxels to screen pixels
* tnFoxels        - fractional foxel value to convert
* tlVertical      - Is this a Y coordinate?
* tcFontName      - "Arial" for example
* tnFontSize      - 10
* tlFontBold      - Is the font bold?
* tlFontItalics   - Is the font in italics?
* tlFontUnderline - Is the font underlined?
FUNCTION foxels_to_pixels
LPARAMETERS tnFoxels, tlVertical, tcFontName, tnFontSize, tlFontBold, tlFontItalics, tlFontUnderline
LOCAL lcStyle
    * Note:     B Bold
    *           I Italic
    *           N Normal
    *           O Outline
    *           Q Opaque
    *           S Shadow
    *           – Strikeout
    *           T Transparent
    *           U Underline
    lcStyle = IIF(tlFontBold, "B", "") + IIF(tlFontItalics, "I", "") + IIF(tlFontUnderline, "U", "")
    IF PCOUNT() > 2
        RETURN tnFoxels * FONTMETRIC(IIF(tlVertical, 1, 6), tcFontName, tnFontSize, lcStyle)
        RETURN tnFoxels * FONTMETRIC(IIF(tlVertical, 1, 6))

Best regards,
Rick C. Hodgin


True foxels to pixels Posted by Rick C. Hodgin @ 1/15/2014 10:51:30 AM
RE: True foxels to pixels Posted by David Mustakim @ 1/15/2014 11:11:28 AM