Round FT metrics, split text drawing by unicode script, and others#318
Round FT metrics, split text drawing by unicode script, and others#318poire-z merged 8 commits intokoreader:masterfrom
Conversation
Happens with the Isidore font from: https://www.mobileread.com/forums/showthread.php?t=273339
Fix some issue (don't remember exactly what) when there's one single good cluster at end of segment, and previous part of segment is to be drawn with the fallback font. (Backported from xtext.cpp.)
When measuring with Harfbuzz, we should also split on Unicode script change, even in a same bidi level (mixed hebrew and arabic in a single text node should be handled as multiple segments, or Harfbuzz would shape the whole segment with the script of the first kind of text it meets, resulting in non-joined arabic if preceeded by hebrew). Also remove First-Strong-Isolate unicode char from the list of RTL chars. (Also fix wording of "bidi" as "bibi"...)
LVRendLineInfo created when splitting a large line (tall table row) into multiple pages were not freed. (Reported by valgring.)
Frenzie
left a comment
There was a problem hiding this comment.
Reviewed 7 of 8 files at r1.
Reviewable status: 7 of 8 files reviewed, 1 unresolved discussion (waiting on @poire-z)
crengine/src/pdbfmt.cpp, line 193 at r1 (raw file):
if ( mobiEncryption!=0 ) return false; // encryption is not supported if ( hederLength >= 0xE4 ) {
That variable name. D:
There was a problem hiding this comment.
Reviewed 7 of 8 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @poire-z)
crengine/src/lvfntman.cpp, line 75 at r1 (raw file):
#define FONT_METRIC_TO_PX(x) (((x)+32) >> 6) // ROUND + TRUNC
My maths is fuzzy, but isn't this missing the AND from ROUND?
Also, metrics, not metric ;).
crengine/src/lvfntman.cpp, line 1668 at r1 (raw file):
else glyph->rsb = (lInt16)(FONT_METRIC_TO_PX( (myabs(_slot->metrics.horiAdvance) - _slot->metrics.horiBearingX - _slot->metrics.width) ) );
@Frenzie : I CAN SEE DEAD WHITESPACE :D. <3.
|
Yay, inline quotes still quoting unrelated code! :D. The reviewable link actually points to the right place. (EDIT: Ninja edit-fixed it). |
|
Yeah, like I said in base I was almost already sold when I saw the whitespace. ;-) |
There was a problem hiding this comment.
Reviewed 1 of 8 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @poire-z)
crengine/src/lvfntman.cpp, line 75 at r1 (raw file):
Previously, NiLuJe (NiLuJe) wrote…
#define FONT_METRIC_TO_PX(x) (((x)+32) >> 6) // ROUND + TRUNCMy maths is fuzzy, but isn't this missing the AND from ROUND?
Also, metrics, not metric ;).
A quick testcase shows that this indeed works as it should, so, yay, maths! :D
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @poire-z)
I figured (and checked with some online C compiler with values 63, 65, 90, 100, 127, 130... and -63 -65... that both ways always give the same result) that
Even when I'm dealing with a single one (height, or advance, or another) of the multiple font metrics?
That's some comment about that "reviewable" site, or my use of added white space to keep things aligned? Anyway, not fond of "reviewable" (except for the larger width & smaller font size when viewing code) - and the noise it adds here, and it forcing me to resolve conversation there, and masquerading as an additional CI check. But if you guys like it... (Except that now, as I don't want to use it, I can reply to code comments in the main PR thread and not miss some of them :) |
Yeah, ran a quick
Yup. c.f., OED ;). I don't think I've ever seen it being used in another form in the context of font design/rendering.
Yeah, that was in response to @Frenzie in another issue and/or on gitter ;). |
|
Just to clear up the maths in my head: Two's complement arithmetic say that (for an int) Hence the 6 low bits, which we then punt off with the shift ;). (ref: https://www.nayuki.io/page/some-bit-twiddling-functions-explained because no, I did not know the two's complement rules off the top of my head ;)) KCalc in programmer's mode has the handy binary representation visible at all times, which helps for this kind of stuff ;). |
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @poire-z)
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @poire-z)
I'm not convinced :) Your screenshots explicitely states its use in plural, and show examples in plurals. |
Newer MOBI files have larger headers. Not fetching the extradata flags would cause not cleaning extradata at PDB block boundaries, and result in garbage in the HTML content (possibly resulting in invalid UTF-8 and not triggering UTF-8 parsing).
So it gets a fixed id and we get more cache stability.
49c6705 to
7370434
Compare
|
(Small optimization to the "background-color black" commit.) |
|
Oh, that's because the singular form is for sure more common in general ;). A slightly different meaning, and different contexts, though ;). In FreeType, the only singular I can find are related to the PCF driver, which may be using it because of said slightly different meaning (and/or because it's just much older) ;). |
|
Well, I'm older too :) But ok, history will blame that on me (and it looks so odd to my french-grammar-rooted english :) |
|
Afaik a metric is basically just a synonym for measurement (e.g., what metric should we use to judge X). One metric, two metrics. Height, ascent, descent, and whatever else there is are all individually a single font metric. As in this quote (2011 April 10, Financial Times, according to here):
Also: https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-obtain-font-metrics
|
|
Yeah, I'm a bit torn on the specific usage when it's used to specifically point to a single specific type like in that last quote ;). That said, here, I'm taking the macro to basically say "convert some metrics to pixels", so the plural seems justified nonetheless. Grammar is fun. Feel free to poke holes in that ;). |


See individual commit messages for detail.
Links to relevant discussions:
Before (with that Isidore font and native hinting, so "abc" not shown):


(at the bottom, no space on one side or both of the arabic "word" - might just be a stream of reandom arabic chars.)
After:
This change is