Vertical Text with DirectWrite (+270° rotated) - directx-11

I need to show vertical text in my direct2d application. Following text formatting code rotates the text +90°.
m_textFormat->SetReadingDirection(DWRITE_READING_DIRECTION_BOTTOM_TO_TOP));
m_textFormat->SetFlowDirection(DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT));
But I want to rotate the text +270° like the following:
There are many other options in SetReadingDirection and SetFlowDirection. But none of them is working. The following sample also rotates only +90°: DirectWrite vertical text sample
If I manually rotate the text, it looks blur:
renderTarget->SetTransform(Matrix3x2F::Rotation(m_rotation, Point2F(left + height / 2.0f, top + (bottom - top) / 2.0f)));
Can anyone please help me with this?
Regards,

I don't think rotation angle is to user in this context, and it shouldn't be. It's a part of layout process that you don't need to interfere with, it's about displaying horizontal scripts along with vertical ones, see [1].
Regarding visual artifacts of transforms, that sounds normal, look at CreateGlyphRunAnalysis() method that takes transform into account, maybe that will give you better results.
[1] https://www.unicode.org/reports/tr50/

Related

Can I add a moving scale or axis in plots using Vegalite?

I am trying to add a movable scale or axis inside a plot. For instance: in this example of stacked plot: Click-to-view
I want to include a movable y-axis scale so, if we hover the graph and put the mouse pointer on the beginning of the orange color of any bar, the a-xis will begin from that bar. (Specifically, moving x=0 line.)
I meant something like this example (of d3).
https://observablehq.com/#d3/index-chart
But, here I want to change the value of x-axis by moving the line. Is it possible to do it using vegalite? If somebody has any similar example in vegalite, can you refer it?
Thank you!
AFAIK, there is no animation in Vega Lite. However, you may check out Gemini which aims to extend the grammar of data viz to some simple animations of single-view Vega/Vega-Lite charts

wxToolBar changing device coordinates

Using the mouse I am drawing 2D shapes on the client area of a MDIChildFrame. Recently I have added a wxToolBar to the frame and when I now draw a shape on the client area it seems that the points have shifted by the size the toolbar. Imagine that with mouse I am clicking on (100,100) and drawing a line to (150,150); however, the line appears somewhere (75,75) to (125,125). By the way, wxMouseEvent GetPosition(); reports (100,100) to me.
Removing the toolbar fixes the problem however, I want to keep the toolbar for ease of tool selection.
I use the code:
m_ToolBar=new wxToolBar(this, wxID_ANY);
m_ToolBar->AddTool() //
m_ToolBar->Realize();
this->SetToolBar(m_ToolBar);
Any ideas will be appreciated.
You can always use wxWindow::GetClientAreaOrigin() to manually offset the coordinates by the toolbar height but normally this shouldn't be necessary, and if this doesn't happen with a "normal" frame but only happens with wxMDIChildFrame it would be a bug in wxWidgets that should be reported as usual.
It's also recommended to not draw over wxFrame itself but rather put a wxWindow into it and draw on it. This should also take care of your problem.

Autocad scaling

I'm studing AutoCAD and encountered with a scale problem.
I write a simple detail, but when i'm setting Lineweight 1.00 mm AutoCAD draw 2cm line instead of 1mm line. I tried to change scale in Annotate -> Dimensions -> Scale factor = 0.05, but it didn't help.
Here is two screenshots: how it is with and withoud LWB pressed. It does some crazy things when I want just to create a line a bit thicker than default.
I have the same problem, but this post wasn't very helpful
And this post wasn't neither
I posed it gere according to this aricle that says, that SO is the best options for this kind of questions: https://meta.stackexchange.com/questions/188052/which-stack-exchange-site-is-best-for-autocad-questions
The scale factor only controls the scale of the linetype.
To change the way the lineweight displays on the screen, right click on the "Show/Hide Lineweight" toggle at the very bottom, click "Settings..." and adjust the slider labelled "Adjust Display Scale".
Note that this will not change the printed weight of the lines, just how they show up on your monitor.
Pretty sure the Autodesk forums is the best place to ask an AutoCAD setup question.
Both posts you linked to above (Autodesk forums and AUGI) pertain to plotting and/or PaperSpace but your post is clearly showing ModelSpace.
I would check if you've drawn your sketch using polylines with a defined width. Could be a units issue as well.

font size bug with CGContextShowTextAtPoint

I have some rather simple code drawing some text into a CGContext. Here is an excerpt (slightly edited).
CGContextSelectFont(context, "Helvetica", 1.5, kCGEncodingMacRoman);
CGContextShowTextAtPoint(context, xpos, ypos, "Hello", 5);
The text renders ok. For some unknown reason, however, the font changes to a smaller size after I click in the view containing the context. Also when I resize the window containing the view the font returns to original size. What is the reason for this?
1.5 points is mighty tiny to begin with. Assuming no other scaling is in effect, that will be one whole pixel and a blurry pixel above it on the screen.
You're probably seeing a bug that I ran into myself: On entry into drawRect:, the current context's text matrix was not the identity matrix. In my case, I saw it contain a scale by 13 on both axes, plus a translation. (Possibly left over from drawing the title bar.) I filed this in Radar as #10585106, in case you want to file your own and cite it.
The solution is to set the text matrix back to the identity transform before trying to draw text.
Once you do that, you'll find that your text will be exactly as tiny as you asked for it to be. You should change your font size to something more reasonable; Core Text contains a function to get the system fonts (from which you can get their sizes), and AppKit's NSFont class contains methods for the same purpose.

Get theme properties of Group Box lines

My goal is to draw a Group Box that is not rectangular but instead has the corners cut away. I do not mean just clipping the corners, but rather have a continuous closed path where the corners are "indented." I want this to match the colors/style of the current theme.
I noticed on Windows XP that the Group Box has 1-pixel gray lines, but on Windows 7 there is a 3D effect created by having a gray line next to a white line (the white line on the interior except on the bottom where it's below the gray line).
You can get the color of the text label of a Group Box using something like this:
COLORREF cref;
GetThemeColor(hTheme, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
So, I'm trying to figure out how to get the color(s) and/or properties of the lines used in a Group Box, then (I hope to) be able to draw the lines I want matching the Group Box style by separately drawing each piece of the shape I want. I'm not sure what properties are used to describe the lines or if functions line DrawRect will draw the 3D effect with a suitable Pen. Is there a way to set a Pen to draw these 3D effects (2-shade parallel lines)?
Thanks.
The thing I always find unexpected about groupboxes is that they are really a style of buttons. (BS_GROUPBOX).
Themed groupboxes (XP and later with classic mode off) use theme part BP_GROUPBOX in VSCLASS_BUTTON. You can use the usual theme APIs to get and draw. If your Group box needs text you can use DrawThemeText.
There are APIs for drawing non-themed group boxes too (e.g. DrawEdge), but I don't remember the details and it's unlikely that you need them.
As usual, I will point out that reproducing the behaviour of controls is always harder than you think it is going to be.
Martyn

Resources