Jetpack Compose how to change Text break strategy? - android-jetpack-compose

How to change the way compose Text() breaks text? I want it to be broken in spaces, but not "//seed" into "//" and "seed".

Related

Word spacing in Latex math mode

I have a problem with spaces between the words in Latex math mode. I have to write text in math mode because of the work I'm doing, and I already did the job. But the words are sooo tightly closed to each other. An example is as below :
It's the code in latex:
$>>> if ret is True:$\\
The output is something like:
ifretisTrue
You see? Sooo close to each other. I need a kind of command to set the spaces between words for all the math equations throughout the entire document.
In math mode LaTeX adds spacing based on mathematical rules. If you want to typeset text in math mode, use \text{}. In your case $\text{>>> if ret is True:}$\\ outputs what you want if you really want to put that in math mode.
By the way, it's better to ask LaTeX related questions at https://tex.stackexchange.com/

Customizing Body Text and Images using Markdown, Pandoc, Beamer to create PDF Slideshows

I have a series of markdown files that I am turning into slides using Pandoc and the Beamer template. I am creating my own custom Beamer template in order to format those slides.
pandoc --slide-level 2 -fmarkdown-implicit_figures -t beamer --template mytemplate.beamer -o test.pdf *.md
I am struggling with making certain elements look the way I would like them to.
My simplified markdown looks like this:
## Header
Normal Body Text
![Image](images/Image1.png "Image")
Specifically, my images are coming out left justified. I can't figure out how to get them to center. If I remove the -fmarkdown-implicit_figures option, then the images are properly centered, but includes captions that I don't want. Adding that flag eliminates the captions but also eliminates the centering.
At the same time, I want the normal body text to be centered as well. So in the above example I would like the text Normal Body Text to be centered. Again, I can't figure out how to do that. I have managed to center other elements (such as the header), but I can't find an appropriate name for the element that represents normal body text.
Can anyone offer a solution to either of these issues?
I found a way to center the images. It may not be the best option, but this seems to work:
\usepackage{letltxmacro}
% Save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics
% Update the include graphics command to include centering
\renewcommand{\includegraphics}[2][]{%
\centering
\latexincludegraphics[#1]{#2}}
To ensure the normal text was centered, I used the following, again I am unsure if this is the best way:
% Center Text By Default
\usepackage{ragged2e}
\centering

Fragile Space – opposite of non-breaking space

Under iOS I'm wondering if there is a kind of "extra fragile" space that I could put in to a string.
If I display it in a UILabel (or other control), and the text needs to be split over >1 line, then the layout would try to split on a a fragile space if it possibly can.
Eg, if <> is a fragile space symbol, then the string "All on one line if possible<>but this on another line if needed." would display as:
All on one line if possible
but this on another line if needed.
… assuming that there wasn't room for the whole string on one line.
Or perhaps the concept is more a "Newline here if you need to".
Maybe something with ranges in NSAttributedString that can describe where breaking should be preferred? Or some other way to specify this to a label?

In a UILabel, is it possible to force a line NOT to break in a certain place

I have a UILabel that is supposed to be two lines long. The text is localized into French and English.
I'm setting the attributedText property of the label. The text is constructed from three appended strings, say textFragment1, textFragment2 and textFragment3. The middle string is actually an image created with an NSTextAttachment.
I want to make sure that textFragment2 and textFragment3 are on the same line. The first string may or may not wrap depending on how long it is. The problem is that my French text is currently fairly short, so the line is wrapping after textFragment2.
I have fixed this temporarily by adding a line break symbol in the localized French text for textFragment1. I don't really love this solution though. I was wondering if there is a way to treat textFragment2 and textFragment3 so that they will always be together on the same line.
You could use a non-breaking space (\u00a0) to join textFragment2 and textFragment3. This character looks just like a normal space—i.e. it results in the same amount of whitespace—but line breaking will not take place on either side of it.
You could also use a zero-width space (\u2060). Using this character will not result in any whitespace, but it will still prevent line breaking on either side. This is what you want if you don’t want any space between textFragment2 and textFragment3 but you still want to prevent line breaking there. (It’s also useful if you have a word with a hyphen in the middle of it but you want to prevent the line from being broken after the hyphen.)
You can read more about these kinds of characters on Wikipedia.

Substitute missing characters with "?" character

Is there an easy way to make default XNA method SpriteBatch.DrawString substitute characters that are not in spritefont with ? sign? I could go with an extension method, but I'm not sure how to implement it, as there is no way to know if a character is not in the spritefont beforehand.
This functionality is built-in. Open the .spritefont file for your font and scroll down to here:
<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->
Uncomment that line and replace the character with the one you want, like so:
<DefaultCharacter>?</DefaultCharacter>
You can also achieve the same effect by modifying the SpriteFont.DefaultCharacter property at runtime.
If you need it, you can get a list of the available characters in a font through the SpriteFont.Characters property.

Resources