feiyanghu


I want to open the *.odttf and read it infromation but I can't find any information to open it

Re: How to open the *.odttf format of font source

Feng Yuan - MSFT


.odttf is obfuscated TTF font. It's documented in XPS specification.

Feng Yuan






Re: How to open the *.odttf format of font source

feiyanghu123

Feng Yuan,

It isn' t detail specified how to open the *odttf format in the Xps SPEC.I want in xps driver directly render the glyph to the raw data. I think use the IPrintReadStream::ReadBytes can read the *.odttf file,but I don't know how use the function.can you help me






Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

Can you double check if the stream is alreadly unobfuscated

This is what a TrueType font look like in a hex dump:

1952:0100 00 01 00 00 00 0F 00 80-00 03 00 70 44 53 49 47 ...........pDSIG
1952:0110 34 EA 07 35 00 00 AD 68-00 00 15 00 4F 53 2F 32 4..5...h....OS/2
1952:0120 99 D5 86 17 00 00 01 78-00 00 00 56 63 6D 61 70 .......x...Vcmap
1952:0130 1D 0E B6 44 00 00 14 E4-00 00 03 2E 63 76 74 20 ...D........cvt
1952:0140 7A 0D 75 4A 00 00 1B C0-00 00 01 5C 66 70 67 6D z.uJ.......\fpgm
1952:0150 44 01 97 8A 00 00 1A 48-00 00 01 76 67 6C 79 66 D......H...vglyf
1952:0160 13 C0 8B 87 00 00 20 EC-00 00 87 3A 68 65 61 64 ...... ....:head
1952:0170 CB 8A CC 67 00 00 00 FC-00 00 00 36 68 68 65 61 ...g.......6hhea

If the font is obfuscated, here is the C# code to unobfuscate it:

public static void ObfuscateData(byte[] fontData, Guid guid)
{
byte[] guidByteArray = new byte[16];
// Convert the GUID into string in 32 digits format (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
string guidString = guid.ToString("N");

for (int i = 0; i < guidByteArray.Length; i++)
{
guidByteArrayIdea = Convert.ToByte(guidString.Substring(i * 2, 2), 16);
}

for (int j = 0; j < 2; j++)
{
for (int i = 0; i < 16; i++)
{
fontData[i + j * 16] ^= guidByteArray[15 - i];
}
}
}






Re: How to open the *.odttf format of font source

feiyanghu123

Feng Yuan,

I had read the XPS SPEC but I can't read about "how to direct render xps glyph element to low data" document in XPS SPECX and MSDN .If you have some document can you share . Can you share some sample code about the xps glyph.





Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

I'm not sure what environment you're working on.

If you're on Windows platforms, you can use GDI, or GDI+ to render XPS glyphs. On other platform, you need a TrueType rendering API.

If you need to implement your own TrueType rasterization engine, it will be lots of work, because TrueType font is a very complicated data structure. If you want to read more about TrueType fonts, read TrueType/OpenType specifications, MSDN, and my book. My GDI book has one long chapter on fonts and one long chapter on text. You can find sample code for the book here: http://blogs.msdn.com/fyuan/archive/2007/03/20/source-code-for-windows-graphics-programming-win32-gdi-and-directdraw.aspx

Thanks

Feng Yuan






Re: How to open the *.odttf format of font source

feiyanghu123

Feng Yuan,

Thanks for you respond immediately.My platform is windows.
Your means we can used the GDI or GDI+ to rend the glyph to low data.(Do you have the sample code for this way)
My means is the xps glyph element part low data was saved in the *.odttf.I want to read the low data form *.odttf and accordint the other glyph property to render them to new low data.

feiyanghu123





Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

What do you mean by low data here

Yes, it's possible to render XPS Glyph using GDI or GDI+. Here are the steps:

1) Get TrueType/OpenType from XPS package, install it with GDI or GDI+. To be perfectly right, you need to rename the font internally with GDI.

2) Parse the Glyph Indices attribute. If glyph index or advance width is missing, you need to query font to get the right information.

3) Figure out the right font size.

4) If the brush is solid color brush with opacity=1, you can render it directly using GDI or GDI+. In other case, it may be more complicated. But you can always get the glyph outline and turn the problem into a path filling problem, although direct text rendering normally provides better quality because of hinting.






Re: How to open the *.odttf format of font source

feiyanghu123

For example: "a" character render used "01110011111111100011" description. "01110011111111100011" is low data .
I want to render the xps glyph element to the low data . I think it is very complicacy .Maybe you had experience for this.
thank for you provide the four step,but I need you more help about step 1.I'll according your suggest to try.if you have more document and sample code for step1 .Can you share
Thanks





Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

What have you tried






Re: How to open the *.odttf format of font source

feiyanghu123

I want to render to bitmap printer,But I don't want used fllow way.

public void SaveXpsPageToBitmap(string xpsFileName)
{
XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);
FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();

int pageCount = docSeq.References[0].GetDocument(false).Pages.Count;

// You can get the total page count from docSeq.PageCount
for(int pageNum = 0; pageNum < pageCount; pageNum ++)
{
DocumentPage docPage = docSeq.DocumentPaginator.GetPage(pageNum);
BitmapImage bitmap = new BitmapImage();
RenderTargetBitmap renderTarget =
new RenderTargetBitmap((int)docPage.Size.Width,
(int)docPage.Size.Height,
96, // WPF (Avalon) units are 96dpi based
96,
System.Windows.Media.PixelFormats.Pbgra32);
renderTarget.Render(docPage.Visual);

BitmapEncoder encoder = new BmpBitmapEncoder(); // Choose type here ie: JpegBitmapEncoder, TiffBitmapEncoder etc.
encoder.Frames.Add(BitmapFrame.Create(renderTarget));

FileStream pageOutStream = new FileStream(xpsFileName + ".Page" + pageNum + ".bmp", FileMode.Create, FileAccess.Write);
encoder.Save(pageOutStream);
pageOutStream.Close();
}
}





Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

I understand that you're trying to render XPS within XPS printing filter pipeline to bitmap bands and then convert to printer language and sent to printers. But I do not know what have you tried to do in this area, especially in text.

Questions, if you're using GDI:

1) Can you get the font data and install the font successfully with GDI

2) Can you use GDI to map UNICODE code points to glyph indecies when they're missing

3) Can you use GDI to calculate advance width when it's missing from markup

4) Can you setup the proper GDI HDC and LOGFONT, to achieve the right FontEmSize for the right printing resolution

5) Can you render text into a bitmap using GDI

6) Can you apply the right brush/opacity to the text when it's not supported by GDI

Regards

Feng Yuan






Re: How to open the *.odttf format of font source

feiyanghu123

Feng Yuan

XPS is PDL,so user can directly printer it.now some hareware(HP) support the file format.I read inforation of Microsoft open the xps source code but I Can't found the source code. so I want render XPS within XPS printing filter pipeline to bitmap bands,only I research the text now .You's question is my want to ask you question. up-to-date I'not find other way to render xps to bitmap bands.





Re: How to open the *.odttf format of font source

Feng Yuan - MSFT

If you're not sure how to answer questions 1) to 6), then you need to read about GDI, and GDI+.

Check MSDN documentation on GDI, GDI+, Charles Petzold's book, TrueType/OpenType specification, and then my GDI book. My GDI book has been translated into Chinese.

Thanks

Feng Yuan






Re: How to open the *.odttf format of font source

feiyanghu123

Thanks for you remind. I had read you sample code for the font (Chapt_14) but It seems not help to me. if you have the Chinese GDI book document Can you share.if you have the sample code for the render the xps glyphs Can you share.




databaseforum