Get list of supported fonts in ITextSharp

亡梦爱人 提交于 2019-12-08 16:16:43

问题


I'm working with ITextSharp for a project and am looking for a reasonable way to get a string list of different fonts it has available for use.

I thought maybe I could just use reflection and loop over a class of available fonts, but there does not seem to be an easy way to do this. What I really want to do is provide a drop down of available/supported fonts for my users to select from

Does anyone have any thoughts on how I might accomplish this?


回答1:


This webpage has a great reference for how to work with the 14 embedded fonts in iTextSharp, as well as how to embed and use any fonts of your choosing.

To get the list of fonts included in iTextSharp:

  Dim myCol As ICollection
  //Returns the list of all font families included in iTextSharp.
  myCol = iTextSharp.text.FontFactory.RegisteredFamilies
  //Returns the list of all fonts included in iTextSharp.
  myCol = iTextSharp.text.FontFactory.RegisteredFonts

An example of a font family is Helvetica. An example of a font is Helvetica-Bold or Helvetica-Italic.




回答2:


First call FontFactory.RegisterDirectories(); to get all fonts on the system registered.

Then call FontFactory.RegisteredFonts; to get all the fonts.



来源:https://stackoverflow.com/questions/2027808/get-list-of-supported-fonts-in-itextsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!