![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 23166
Join Date: Sep 2012
Device: Kindle 4NT
|
Java custom font?
Is it possible to embed a custom font in a Kindlet?
The Font class seems to be missing a createFont method. I know there is a font hack, but it's opaque and I don't care to have Droid Sans on my Kindle. I just want a better monospaced font. There is a /usr/java/lib/fonts directory, can I just dump stuff in there? Does OTF work? |
![]() |
![]() |
![]() |
#2 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
IIRC I did exactly that.
I think I replaced the current ones with just some other ones renamed to the same thing. That's not exactly portable but did the job for me... let me go check first. [root@kindle root]# cd /usr/java/lib/fonts [root@kindle fonts]# ls -al Spoiler:
Niluje will be able to give you the ins and outs of it all. But I'm fairly certain I have at some point just jumped fonts in there and renamed them. I don't recall why. for the WAFs testing perhaps. So if your question is can I dump fonts in there and not trash the system then yes. If it is will this automagically change the relevant fonts, I think you need to run a fc-cache -f -v see Nilujes comments below: and then restart. That should do the job IIRC. EDIT: Hmm yeah I just did this to get huge fonts on the 5 with no Hacks. (well, font ones) That's why I remember it. Last edited by twobob; 10-08-2012 at 06:29 PM. Reason: (well, font ones) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Does OTF work?
|
![]() |
![]() |
![]() |
#4 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
One more thing. I'm a bit confused about the request.
You ask in a "in a kindlet", IIRC only one or two of the fonts are used "In Kindlets". So replacing them would replace the fonts used in a kindlet. I think? If you mean "can I create a reference to a custom font... that I can use in a Kindlet" I'm not sure mate. probably, with enough digging. Last edited by twobob; 10-08-2012 at 05:00 PM. Reason: clarity |
![]() |
![]() |
![]() |
#5 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Yep, the Fonts hack will switch the fonts *everywhere*, including in Kindlets. And it allows you to switch the serif/sans serif/monospace & CJK/fallback families, so, yep.
(And, yeah, dumping new stuff in java/lib/fonts & tweaking the java font prefs & fontconfig to pick those up is the gist of it on the K2/3/4). @twobob: The fc-cache stuff is specific to the Touch. The ALT_FONTS thing is still doable on those older devices, though: cf. this thread. And, yeah, the Kindle handles OTF fonts. It might horribly choke up on some fonts for no apparent reason when using the system's FreeType lib, though. As for bundling/using a custom font in a dedicated Kindlet on a vanilla Kindle, no idea, sorry ![]() Last edited by NiLuJe; 10-08-2012 at 06:08 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
screenie or it never happened
I think the collection manager is a kindlet? as is JBPatch's interface.
(by that I mean that Ixtab hasn't pulled any ninja moves on them and made them render "via space" or something impressive, assuming they are "fairly standard": they should be Okay examples for this...) replacement (huge) font pictured using your method EDIT: added a couple from JBPatch to show comparison with fonts that are unaffected by me (the tiny ones) Last edited by twobob; 10-08-2012 at 06:24 PM. Reason: (huge) |
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 23166
Join Date: Sep 2012
Device: Kindle 4NT
|
To clarify. The AWT-derived KTextSomething have a setFont method. I was hoping I could put fonts in that folder and load them in the Kindlet.
It currently uses the monospace font, which I would like to replace with a "programmer font". No need to change it anywhere else. Thanks for the info. I will experiment. *googles "java font prefs"* |
![]() |
![]() |
![]() |
#8 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
ah right yeah. well that folder would be a helpful place as there is some mechanism to re-read the java font cache IIRC (I did this once on my PC) and that folder would be included AFAIK as the default.
I know almost zero Java but have noticed the method stub you refer to while fiddling. didn't have a play mate. here's some resources (they don't contain your stuff AFAICT but helpful anyways to others...) personal basis (check your version, future reader) http://docs.oracle.com/javame/config...217/index.html Some kindlet stuff: (always check your references are the right version) https://kdk-javadocs.s3.amazonaws.co...w-summary.html Sorry I can't help more mate. If you do figure it out it would be great to know. Thanks. |
![]() |
![]() |
![]() |
#9 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 23166
Join Date: Sep 2012
Device: Kindle 4NT
|
I dropped a few fonts in there, but logging all the font family names Java knows about, I only see serif, sans-serif monospaced, dialog, default, etc.
I tried adding another name to font.properties in /usr/java/lib, but that did not work. Then I just replaced the monospace section with my own font. I think it worked. I say "I think", because I'm not a font expert. It seems to look slightly different, but I might be imagining stuff. |
![]() |
![]() |
![]() |
#10 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
nah that would work I think. I do that all the time. (just dump fonts in to try stuff out)
|
![]() |
![]() |
![]() |
#11 | |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
set out your expectations, assumptions and a worked example
Quote:
How would we know if in fact that font was available and it was an invocation error? for example. So.. perhaps just set out your expectations, assumptions and a worked example and you will get better help. : ) |
|
![]() |
![]() |
![]() |
#12 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 71
Karma: 23166
Join Date: Sep 2012
Device: Kindle 4NT
|
"did not work" as in, after adding more fonts, Java gives me the same list of aliases. I just called GraphicsEnvironment.getAvailableFontFamilyNames()
But after modifying the monospaced alias in the properties file, it appears to use the new one. So I'm happy. I can just edit the file to use whatever font I want. |
![]() |
![]() |
![]() |
#13 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Aye. fair enough. possibly the method is nerfed or limited in some way. hard to tell through all that obfuscation and fog.
Pleased the "final result" method works for you. I was happy enough with it. possibly there is a way via Azw3 format? but I don't know the ins and outs of embedding other bits of other formats and suspect you would end up writing an entire parser for the sake of a few pixels ![]() although it seems like web fonts should work to me, just not sure why I thought that. probably all that javascript kicking about in WAFS, it gets me all confused about exactly what I am talking about. Happy you are now happy ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Install custom font on 5.2? | Barty | Kindle Developer's Corner | 14 | 11-29-2012 02:25 AM |
Hacks Best custom font? | robollama | Amazon Kindle | 7 | 05-01-2011 07:33 PM |
Custom Font Hacking | Hrant | Kindle Developer's Corner | 5 | 07-26-2010 05:46 PM |
Custom Font Question | Blossom | Astak EZReader | 4 | 03-12-2010 11:04 PM |
Custom Java apps/booklets on Kindle? | dumky | Kindle Developer's Corner | 10 | 02-10-2009 03:26 PM |