Comments (12)
Hi @hanlectin ,
Some time ago we had a similar request and added the option to set the fontstyle, cf.:
Let me know if this helps.
from fontawesome.sharp.
thanks - I've already seen this, but I'm afraid this doesn't help in my case :(
I really need to convert the IconChar directly to a bitmap. I cannot use the WinForm Controls IconButton, MenuItem, etc.
so in my opinion the .ToBitmap() method really misses an option to specify the fontstyle...
from fontawesome.sharp.
Ah, i see. Would using the extension method on font family instead of iconchar be an option?
example:
var bitmap = myfont.ToBitmap(icon, ...)
from fontawesome.sharp.
To make quick access to often used fonts (fa-brand, fa-solid, fa-regular, .. ) more developer friendly we can probably add some lookup-shortcuts for the internally loaded fonts,
I probably plan on spending some time on this over the weekend. I would also be happy to accept a PR on this. So, if you can & want help, let me know.
from fontawesome.sharp.
I was already wondering how to instantiate or access a fa-FontFamily...
looking at FontAwesome.Sharp-master it seems I can't, right? (everything I'd need is private or internal)
...this was before I saw your subsequent post!
so:
- yes, the extension method on font family would help! (if I could access the internally loaded fonts)
- I still feel like IconChar.ToBitmap(..) would be a cleaner and more consistent solution
- making the internally used fa-fonts available seems like a good idea
I'd be happy to help if I can ;)
from fontawesome.sharp.
Hi @hanlectin, i invested in some cleanup & documentation and also added some helper methods, cf.:
- https://github.com/awesome-inc/FontAwesome.Sharp#all-icons-seem-to-be-rendered-with-regular-style-how-to-render-solid-or-brand-icons
- https://github.com/awesome-inc/FontAwesome.Sharp/blob/master/FontAwesome.Sharp.Tests/WindowsForms/FormsIconHelper_Should.cs#L35
Please review with 5.15.2 once it is deployed.
from fontawesome.sharp.
thanks for your efforts and sorry for the late answer...
I tested v5.12.3 - and it's almost working. or maybe I just get things wrong?
IconChar fa_icon = IconChar.Save;
Bitmap bmp;
bmp = fa_icon.ToBitmap(IconFont.Auto, 256, Color.Black); //OK! disk-outlined
bmp = fa_icon.ToBitmap(IconFont.Brands, 256, Color.Black); //OK! empty (=no brand icon)
bmp = fa_icon.ToBitmap(IconFont.Regular, 256, Color.Black); //ERR? empty (should be disk-outlined, right?)
bmp = fa_icon.ToBitmap(IconFont.Solid, 256, Color.Black); //OK! disk-solid
IMHO using "IconFont.Regular" should return the same bitmap as "IconFont.Auto" - i.e. an outlined disk...
another (minor) issue:
the returned bitmaps are not centered (shifted to the top-left).
this is most likely correct, as the IconChars represent a font/letter and due to the font's baseline- and advance-offset this seems logical to me.
I currently simply shift the image by a few percent to the right and to the bottom. but I use empirical percentages here.
--> is there a way to calculate the correct offsets?
from fontawesome.sharp.
Hi @hanlectin ,
With respect to centering there has been some ongoing discussion resulting in some slight enhancements, see
from fontawesome.sharp.
With regard to the save-icon: This should be it right?
- https://fontawesome.com/icons/save?style=regular
- unicode should be f0c7 (should be ok: https://github.com/awesome-inc/FontAwesome.Sharp/blob/master/FontAwesome.Sharp/IconChar.cs#L1071)
from fontawesome.sharp.
With regard to the save-icon: This should be it right?
- https://fontawesome.com/icons/save?style=regular
- unicode should be f0c7 (should be ok: https://github.com/awesome-inc/FontAwesome.Sharp/blob/master/FontAwesome.Sharp/IconChar.cs#L1071)
yes - that would be correct. however, this "disk"-icon is only returned with
bmp = fa_icon.ToBitmap(IconFont.Auto, 256, Color.Black); //OK! disk-outlined
the following returns an empty bitmap:
bmp = fa_icon.ToBitmap(IconFont.Regular, 256, Color.Black); //ERR? empty (should be disk-outlined, right?)
...I could perfectly live with that. I could only use .Auto and .Bold (no reason to use .Regular, as .Auto returns the .Regular as a default)
howerver, I think .Regular should also return the same icon as .Auto, right?
(and thanks for pointing me to the discussion on centering the icon!)
from fontawesome.sharp.
Hi @hanlectin ,
Sounds like you found a bug ;-)
from fontawesome.sharp.
I had some time to look into it. The auto-font heuristic may cache the "Brands Regular"-font instead of the "Regular"-font.
{Name = "Font Awesome 5 Brands Regular"}
{Name = "Font Awesome 5 Free Regular"}
{Name = "Font Awesome 5 Free Solid"}
So in case you look up a brand-icon before a regular-icon the the library will lookup the wrong font resulting in an empty image.
from fontawesome.sharp.
Related Issues (20)
- FontAwesome.Sharp package (v5.15.4.0) is unsigned HOT 1
- Add example for nerdfonts
- Add Support for .NET 7, C# 11
- Evaluate https://thenounproject.com/icons/
- Update NuGet Package to 6.2.1 HOT 3
- CVE-2022-34716 (Medium) detected in system.security.cryptography.xml.4.7.0.nupkg
- WS-2022-0161 (High) detected in newtonsoft.json.12.0.3.nupkg, nuke.common.6.1.1.nupkg
- Generate FontAwesome.Sharp.dll for FA Pro? HOT 13
- Image and text are not horizontal aligned. HOT 1
- Update NuGet package FontAwesome.Sharp.Pro HOT 2
- Update NuGet package FontAwesome.Sharp.Pro HOT 6
- CVE-2022-26907 (Medium) detected in microsoft.rest.clientruntime.2.3.20.nupkg, nuke.common.6.1.1.nupkg
- CVE-2023-29337 (High) detected in nuget.common.5.11.0.nupkg, nuke.common.6.1.1.nupkg
- CVE-2024-21907 (High) detected in newtonsoft.json.12.0.3.nupkg, nuke.common.6.1.1.nupkg
- System.ArgumentException: '' is not a valid value for property 'FontFamily' HOT 7
- Icon button in datagridview HOT 7
- Support / Add example for Open Iconic HOT 1
- Duplicate IconChar entries in property window. HOT 8
- Button content not properly aligned. HOT 6
- How to use with Awesome Pro? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fontawesome.sharp.