Giter Club home page Giter Club logo

Comments (12)

mkoertgen avatar mkoertgen commented on June 12, 2024

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.

hanlectin avatar hanlectin commented on June 12, 2024

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.

mkoertgen avatar mkoertgen commented on June 12, 2024

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.

mkoertgen avatar mkoertgen commented on June 12, 2024

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.

hanlectin avatar hanlectin commented on June 12, 2024

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:

  1. yes, the extension method on font family would help! (if I could access the internally loaded fonts)
  2. I still feel like IconChar.ToBitmap(..) would be a cleaner and more consistent solution
  3. making the internally used fa-fonts available seems like a good idea

I'd be happy to help if I can ;)

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 12, 2024

Hi @hanlectin, i invested in some cleanup & documentation and also added some helper methods, cf.:

Please review with 5.15.2 once it is deployed.

from fontawesome.sharp.

hanlectin avatar hanlectin commented on June 12, 2024

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.

mkoertgen avatar mkoertgen commented on June 12, 2024

Hi @hanlectin ,

With respect to centering there has been some ongoing discussion resulting in some slight enhancements, see

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 12, 2024

With regard to the save-icon: This should be it right?

from fontawesome.sharp.

hanlectin avatar hanlectin commented on June 12, 2024

With regard to the save-icon: This should be it right?

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.

mkoertgen avatar mkoertgen commented on June 12, 2024

Hi @hanlectin ,
Sounds like you found a bug ;-)

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.