![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
|
Embedded fonts in LRF WORKING
Well, after several evenings in IDA/OllyDbg I finally got it working. Due to several bugs in the Reader's LRF parser, embedded fonts only work for some specific combinations of parameters.
See the attached file for an example of such LRF. It has embedded Courier New font and a text string in Russian. I have not yet found a way to generate such files with available converters. This one was generated by makelrf and then edited manually in a hex editor. So here are the technical details for the converter authors: 1. Font stream should added as a Font object (type 0x19). The stream must be either compressed or scrambled (or both), otherwise the parser will fail to load it. 2. Reference to the font object must be added to the root BookAtr object with the tag F5D8. It should be possible to add several fonts in this way, though I haven't tested it. 3. TextAtr object which sets the style for rendering the text, must specify the full TrueType font name (with tag F516), not the name from the Font object. |
![]() |
![]() |
![]() |
#2 |
Fully Converged
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18,171
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
|
Congrats igorsk!
![]() Btw, I remember OllyDebug very well ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 1695
Join Date: Oct 2006
|
Quote:
It works! I tried lrf files with embeded fonts taken from yahoo group and did see different fonts in Librie for Windows, but Reader did not recognize them and used default fonts instead. Now we know that embeded fonts really work for Reader also. Incredible! I'll include this to my lrs_to_lrf parser. Do you know correct lrs records to pass it to the parsers (to follow lrs standrads)? |
|
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
|
Quote:
Code:
<RegistFont fontname="Courier New" file="Courier New.ttf" encoding="TTF" fontfilename="Courier New.ttf"/> I will also update LRF2LRS so that it correctly decompiles such files. |
|
![]() |
![]() |
![]() |
#5 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
|
Excellent work igorsk! (I'm adding this to my parser as well)
This now begs the question: is it legal to embed a particular font? Adobe has worked deals to license embedding fonts into PDF's but I seriously doubt Sony has done the same for LRF... You may wish to check the license for any fonts you wish to embed prior to publishing any LRF document with those fonts embedded in it. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
|
You can check if the font allows embedding with Font properties extension:
http://www.microsoft.com/typography/...roperty21.mspx |
![]() |
![]() |
![]() |
#7 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
|
Probably a good warning for the parser to toss to the user during parsing. I'll be sure to check and warn.
|
![]() |
![]() |
![]() |
#8 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 1695
Join Date: Oct 2006
|
Several fonts also work OK.
Lrs to Lrf parser with font support, http://www.msh-tools.com/ebook/MSH_LRSParser.zip example with 2 embedded fonts: http://www.msh-tools.com/ebook/testfonts.zip |
![]() |
![]() |
![]() |
#9 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 137
Karma: 1936
Join Date: Aug 2006
Device: iLiad, Librie, REB1100, GEB2150, GEB1150, etc
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 | |
Member
![]() Posts: 20
Karma: 10
Join Date: Nov 2006
Device: Sony Reader
|
Quote:
http://orion.lcg.ufrj.br/~esperanc/testfonts.zip Incidentally, I´ve noticed that the lrf file generated with MSH_LRSParser duplicated all stop signs at the end of the sentences. Does anyone know why? |
|
![]() |
![]() |
![]() |
#11 |
Member
![]() Posts: 20
Karma: 10
Join Date: Nov 2006
Device: Sony Reader
|
Spans with fontfacename
I would love use font embedding to obtain real bold and italic text rather than the "fake" effect employed in the reader. Unfortunately, it seems that <Span> tags are processed incorrectly by MSH_lrsparser when the fontfacename attribute is used. The problem is that an extra period (".") appears just after the span.
See, for instance the following code: Code:
<TextBlock blockstyle="211" objid="212" textstyle="210"> <P> <Span fontweight="900"> No problem with other attributes </Span> <Span fontfacename="Courier10 BT Roman"> Extra period when switching to Courier </Span> <Span fontfacename="Swis721 BT Roman" fontweight="900"> Same thing when switching to Sans Serif </Span> </P> </TextBlock> |
![]() |
![]() |
![]() |
#12 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 1695
Join Date: Oct 2006
|
Quote:
Here is my example (both lrs and lrf) and the screenshoot: |
|
![]() |
![]() |
![]() |
#13 | |
Member
![]() Posts: 20
Karma: 10
Join Date: Nov 2006
Device: Sony Reader
|
Quote:
On the other hand, I still have the problem with multiple embedded fonts. Here´s the relevant code (see also the two complete example files attached) Code:
<Main> <Page evenheaderid="207" objid="209" oddheaderid="207" pagestyle="208"> <TextBlock blockstyle="211" objid="212" textstyle="210"> <P> <Span fontfacename="Palatino Linotype">Some text written in Palatino Regular. </Span> <Span fontfacename="Palatino Linotype Bold">Some text written in Palatino Bold. </Span> <Span fontfacename="Palatino Linotype Bold Italic">Some text written in Palatino Bold Italic. </Span> <Span fontfacename="Palatino Linotype Italic">Some text written in Palatino Italic. </Span> </P> </TextBlock> </Page> </Main> <Template version="1.0"> </Template> <Style> <BookStyle> <SetDefault empdotsfontname="Dutch801 Rm BT Roman" empdotsposition="before" emplineposition="before" emplinetype="solid" rubyadjust="none" rubyalign="start" rubyoverhang="none" setwaitprop="noreplay" /> <BookSetting bindingdirection="Lr" colordepth="24" dpi="1600" screenheight="800" screenwidth="600" /> <RegistFont encoding="TTF" file="c:\windows\fonts\pala.ttf" fontfilename="aaa" fontname="Palatino Linotype" objid="200" /> <RegistFont encoding="TTF" file="c:\windows\fonts\palab.ttf" fontfilename="aaa" fontname="Palatino Linotype Bold" objid="201" /> <RegistFont encoding="TTF" file="c:\windows\fonts\palabi.ttf" fontfilename="aaa" fontname="Palatino Linotype Bold Italic" objid="202" /> <RegistFont encoding="TTF" file="c:\windows\fonts\palai.ttf" fontfilename="aaa" fontname="Palatino Linotype Italic" objid="203" /> </BookStyle> |
|
![]() |
![]() |
![]() |
#14 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 137
Karma: 1936
Join Date: Aug 2006
Device: iLiad, Librie, REB1100, GEB2150, GEB1150, etc
|
Quote:
|
|
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
|
In Reader, "fontfilename" attribute is ignored, and even "fontname". It uses the actual font names from the TTF.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Embedded fonts, Calibre, and choice of fonts | AlexBell | ePub | 8 | 05-30-2010 06:00 AM |
iPad Embedded Fonts | JSWolf | Apple Devices | 24 | 04-26-2010 02:41 PM |
Embedded fonts in epub | erik5000 | ePub | 7 | 12-08-2009 11:55 AM |
ePub embedded fonts | JSWolf | Ectaco jetBook | 9 | 09-14-2009 08:43 PM |
Using embedded fonts with italics only | sherman | Calibre | 2 | 06-27-2009 04:32 AM |