|
|
#1 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 551
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
|
Selectively assigning font-size within an element
I am assuming this is a hard "No", but I figured I'd ask the pros anyway...
Is there a way—using css—to change the font-size of letters in an element, but not the font-size of punctuation or numbers? Or is my only option to manually <span> out the letter strings and assign the font-size at that level? (Normally, I would comfortably assume this is impossible, but you guys not-so-recently flagged properties like "text-align-last" which I would have imagined was so situation specific that it wouldn't exist... so here we are.) |
|
|
|
|
|
#2 |
|
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,474
Karma: 21000001
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Traditionally it required the use of spans… which is very frustrating seeing a very large opening quote with the large initial drop cap.
I think renderer’s simply choose to include punctuation in the :first-letter pseudo-element. I’m not aware of a :first-symbol ??? |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 121
Karma: 1000
Join Date: Nov 2025
Device: none
|
Think another way around: edit the font file.
![]() (which is more tedious and require pro tools and knowledge) |
|
|
|
|
|
#4 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 121
Karma: 1000
Join Date: Nov 2025
Device: none
|
To be serious, this level/depth of formatting control kinna kills the whole premises of re-flowable file isn't it?
|
|
|
|
|
|
#5 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82,670
Karma: 151278869
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
No it doesn't kill the premise of reflowable. It just means that to get what you want, you'd need to use an embedded font that's been edited to do what you want.
|
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,930
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
1. In your xhtml file: Code:
<p class="MyFont">Lorem ipsum dolor March 29, 2026 sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc.</p> Code:
@font-face {
font-family: "MyTimes";
src: local("Times New Roman");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "MyTimes";
src: local("Times New Roman");
unicode-range: U+0030-0039, U+0021-002F, U+003A-0040, U+005B-0060, U+007B-007E;
size-adjust: 150%; /* Here you set the size you wish */
}
.MyFont {
font-family: "MyTimes";
line-height: 1.2em;
}
With this method (you must define twice the @font-face declaration, the first one is the fallback code for the whole unicode-range), you don't need an special font. In my example I employed a local font ("Times New Roman") but if you wish, you can incluye your custom font in the epub and in that case, you need to replace: Code:
src: local("Times New Roman");
Code:
src: url("../Fonts/YourFont.ttf");
The unicode-range method is extremely flexible because it allows you to segment the font by any "block" of characters you wish to treat independently, such as uppercase letters, thus providing another way to achieve raised caps and drop caps. To make uppercase letters larger, you only need to define the Unicode range corresponding to the capital letters of the Latin alphabet. Last edited by RbnJrg; Yesterday at 04:43 PM. |
|
|
|
|
|
|
#7 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,930
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
That only for old ereaders; with modern ones, you can use the method I posted previously; another advantage of epub3 over epub2.
|
|
|
|
|
|
#8 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,930
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
|
|
|
|
|
#9 | |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82,670
Karma: 151278869
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
The problem with ePub is that you cannot be sure the person reading will be doing so with an ePub3 program. |
|
|
|
|
|
|
#10 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 551
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
|
Thanks, all.
@RbnJrg - This is interesting. As I'm doing all my reading in KOReader these days, I try to be cautious about how advanced I get with my css as I know that KOR is not fully epub3 compatible (something I know you lament). But your elegant solution still gives me lots of food for thought. @icereach - I don't see how this would negatively affect the reflowability of the document(any more than selectively changed relative font sizes currently does, like THIS)... Last edited by ElMiko; Yesterday at 08:30 PM. |
|
|
|
|
|
#11 |
|
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,474
Karma: 21000001
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Despite some individual’s willful ignorance of the concept of fall-back coding, you can code for both ePub 2 and 3 in the same ePub. It takes a little more work, but it works. You can use all the new techniques to give your customers the best possible product if their device supports it and a good product if they don’t.
Take a look at: css hierarchy rules @supports @media Scripts You can also search here since there are several threads discussing fall-back coding. Cheers! |
|
|
|
|
|
#12 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 551
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
|
Thanks, @Turtle91, I'll do that. In this case, however, it seems that the fall back coding would have to be <span>ing the desired text anyway, at which point the elegant epub3 solution becomes visually redundant.
But your point is well-taken, and there are certainly other situations where two slightly different treatments (one that makes it looks great, and one that makes it look acceptable) could be called for. |
|
|
|
|
|
#13 | |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 121
Karma: 1000
Join Date: Nov 2025
Device: none
|
Quote:
|
|
|
|
|
|
|
#14 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,930
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
|
|
|
|
|
#15 | |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82,670
Karma: 151278869
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
It just mean you have to use spans which will work in more cases then the embedded font solution. |
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Moon+ Reader your favorite font and font size? | loodio | Android Devices | 6 | 01-30-2016 06:50 PM |
| Problem changing font size using font size key | Waylander | Conversion | 0 | 10-02-2013 03:30 PM |
| Determine font and font size on incoming epub? | peaceridge | Calibre | 4 | 01-30-2012 03:35 PM |
| PRS-300 Med font size too big, but small font size too small | eli2k | Sony Reader | 4 | 05-28-2010 09:47 AM |