locked
Loading a font from Stream AND vectorizing the font RRS feed

  • Question

  • I posted the following to the WPF forum (my first ever post there), and sadly no one responded.  Anyone in this forum wants to try?
    Hi, first time posting here.  I have a Silverlight application that deals with fonts extensively.  One of the missing feature of Silverlight is the ability to convert TextBlocks to vectors.  I have seen it done in WPF but there just isn't such API in Silverlight.  FYI the application is Tagxedo (http://www.tagxedo.com) and the fonts are dynamically loaded (from the server, or user provided).
    As a "workaround" I am looking into doing the convert in WPF.  Surprisingly, it seems that it is impossible to do so in WPF, but for a different reason.  Namely, there doesn't seem to be a way to load a font (.ttf) from a stream.  The font that is used by the application is not static, but could be loaded from user's computer, or downloaded from the server, or embedded.  Silverlight has the concept of "FontSource" which I think was invented to allow dynamic loading of fonts.  I am surprised to not find such functionality in WPF.  I'm looking at the latest version of everything.
    Am I mistaken about this?  Basically, all I want to achieve is to be able to load a dynamic font (.ttf from a stream), and vectorize some textblocks.  So far my understanding is that vectorization is not supported by Silverlight, and dynamic font from stream is not supported by WPF.
    Any idea?
    I fear that the lack of response is a sign that it is not possible...  Namely, in Silverlight I can load a font from stream but cannot vectorize.  In WPF I can vectorize but cannot load a font from stream.  How ironic.
    But can someone confirm one way or the other?
    Let's say I really need to do this, and it is not possible in SL/WPF.  What else would you suggest?  So far I can think of: (1) vectorize myself (e.g. Potrace C#), (2) Use Java (I think it may support both), (3) Just stick with high-resolution PNG, (4) ttf2svg and somehow figure out how to use SVG fonts, (5) Flash???  None of these are particularly attractive solutions to me though.  It's just silly that this cannot be done in SL/WPF.

    I posted the following to the WPF forum (my first ever post there), and sadly no one responded.  Anyone in this forum wants to try?

    -----------------------------------

    Hi, first time posting here.  I have a Silverlight application that deals with fonts extensively.  One of the missing feature of Silverlight is the ability to convert TextBlocks to vectors.  I have seen it done in WPF but there just isn't such API in Silverlight.  FYI the application is Tagxedo (http://www.tagxedo.com) and the fonts are dynamically loaded (from the server, or user provided).

    As a "workaround" I am looking into doing the convert in WPF.  Surprisingly, it seems that it is impossible to do so in WPF, but for a different reason.  Namely, there doesn't seem to be a way to load a font (.ttf) from a stream.  The font that is used by the application is not static, but could be loaded from user's computer, or downloaded from the server, or embedded.  Silverlight has the concept of "FontSource" which I think was invented to allow dynamic loading of fonts.  I am surprised to not find such functionality in WPF.  I'm looking at the latest version of everything.

    Am I mistaken about this?  Basically, all I want to achieve is to be able to load a dynamic font (.ttf from a stream), and vectorize some textblocks.  So far my understanding is that vectorization is not supported by Silverlight, and dynamic font from stream is not supported by WPF.

    Any idea?

    -----------------------------------

    I fear that the lack of response is a sign that it is not possible...  Namely, in Silverlight I can load a font from stream but cannot vectorize.  In WPF I can vectorize but cannot load a font from stream.  How ironic.

    But can someone confirm one way or the other?

    Let's say I really need to do this, and it is not possible in SL/WPF.  What else would you suggest?  So far I can think of: (1) vectorize myself (e.g. Potrace C#), (2) Use Java (I think it may support both), (3) Just stick with high-resolution PNG, (4) ttf2svg and somehow figure out how to use SVG fonts, (5) Flash???  None of these are particularly attractive solutions to me though.  It's just silly that this cannot be done in SL/WPF.

    Wednesday, September 15, 2010 7:49 PM

All replies

  • Hi. I have no full answer, however some time ago I read about how this...

     Surprisingly, it seems that it is impossible to do so in WPF, but for a different reason.  Namely, there doesn't seem to be a way to load a font (.ttf) from a stream.

    ... is possible using a PrivateFontCollection. Maybe this gets you started.

    http://blogs.msdn.com/b/michkap/archive/2005/11/20/494829.aspx

    He uses a resource stream, but I don't think it matters where the stream eventually comes from.

    Wednesday, September 15, 2010 11:58 PM
  • Thanks for the tip, and I'll look into it.

    Thursday, September 16, 2010 4:58 AM
  • I looked at it and could not get it to work, at least not in the context of WPF...  Someone else marked it as an answer but I'll have to unmark it.

    Also just check the WPF forum and the answer is NO.  This would be one feature that Silverlight supports but WPF doesn't.

    http://social.msdn.microsoft.com/Forums/en/wpf/thread/32a37ad3-2f10-4f55-9750-560ada9e43d7

    Friday, October 1, 2010 6:53 PM