Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions... #185

Closed
BadHabbits1337 opened this issue Jan 31, 2020 · 4 comments
Closed

Some questions... #185

BadHabbits1337 opened this issue Jan 31, 2020 · 4 comments

Comments

@BadHabbits1337
Copy link

I am currenly looking for a good library that capable of rasterizing fonts on subpixel level. Your one looks very promising, because it pure C# and has no native external dependencies.

But, when i started looking twards learning of how it works, i hit the wall, because of this things:

  • Demo projects throws lots of exceptions when i hit some buttons. Some of exceptions says that, there is no file with font (they hardcoded to some local path (probably yours), and some couldn't find some sample fonts, that just not included into repository). And lot's nullrefs, in lots of different places
  • Main repo readme if perfect, wiki also nice and advertising. But it laks of simple "Hellow World" example, where i could find out how just render some words on to simple bitmap, and probably save it onto disk.
  • There is no NuGet package, which i could drop in to my project, and start using your library.
  • From the previous follows pretty complex project structure in general. There lots of stuff that referenced, some shared project stuff allaround (mostly in demo projects). And i just couldn't see the picture of how actually the whole thing organized.

It would be great if you could answer these questions, i hope it will clarify a lot of things that going on there:

  1. Which module is main/root in Typography?
  2. Which i need it i only wants to work with *.ttf fonts?
  3. What types/classes/structs i should be aware of if i want to use your library as user.
    3.1For example, if i want rasterize font into the atlas, i probably need some font container type, some bitmap type, and packer (i have one already)...
    3.2. Is there way of working with font, like it just a collection of glyphs?
    3.3. Which type i should use for rasterization?
    3.4. Is there some bitmap type, or rendering based on some System.Drawing stuff?
  4. What the purpouse of porjects in 'Typography_Build' directory?
  5. Could you write some simple snippet where font get loaded, and we rasterize some of it glyph into pixel array in memory (for simplicity)? And define which libraries i need reference to run it console app on netcore 3.0 runtime?
  6. Is there any plans to write some docs?
  7. NuGet package?

Btw, it looks great, but it just unclear where from to start, and how to integrate it some external projects...

@Happypig375
Copy link
Contributor

Happypig375 commented Jan 31, 2020

  1. Typography.OpenFont is the root. Other projects reference it. For more information on various projects, see What are each project used for? #99.
  2. The projects to use do not depend on the font file format. To read a font, use new Typography.OpenFont.OpenFontReader().Read(System.IO.File.OpenRead("Some path")). The stream is disposed inside the Read method.
  3.  
    3.1. The font container type is Typography.OpenFont.Typeface. Instances are obtained using the code above. Bitmap types are not included.
    3.2. The Glyphs property of Typography.OpenFont.Typeface has the type Typography.OpenFont.Glyph[].
    3.3. Typography.OpenFont.TrueTypeInterpreter for outlining a TTF glyph. (For other people, OTF fonts can also be CFF fonts, in addition to TTF fonts. Use this class instead.)
    3.4. Supply your own.
  4. The Build folder is for multi-targeting. Currently Typography targets .NET Framework 2.0 and .NET Standard 2.0. The shared code lives outside the build projects.
  5. See the GdiPlus sample.
    GdiPlus sample
  6. See Documentation Project #15. Currently the Demos are the de facto documentation.
  7. See NuGet package? #96. Typography is not yet stable enough so APIs may change. Use a git submodule.

@BadHabbits1337
Copy link
Author

Thanks, your answers helps, now i see some points pretty clear.

But now i have some more questions:

  1. The main purpouse of Typography lib, is about loading and interpreting font files?
  2. If so, actual rendering of glyphs should be done using something else, like gdi+, or PixelFarm's Agg implementation?
    3.1 If i decide to use Agg lib, i also need PixelFarm.Typography library?
    3.2. But why there is no target in Build directory for PixelFarm.Typography? Is it intentional, or just ocasionaly?
    3.3 Or it is some kind of reference implementation of bridging between this two (Typography, and PixelFarm), and i could (or should?) write my own implementation of this bridge?

Also some thougth in general.
As i could see, there pretty lot of steps and posibilities in porcess of *.ttf+SomeString -> Displayed pixels on screen. Is my understanding correct about this tasks and their relation to LayoutFarm's libraries:
A. Parsing font file formats [Typography.OpenFontReader]
B. Loading glyph outlines [Typography.OpenFont.TrueTypeInterpreter]; and stuff from GlyphPathBuilder...
C. Layouting words and text [Typography.TextFlow]
D. Line wrapping/breaking [Typography.TextBreak]
E. Glyph measuring (advance, bound, ligatures, kernings) [Typography.GlyphLayout]
Am i right, or some things are misunderstood?

@Happypig375
Copy link
Contributor

  1. Yes
  2. Yes. Note that PixelFarm is not limited to Agg, you can use other rendering methods mentioned in its README.
  3.  
    3.1. Yes. However, you don't need to care about this as PixelFarm has projects that reference Typography directly:
    https://github.com/PaintLab/PixelFarm/blob/d90cc26586feacb181f938f0a40c88203f7d4afe/src/PixelFarm/Typography.One/Typography.One.csproj#L41-L51
    https://github.com/PaintLab/PixelFarm/blob/41309818503494db5faef4dac1fa0eef27ff5a4e/src/PixelFarm/PixelFarm.Typography/PixelFarm.Typography.csproj#L41-L131
    3.2. PixelFarm, in contrast to Typography, does not support .NET Standard 2.0 yet. Therefore, PixelFarm.Typography only has the .NET Framework 2.0 target.
    3.3. It's the official bridge in addition to serving as a reference. If you want to bridge Typography with another rendering library, feel free to do so.
  4. You should be right. One minor note: the reference graph is:
Typography.OpenFont
        ↑
Typography.GlyphLayout
        ↑
Typography.TextFlow

(Typography.TextBreak is independent.)
Therefore, C should be after E.

@BadHabbits1337
Copy link
Author

Thank you very much, now I see the full picture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants