-
Notifications
You must be signed in to change notification settings - Fork 86
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
Typography's Trimmable Feature #187
Comments
Plan:
|
Before I add (see : 8bcde3c) and I think the new compact form of CFF instructions will
in this version, |
Typography's Trimmable Featurepic 2: from pic1, the objects in red rect are the targets of the Trimmable feature see Trimmable feature on latest master This can be used with ttf, otf (cff) , svg, bitmap font. After TrimDown(), the Typeface removes 'glyph-building instructions' of all kinds. BUT It preserves the 'TextLayout information' (eg. GSUB, GPOS) =>. you can 'restore' the information again with RestoreUp() Hope this will reduce memory usuage :) using Typography.OpenFont;
using Typography.OpenFont.Trimmable;
//....
//...
static void TestLoadAndReload(string filename)
{
//Trimmable feature tests:
//[A] read the font file as usual => get full information about the font
Typeface typeface = null;
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
//read in full mode
OpenFontReader openFontReader = new OpenFontReader();
typeface = openFontReader.Read(fs);
}
//before
bool hasColor1 = typeface.HasColorTable();
bool hasSvg1 = typeface.HasSvgTable();
bool hasCff1 = typeface.IsCffFont;
TrimMode glyphMode1 = typeface.GetTrimMode();
Glyph g1_1 = typeface.GetGlyph(1);
//---------------------------------------------------------
//[B] if you create paths from glyphs, or atlas from glyph
// and you don't want any glyph-building-detail (eg. to reduce memory usuage)
// but you still want to use the typeface for text-layout
// you can trim it down
RestoreTicket ticket = typeface.TrimDown();//***
//[C] you can GetGlyph() but this is ANOTHER NEW GLYPH
//without building instruction( eg. no cff,ttf,svg data,bitmap)
//
Glyph g1_2 = typeface.GetGlyph(1);
//** if you cache the the old version of 'full-info' glyph**
// the info is still cache on the old glyph and it can be used as 'full-info' glyph
// TrimDown() DOES NOT go to delete that glyph.
bool hasColor2 = typeface.HasColorTable();
bool hasSvg2 = typeface.HasSvgTable();
bool hasCff2 = typeface.IsCffFont;
TrimMode glyphMode2 = typeface.GetTrimMode();
//---------------------------------------------------------
//[D] can we load glyph detail again?
//yes=> this need 'ticket' from latest TrimDown()
//if you don't have it, you can't restore it.
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
typeface.RestoreUp(ticket, fs);
}
}
Trimmable test, FormTestTrimmableFeature |
see verybadcat/CSharpMath#107
I copy this image from that link.
pic 1
The text was updated successfully, but these errors were encountered: