How to build a font generator in iOS Swift and allowing pasting to clipboard - swift

I'm now building a listview to display fonts from the UIFonts framework. However, for using UIPasteboard.general.string, the fonts are not copied to the clipboard and only the plain text is transferred.
I've tried including the MobileCoreServices framework and use kUTTypeRTF to implement it. But there is no detailed documentation on it.
May I know how can I build a custom font list and allowing the text be selected and pasted with its font styling onto the other applications (like Notes or Facebook post), just like the font generator hosted online?
I'm now working on the two following UIFonts, but I'm not able to keep its formatting while pasting from the clipboard.
let fonts: [String] = ["BodoniSvtyTwoOSITCTT-Book", "ChalkboardSE-Regular"]

You cannot copy-paste text with a font on your iPhone.
FancyLetters also cannot do this. It just shows you characters that look like they are printed.
For example, the letter "A" has variations: "𝓐", "𝒜", "𝔸". But this is not font-altered text, StackOverflow does not allow it either. These are characters from Unicode table. They are the same characters as "A" or "B", except that without special modifiers the keyboard will not print them for you, e.g. SHIFTOPTIONK = .
Any font is superimposed over Unicode characters.
I recommend you to read an excellent article Emoji under the hood. It's about how emoji are drawn on devices, but it also explains a lot about the construction of characters and how they are rendered on different devices.

Or font generator also cannot do this. It just shows you characters that look like they are printed

Related

Unity - Displaying Burmese (Zwagyi) text

We're currently developing a game in Unity (2019.4.28f1). This game is played internationally. We'd like to add support for languages other than common Latin written languages. Currently, we're trying to implement support for Burmese, but aren't making much progress.
Finding fonts to display Burmese isn't a big issue. As you can see in the image below, we manage to display all characters that are supposed to be displayed.
However, the big problem here is that the displayed order of symbols isn't the same as what it's supposed to be (see image below for the desired result).
We've tried several fonts that use either Unicode or Zwagyi encoding, but none of them seem to display characters in the correct order. Currently, we're using a padauk font from here, which is supposedly Unicode encoded. Then, within Unity, we applied to following settings to that font:
So, if one of you knows more about this and can share some information with me, that would be much appreciated!
Thanks.
We've already found a solution for this! Before setting the text of the text component convert the Unicode codes to Zwagyi and it'll display the text in the correct order!
All the credits go to this guy who put in the effort to make a tool for these use cases!
Of course, you still need a (Unicode) font that supports these (Burmese) symbols.
Example:
Text textComponent = GetComponent<Text>();
textComponent.text = mmfont.Net.Converter.Uni2ZG(yourUnicodeText);

Hyphenated word wrapping

Do we have character hyphenated wrapping supported in iOS? i.e. when text exceeds the frame width there should be a hyphen added by the iOS in the last word of the line.
Here is a GitHub project about hyphenation made by Tupil. It is a category implementation for NSString called NSString+Hyphenate. You may have a try with this. Tupil's blog "Adding Hyphenation to NSString" describes how to use it.
You can also have a look at:
Frank Zheng's blog - Hyphenation with Core Text on the iPad

How to display Chinese in plot's label

How to display Chinese in plot's label
我是英文版64位win7系统,在matlab中的命令行和文件中可以输入中文,但是保存再打开之后中文就变成“???”了。然后在plot里面xlabel中也无法使用中文,画出来的图片上就是“???”。
请问怎么才能在MatLab中使用中文?
Have you Googled yourself? Try https://www.google.com/search?q=MATLAB%20%E4%B9%B1%E7%A0%81. Basically you need to use an appropriate font, depending on which OS and MATLAB you use.
You can either directly use Chinese font (such as SimSun 宋体) or properly configure font linking in registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\FontLink\SystemLink). I wrote some articles about this in ThemeX forum. Pay a visit.

Prevent Emoji Characters from Showing

I use a few special uniode chars in my app, but since iOS 5 these have been replaced with emoji characters. How can I force the unicode characters to be displayed and not the emoji characters? Thanks
This is an old question but it plagued me a lot recently until I found the answer.
Just add '\U0000FE0E' after the character that we want to prevent from becoming an emoji.
For example:
#"▶" // should be written as:
#"▶\U0000FE0E"
Using the escaped unicode works as well:
#"\u25B6" // should be written as:
#"\u25B6\U0000FE0E"
We need to use Unicode variants to prevent certain characters from becoming emoji.
Here is the article that solved my problem.
Just to add to BFerer's helpful answer, I found this works similarly in Swift:
"▶\u{0000FE0E}"
There's a few mentions of this issue on Apple's private devforums (which you have access to if you're a registered member of the iOS developer program).
It sounds like the potential solution would be to explicitly set the font for whatever you're trying to display.
Use "Hiragino Mincho ProN" for the font. It worked for me, but unfortunately I had to change the insets to make things look correct. I had to add an inset to the top to place things as they were before the iOS update.
All the credit goes to Kevin Ballard who answered my post in the following discussion -
Unicode characters being drawn differently in iOS5

String with different font

I am having a string message i need first word of that as bold font and rest normal.
Making different label can be create problems,(need to find the size of first the make other and then make other,text is in 4 line).
How can i use NSAttributedString here. I could found How do you use NSAttributedString?
but using this shows undeclared NSForegrou... (present in app kit framework).But could not found app kit framework on sdk 4.2
Need help for making such kind of string(bold + normal text).
Go through the below blog tutorial with code, they have different font with NSAttributedString.
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML
https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor
May I point you to the CoreText Framework and Befriending Core Text on cocoanetics.com. This will show you how to format text.