Copy text with all the font properties and paste it anywhere - android

I want to copy text with the same font style, same font color from TextView in Android application and paste it anywhere(like message app, WhatsApp etc.) with all the TextView font properties (style, color, size etc.).
I use a .ttf file for different font style.
How to copy that text with all the properties?

Short answer: you can't.
The copy-paste option is a system operation, and even if you'd find a way to change it to get in all the font properties, it still depends on the receiving applications to implement your custom paste and also to have the same .tff files for the custom fonts, etc..

Related

Copy the text with the font in the Android application

In some Android programs, you can copy text with a specific font and paste it in other programs, but how do they work?
like this:
𐎢𐎲𐎢
I want to show a text with its font to the user and allow him to copy it, but like the example above, I want its style to be copied as well, but only the normal text is copied.
like this: abcd
But what I want is this : 𐎷

Android: using custom font as fallback font for missing glyph

is there anyway to set custom font as a fallback font to the default font?
I need to display some cjk characters not supported by android's default font (which I think is noto font for non latin characters). I have a custom font consists of the glyphs missing, so I'm thinking to use noto as the main font, and set my custom font as fallback.
The only way I can come up with is to make noto font as a typeface and set my custom font as fallback. Then I can assign this typeface to where I need it.
However, this mean I need to programmatically assign almost all textview in the app, which doesn't seem right... (and elegant😅)
I would like to ask what is the best practice for this scenario? Like, perhaps there's a way to declare them as a font family in XML?
Thanks a lot ;)
Let me answer myself :)
After trying, I think the easiest way is to merge two font files together.
Just make sure the font's license allows you to do so.

how to get android default font list programmatically?

I am trying to create app which provide text formatting (like font style , font size , font color). So I want default fonts provided by android as a list to be shown in drop-down. Selecting font from drop-down will change the Text dynamically.
Can anyone help , how can I achieve this either via XML or programmatically ?
See the image how it must look like
font list is saved in Typeface class as a static field Map<Stirng, Typeface> sSystemFontMap. you just need to get this field. See my answer here.
There are only three system wide fonts in Android SDK.
normal
serif
monospace
More info : click here

Android - Combining multiple font styles, into one single font (Typeface)

I have several fonts with different styles, lets say: "MyFont_default.otf", "MyFont_italic.otf", "MyFont_bold.otf"
Normally, I would set the font of a TextView like this:
Typeface tf=Typeface.createFromAsset(context.getAssets(), "MyFont_italic.otf");
textView.setTypeface(tf);
And my question is: is it possible to combine all these fonts, into one single font, say "MyFont", and depending of the TextView style defined in the XML layout file (italic, bold), the TextView to be displayed in the appropriate font?
I don't have the proper reputation to comment but I can confirm, that approaches work.
Using FontForge (binary available for Windows):
Open your multiple .otf files with FontForge (Regular, Bold, Italic).
Make sure to select the window showing the "Regular" version of the font
Use File > Save ttc from that window
See that indeed the other sub fonts are listed in the save dialog (bold, italic)
Save and use this ttc file in Android
I tested it with an html text displayed in a TextView :
<b>Test</b> Test <i>Test</i>->
"Test Test Test" which didn't work previously in Android 2.3.7 and with this ttc font all three versions of the text show perfectly.
As I said, it's important to select the Regular font when exporting because that's the one Android uses as "default" (I did an export first from the Bold version and it was all Bold).
Use some sort of font editor to combine the fonts into a single file. Many fonts come with multiple styles in a single file, which is what you would need in this case.

How we can set the font for all applications according to selected font type in one application

Suppose I have an "apk" file. In this app, we can set the font. My question is how we can set that selected font for all applications.
You can't. What would be the point of me being able to define fonts in my application if you were going to override them?

Categories

Resources