Right-side text limit working erratically while changing the font - matlab

Please note that I have already posted this question # mathworks.com but did not get any answer.
Let me try to explain a slight problem that I am facing.
In this figure, you can see that I have font “Monospaced” with font size 14. The right-hand text limit is place at 75th column. As you can see from the code, the line terminates at 75th position and then goes to the next line.
Now, if I change the font to say, “Comic Sans”, keeping the same font, the ‘right-hand text’ limiting line moves to a new position. But strangely, the text terminates not at the position where the line is shown, but in the same place where initially the ‘right-hand text limit’ was there.
I checked it for other fonts also, but still the problem persists. Any idea of what is happening?
Using Matlab R2021b.
Thanks in advance.

Related

Trouble with font and text extrusion

So, I'm doing some odd things with text extrusion and (perhaps not surprisingly) having some odd issues in OpenSCAD.
This is part of a much larger project, but I've been able to simplify the problem down to the following snippet of code.
use<RingbearerMedium-51mgZ.ttf>
Text = "b";
Font = "Ringbearer:style=Medium";
segment_count = 2;
segment_width = 2;
text_height = 5;
text_thickness = 1;
// Iterate over each "segment" of text
for (segment_number = [0: segment_count - 1])
{
// Calculate the x offset of the current "segment" of text
segment_x_offset = segment_number * segment_width;
// Extrude the "segment" of text to the requested thickness
linear_extrude(text_thickness)
// Grab the current "segment" of text
intersection()
{
text(Text, font=Font, size=text_height);
translate([segment_x_offset, 0])
square([segment_width, text_height]);
}
}
All this does is generate a line of text (just "b", in this case), cuts it into "segments", then extrudes each segment in-place. It's not much use in this example, but in the larger one, I'm translating and rotating each segment.
OpenSCAD's F5 preview renders fine. Here's a screenshot:
F5 Preview
However, the F6 preview always drops the left side of the letter "b" and displays the error "ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron". Here's a screenshot:
F6 Preview
This effects other letters as well, but only seems to be a problem with the "Ringbearer" font I'm trying to use. I don't know if I can upload the font, but it's available for download for free from here: Link to Ringbearer Font. Extruding and rendering the font without breaking it into segments works just fine. It's just when I try to segment this particular font that OpenSCAD fails.
Now, the obvious answer is to use a font that works, which is fine, as far as it goes, but I'm genuinely curious why this is happening. Is it an error with the font or is this a limitation of OpenSCAD? Is this a known issue that I'm just not aware of?
I appreciate any insight I can get.
Within OpenScad, go to help->font list.
I think the font you are using isn't supported.
Yet I had a similar problem with a supported font. I changed the font few times until I found one that works for me well, and look nice as well.
It also depends on the font size. Sometimes same font fails at a smaller size, and works well on a larger size.
Anyway, you can see this on the slicer, before going to the printing. Take a close look at the slicing layers of the text, it will save you some printing time and frustration.

Unity's text mesh pro input field caret is too wide and pushes text outside of textarea

I'm working on a mind map editor in which the user can draw boxes and write text in them. However, the TMPro input fields I'm using in those boxes have extra-wide caret when I type in them, and changing the fonts didn't solve the problem. Here are some images of the issue:
The caret is so wide that it can push the text inside out of the box:
I tried to lower the caret width in my script, but it's an int and has already been set to 1. Can you give me some possible reasons as to why this is happening?
I solved that problem by multiplying width+height of my inputfield by 100 and dividing its scale by 100.
Don't forget to increase the font size significantly.

Text component displaying lines in reverse order

Alright, I do not know how to fix this and only ran into this problem after trying to put in some longer text on a UI Text component. I have tried both pasting a value into its Text attribute through the Unity editor, and setting its value programmatically like this:
t.GetComponent<Text> ().text = "This is where meat, fish, and [...] (long text)"
Because Horizontal wrap is on, the text wraps when it reaches the edge of the available space.
However, the text displays backwards. Meaning, the start of the paragraph is at the bottom, and bottom at the top. Taking off wrap fixes this, but then the font size has to be really small (or it won't all be visible), and it can't form a normal paragraph because it has to... you know... wrap.
Is this a bug in Unity?
This is what happens - as you can see, it is displayed backwards:
The negative Line Spacing value is what is causing the issue here:
When the value of this field is less than 0, the lines will actually be arranged backwards, leading to the behaviour you're currently encountering. Just change the value to a positive number to have the text display correctly.

How to stop MATLAB clipping the title of a figure when I print

When I create a figure with MATLAB with a title, then use the File|Print option to print the figure, the title is clipped. Please try this code for an example
t = linspace(0,2*pi,1000);
s = sin(t);
figure
plot(t,s)
titleString = sprintf('Multi\nLine\nTitle');
title(titleString)
disp('Now press File|Print Preview on the figure and observe that the title is clipped.')
disp('This happens with all titles, the multi line title makes it more obvious.')
disp('I know I can fix it with Fill Page or Center, but I should not have too.')
You can also see the problem in print preview. As I say in the example code, I know I can get round the problem using Print Preview then Fill Page or Center, but I don't want people using my code to have to use a work around.
I have observed this problem with r2014a and r2015b. I assume other releasse are also affected.
Is there setting I can make before creating the figure that centres the plot or fills the page and makes the problem go away? Is there some other setting I should make to avoid the problem?
Here is a little more debug information. If I press File|Print Preview, MATLAB reports Left 0.64, Top -0.59, Width 20.32, Height 15.24. I guess the problem is related to the negative Top value. These are defaults from MATLAB; I have not made any attempt to change these values.
One extra thing. I am in the UK, so my default paper/printer setting will be for A4 paper, if that makes a difference.
Edit:
It looks like my problems are caused by two lines further up in my program:
set(0,'DefaultFigurePaperOrientation','landscape')
set(0,'DefaultFigurePaperType','A4')
I think that becuase plots expect to be on paper with a portrait orientation, I am seeing these problems.
Perhaps I should revise my question to: what to I need to change in MATLAB figures so they print correctly on landscape A4 paper (ideally in the center, scaled to fill the page, but with correct orientation). All this without using Print Preview.
But I am going to do this instead to code around my problem.
set(0,'DefaultFigurePaperOrientation','portrait')
set(0,'DefaultFigurePaperType','A4')
I can't seem to reproduce your problem on the computer I'm currently on (see the values I'm getting by default - Top is 8.11):
However, if your problem is what I think it is (I'm getting something that fits this description on another computer I'm working on), try adding _{ } at the end of your string. This is a TeX string meaning "subscripted space" which pushes the rest of the text slightly upward. You can also use ^{ } on the first line if the clipping is happening from the top. I found this workaround to work on axis titles and labels as well.
Exaggerated, the workaround looks like this:
titleString = sprintf('^{^{^{^{^{^{ }}}}}}Multi\nLine\nTitle');
Which shows the word "Multi" even for Top = -0.59.
If the above is not what you're looking for, you might want to look at the robust export_fig.
I can confirm that my clipping problems are caused by this line:
set(0,'DefaultFigurePaperOrientation','landscape')
I have revised my program to start with this instead.
set(0,'DefaultFigurePaperOrientation','portrait')
set(0,'DefaultFigurePaperType','A4')
And the problem has gone away.
Users can still print in landscape if they use the print preview feature.

Crystal Reports fields won't align

I have several items that I want to line up. The Width and Height of all fields match. Usually I just use the Align, but it's making it worse. My out of line field which is slighly lower, moves way up, way out of line (with align tops)
So I tried using the Size and Position to set it manually. Several objects have a Y of 0.056, but my last one has 0.061. I change the last one to 0.056 and save it. It doesn't appear to be different, and when I look at it again, it's still 0.061. (When I used align, it went up to 0.028!)
I do NOT have Snap to Grid set (my grid size is 0.083). (Nor does turning on Snap to Grid make them align.) The fields have exactly the same formatting. But unless I can magically make them align by hand, they refuse to align. Why?
You've already done a lot of the regular troubleshooting steps. One more ting that I sometimes do is to select all the fields I want to align, then use the arrow keys and move them up into the section above and then back down into their original section. That usually puts them all into the 0 position. If it dosn't work with all of them selected, try each one separately.