Font Size in 3D

Originally Posted 25 February 2016, 8:17 am EST

  • Originally Posted 25 February 2016, 8:17 am EST

    I'm specifying TrueType
    SetUseTruetype(TRUE);

    Setting the font type and size using a HFONT only affects the font type, but not the size?
    SetAxisFont(hFont);

    Setting the font type and size using a string also only affects the font type, and not the size?
    Xrt3dSetPropString(m_hChart,XRT3D_AXIS_FONT,_T("Sergoe UI,9,Regular"));

    The only way to change the font size is to use the stroke size property
    SetAxisStrokeSize(50);

    But since I'm using TrueType fonts I didn't expect this property to have any affect?

    This stroke size property is using unit cube size etc. to scale the size of the font, how can I convert the TrueType font size e.g. 9 to a unit cube size that I can use in SetAxisStrokeSize?

    -cpede
  • Reply

    Hi,

    In addition to the thread here, can you please share a stripped down application where the Axis Font size related code is not working for you? I will try to narrow down the cause and assist you further at the earliest.

    Thanks and Regards,
    Pragati Kaushik
  • Reply

    OK, some quick code.

    Here I try to calculate the stroke size based on the size of the actual font. This however needs to be called for every resize of the graph.

    BUT, it seems to produce too small fonts.

    Is the unit cube size the same as the graph height?

    int nCube = GetGraphHeight();
    RECT textRect;
    textRect.left = textRect.right = textRect.top = textRect.bottom = 0;
    TCHAR szBuffer[4] = {0};
    _tcscpy_s(szBuffer,_countof(szBuffer),_T("123"));
    HDC hDC = ::GetDC(GetSafeHwnd());
    HDC hTextDC = ::CreateCompatibleDC(hDC);
    HFONT hOldFont = (HFONT)::SelectObject(hTextDC,hFont);
    DrawText(hTextDC,szBuffer,_tcslen(szBuffer),&textRect,DT_CALCRECT);
    ::SelectObject(hTextDC,hOldFont);
    ::DeleteDC(hTextDC);
    ::ReleaseDC(GetSafeHwnd(),hDC);
    float fCube = 1000.0f*(float)(textRect.bottom-textRect.top)/(float)nCube;
    SetAxisStrokeSize((int)fCube);


    -cpede
  • Reply

    Hi,

    >Setting the font type and size using a HFONT only affects the font type, but not the size?
    >SetAxisFont(hFont);
    >Setting the font type and size using a string also only affects the font type, and not the size?
    >Xrt3dSetPropString(m_hChart,XRT3D_AXIS_FONT,_T("Sergoe UI,9,Regular"));
    >How can I convert the TrueType font size e.g. 9 to a unit cube size that I can use in SetAxisStrokeSize?


    Setting font size is important and affect all fonts other than those attached to the PlotCube (e.g. Headers, footers, ChartLabels, etc.). Fonts that are part of the PlotCube however, have to be treated differently as they must maintain an illusion of 3 dimensions as the PlotCube is adjusted through actions such as rotation, translation, zooming, etc. To draw the lettering of the axis title and annotations it is necessary to draw the image and map it to the 3D "space" of the PlotCube. For the result to be proper, it is necessary to define the fonts as a fractional height of the PlotCube.

    > Can I calculate the Cube size myself, and thereby correct the size of the font to
    > match the size of the standard TrueType fonts?


    No. That is not available with the Chart3D.

    > Can I avoid Chart to use perspective on the size of the fonts? (I mean what is the
    > purpose of a text that becomes smaller and unreadable?)


    As discussed above, if the fonts associated with each axis do not rotated and scale with the cube, the illusion of 3 dimensions is lost and confusing to the eye. Thus this behavior is not going to change.

    > When the font rotation is set to XRT3D_FONT_ROTATION_NONE, and in a contour plot
    > (where the is no perspective or 3D depth) why doesn't it just uses the TrueType font
    > and size specified?


    Are you looking for a 2d projection of the elevations(contour or heat map). If that is the case then setting values as given below will generate such a projection. For such a projection, there is no rotation or 3D illusion to maintain, so the height of the TrueType font is considered during the draw although the stroke size remains a factor for consistency when switching between the 2D projection and full 3D surface chart.

    Xrt3dSetValues(hChart,
    XRT3D_USE_TRUETYPE, TRUE,
    XRT3D_DRAW_CONTOURS, TRUE,
    XRT3D_DRAW_ZONES, TRUE,
    XRT3D_DRAW_MESH, FALSE,
    XRT3D_DRAW_SHADED, FALSE,
    nullptr);

    Hope this helps!

    Regards,
    Nilay Vishwakarma
  • Reply

    Hi,

    Any new from your development team on this?

    -cpede
  • Reply

    Hi,

    Thank you for sharing the details. I could also observe the behavior at my end. I have forwarded it to the development team for their insights and will let you know once they come back with any information on the same.

    Warm Regards,
    Pragati Kaushik
  • Reply

    Hi Pragati,

    Thanks for the answer.

    I use your project from the topic http://our.componentone.com/groups/topic/font-rotation-in-3d-plot/ to investigate this problem.

    It is very clear that if I specify a size for the XRT3D_AXIS_FONT it has absolutely no effect.

    { // font
    LOGFONT lf;
    memset(&lf, 0, sizeof(LOGFONT));

    auto hDC = GetDC(hwndChart);
    memset(&lf, 0, sizeof(LOGFONT));
    lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    lf.lfCharSet = DEFAULT_CHARSET;
    _tcscpy_s(lf.lfFaceName, _T("Helvetica"));

    auto hFont = CreateFontIndirect(&lf);
    Xrt3dSetValues(hChart, XRT3D_LEGEND_FONT, hFont, nullptr);
    Xrt3dSetValues(hChart, XRT3D_HEADER_FONT, hFont, nullptr);
    Xrt3dSetValues(hChart, XRT3D_FONT_ROTATION, XRT3D_FONT_ROTATION_NONE, NULL);
    DeleteObject((HGDIOBJ)(HFONT)(hFont));

    lf.lfHeight = -MulDiv(36, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    _tcscpy_s(lf.lfFaceName, _T("Helvetica"));
    hFont = CreateFontIndirect(&lf);
    Xrt3dSetValues(hChart, XRT3D_AXIS_FONT, hFont, nullptr);
    DeleteObject((HGDIOBJ)(HFONT)(hFont));
    ReleaseDC(nullptr, hDC);
    }


    The above should make the font on the axis much larger than e.g. the header, but it doesn't.

    And the reason is that it follows the Cube size and the perspective of the 3D graph.

    My question are:
    Can I calculate the Cube size myself, and thereby correct the size of the font to match the size of the standard TrueType fonts?

    Can I avoid Chart to use perspective on the size of the fonts? (I mean what is the purpose of a text that becomes smaller and unreadable?)

    When the font rotation is set to XRT3D_FONT_ROTATION_NONE, and in a contour plot (where the is no perspective or 3D depth) why doesn't it just uses the TrueType font and size specified?

    -cpede


  • Reply

    Please follow up again on my comment:

    Alternatively, it would however be nice if the largest font displayed (the one most in the foreground) in the 3D perspective way, matched the font size specified. This would at least give some kind of consistency when switching from Contour to e.g. Surface plot and back; - or if you could give the cube size used to scale the 3D fonts to the size of the plot, I could recalculate the stroke size on when the plot re-sizes.

    I have attached a picture for you to see the result of your decision, and how it looks in the real world.

    -cpede

  • Reply

    Hi,

    I have forwarded your comments to the devs and will let you know once they come back on this.

    Thanks.
  • Reply

    Hi,

    Thanks for the answer. Yes, you are right it works for the contour plot.
    Maybe it is because I'm not used to working in 3D environments myself that I find scaling the text based on the perspective is strange. I can see that VTK also uses this perspective way of displaying the labels in 3D views, - but that also looks strange.

    No question that I would prefer a mode where the size of the text was constant, at least when XRT3D_FONT_ROTATION_NONE was set.

    Alternatively, it would however be nice if the largest font displayed (the one most in the foreground) in the 3D perspective way, matched the font size specified. This would at least give some kind of consistency when switching from Contour to e.g. Surface plot and back; - or if you could give the cube size used to scale the 3D fonts to the size of the plot, I could recalculate the stroke size on when the plot re-sizes.

    -cpede
  • Reply

    Any news about this?

    -cpede
  • Reply

    Hi,

    I will forward your comments to the development team and will get back to you when there is any information from their side.

    Thanks.
  • Reply

    Hi,

    I have asked the developer for an update. Will update you once he reverts back.

    Thanks,
    Pragati
  • Reply

    Well, one thing you could do, as related to my first entry, is to make it possible to read the Cube Size you use internally to calculate the font size, - via your API. That way I could proceed, and it will not affect your execution of your code.

    -cpede
  • Reply

    Hi,

    I am sorry for the delay on this. I am talking to the developer to look at it on high priority and will update the thread once there is anything from him.

    Thanks.
  • Reply

    Any news about this small feature?

    -cpede
  • Reply

    Hi,

    I have asked the developer for this and will share his insights soon.

    ~Pragati
  • Marked as Answer

    Reply

    Hi,

    I am sorry to mention, this behavior cannot be changed. Our ActiveX Controls are in maintenance mode and we no longer provide any bug fixes or enhancements for the same.

    This being said, we can still look into the matter and if a reasonable set of customers demand for a bug fix we can try to fix it or maybe suggest a workaround for the same, if it exists.

    As per the concerned team, changing this behavior includes a number of side effects which can hamper the product. Hence, it cannot be changed.

    Thanks.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels