Skip to content

BottomMenu: show real sizes for margins and font size#9205

Merged
11 commits merged into
masterfrom
unknown repository
Jul 5, 2022
Merged

BottomMenu: show real sizes for margins and font size#9205
11 commits merged into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jun 12, 2022

Copy link
Copy Markdown

Pictures say more than words:

grafik

grafik


This change is Reviewable

@poire-z

poire-z commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

Fine by me.
(I must say that pt for font size may talk to me because of reading about fonts - but for margins it will feel a bit abstract. May be it will talk more to people with a designer/illustration background.)

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

Indeed, for margins cm (or I suppose inch) would be more natural.

@zwim

scaleByPt

I think you mean something like (convert)ToPt.

@poire-z

poire-z commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

On the other hand, something a bit abstract like pt feels better than "cm" if the user has changed its Screen DPI.
@zwim: are you using the user-set Screen DPI ? Or the device.lua harcoded value for each device (and I don't know if this is always accurate, like on Android - do we get the correct real value)? in which case, cm will be real centimeters that the user can measure to confirm we're not lying :)

(inch wouldn't talk to me at all :)

@ghost

ghost commented Jun 12, 2022

Copy link
Copy Markdown
Author

I think you mean something like (convert)ToPt.

This name is a leftover from my previous PR, scaleBySize and scaleByPt do a smilar job. But the name can be changed.

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

On the other hand, something a bit abstract like pt feels better than "cm" if the user has changed its Screen DPI.

It'll be equally inaccurate. :-)

Or the device.lua harcoded value for each device

I don't think we have access to that — at least not over there in the framebuffer code at this time?

@ghost

ghost commented Jun 12, 2022

Copy link
Copy Markdown
Author

(inch wouldn't talk to me at all :)

Anyway if we support cm someone will request inch and vice versa.

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

This name is a leftover from my previous PR, scaleBySize and scaleByPt do a smilar job. But the name can be changed.

I'm not entirely sure what you're saying here. If they do a similar job then there should be no such thing as scaleByPt, ever. ;-)

@ghost

ghost commented Jun 12, 2022

Copy link
Copy Markdown
Author

@Frenzie I meant both take a px value and calculate the result. scaleBySize converts a px to your koscale(tm), scaleByPt converts a px value to a pt value.

@ghost

ghost commented Jun 12, 2022

Copy link
Copy Markdown
Author

@poire-z So far I have tested it on the emulator with the "-d dpi" option, to assure the correctness of the calculated sizes.

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

"koscale" is the intended display size it's scaled to. It can change completely tomorrow.

@poire-z

poire-z commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

I don't think we have access to that — at least not over there in the framebuffer code at this time?

Looks like we do, as self.device.display_dpi in base/ffi/framebuffer.lua.
And on Android, it's:

frontend/device/kobo/device.lua:    display_dpi = 300,
frontend/device/kobo/device.lua:    display_dpi = 300,
frontend/device/android/device.lua:    display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
frontend/device/pocketbook/device.lua:    display_dpi = 200,
frontend/device/pocketbook/device.lua:    display_dpi = 212,
frontend/device/pocketbook/device.lua:    display_dpi = 167,

In the code, there's a check that hints it's possible there is no self.device:
https://github.com/koreader/koreader-base/blob/7548930c384227139ca506ab87ff006e50e84634/ffi/framebuffer.lua#L340-L356

So, i guess @zwim new formula should use this one if we want to show a value in absolute units like pt ( or pt for fonts and cm for margins?) that won't change when the user tweak Screen dpi to just get bigger/smaller stuff - with something to pick another value when no self.device.

On the other hand, something a bit abstract like pt feels better than "cm" if the user has changed its Screen DPI.

It'll be equally inaccurate. :-)

Yes, but with cm, anybody can realize it is innacurate - with pt only professionals will know :)

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

Looks like we do, as self.device.display_dpi in base/ffi/framebuffer.lua.

Indeed you're right. But then should we also default that to 160 if it doesn't exist?

Edit: I mean you'd need something like:

local display_dpi = self.device and self.device.display_dpi or 160

In this convertToPt function.

@poire-z

poire-z commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

But then should we also default that to 160 if it doesn't exist?

No dpinion :)
(But may be the -d emulator option should then be favored ? as it may only be used on the emulator/appimage - with no garantee it's the real dpi of the screen)

@Frenzie

Frenzie commented Jun 12, 2022

Copy link
Copy Markdown
Member

The emulator -d option maps to display_dpi, doesn't it? I'm talking about the scenario where one uses the base framework without the KOReader frontend.

@ghost

ghost commented Jun 14, 2022

Copy link
Copy Markdown
Author

Updated the screenshots in the initial commit, got rid of the helper in framebuffer.

Calculations for size are tested with a hardcopy (document with the same font and size in pt shown by KOReader) on two documents.

Not tested on Android yet.

Comment on lines +598 to +601
text = _("Metric system"),
checked_func = function()
return G_reader_settings:readSetting("metric_system", true)
end,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really have to have a setting for this ? for the 2 nearly hidden places that show some size ?
I'd say that if I don't know how long is a "inch", for lack of ever seeing this unit, I guess all our users over the world (but may be not their blind grandma) should have a grasp of mm, cm, meters and understand what it means/sizes when seeing it).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can comment out the menu entry. We can delete it if nobody requests it in lets say two releases :)
(As a physicist the Système international d’unité is the inly one to take care of :) )

@NiLuJe NiLuJe Jun 14, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Murica!

(Snark aside, yeah, it might make sense to have a toggle available somewhere ;o). It's not quite as widespread and opinionated as the 12H vs. 24H clock issue, but, still ;p).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's @Frenzie have the final word.
(If kept, may be move the menu item nearer to the other unit one/ones like 12/24h.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a setting for it, unless we just show both. Default to metric please. ;-)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, default to metric is clear.
Should I put the menu entry into "Time and Date" (as the last entry there) and rename that entry to "Time, date and units"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion. But I'd say leave Time and date> as-is, and add a Units> submenu, with only this one for now (I can't rule out that you will one day come up with the idea of showing frontlight levels in lux or lumens, and device temperature in °C or °F :)
(Is [x] Metric system unambigous enough to indicates it's only about sizes/distances ? Is "metric" about meters and distances, or about metrics and other general units ?)

@ghost

ghost commented Jun 22, 2022

Copy link
Copy Markdown
Author

The menu looks like that now:

grafik

@poire-z

poire-z commented Jun 25, 2022

Copy link
Copy Markdown
Contributor

@zwim: has my #9205 (comment) been considered ? (about using the hardcoded/real device dpi instead of the user set?)

@ghost

ghost commented Jun 26, 2022

Copy link
Copy Markdown
Author

@zwim: has my #9205 (comment) been considered ? (about using the hardcoded/real device dpi instead of the user set?)

First answer the question:
Not now?

Then ask a question:
What shall we do on devices, where there is no Device.display_dpi? Do we want to use Screen:getDPI() as a fallback?

@poire-z

poire-z commented Jun 26, 2022

Copy link
Copy Markdown
Contributor

@Frenzie mentionned using 160 in the post just after mine.
I have no idea which is best, between 160 or using the user set dpi.

@Frenzie

Frenzie commented Jun 26, 2022

Copy link
Copy Markdown
Member

It needs to be both.

@Frenzie

Frenzie commented Jun 26, 2022

Copy link
Copy Markdown
Member

But technically speaking I suppose the user-set DPI overrides the fallback of 160? In that case it doesn't need to be both. But in any case it needs to be 160 as a fallback; it can't be nil.

@ghost

ghost commented Jun 26, 2022

Copy link
Copy Markdown
Author

I will go with

local display_dpi = Device.display_dpi or Screen:getDPI()

as Screen:getDPI() last fallback is 160.

@Frenzie

Frenzie commented Jun 26, 2022

Copy link
Copy Markdown
Member

I'm not sure if we want to read the property directly without a getter? But yes, that should be fine besides that.

Comment thread frontend/device/generic/device.lua Outdated
self.input.gesture_detector:init()
end

function Device:getDisplayDPI()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be it should be named getScreenRealDPI() (or something else instead of "real", @Frenzie ?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDeviceScreenDPI? Assuming it doesn't relate to the setScreenDPI function right above.

@ghost

ghost commented Jun 28, 2022

Copy link
Copy Markdown
Author

Ready?

Comment thread frontend/ui/data/optionsutil.lua Outdated
Comment on lines +156 to +159
if is_size == 1 then
unit = G_reader_settings:nilOrTrue("metric_length") and "mm" or "\""
else
unit = "pt"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be here and in the callers, except of 1 and 2, use "pt" or "mm" and if size_type == "mm" elseif size_type == "pt" (event if you end up using inch because of the preference).

Comment thread frontend/ui/data/optionsutil.lua Outdated
if is_size == 1 then
unit = G_reader_settings:nilOrTrue("metric_length") and "mm" or "\""
else
if is_size == "pt" then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be the variable should be renamed to "unit" or "size_type" now (as is_size sounds like it should be a boolean true/false).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will make the code shorter and more readable

@ghost

ghost commented Jul 4, 2022

Copy link
Copy Markdown
Author

Ready?

@Frenzie Frenzie added this to the 2022.07 milestone Jul 5, 2022
@ghost ghost merged commit 2c952ec into koreader:master Jul 5, 2022
@ghost ghost deleted the showRealSizes branch July 5, 2022 13:39
@poire-z

poire-z commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

@zwim : you're the scientist, but are you really sure a contrast can be expressed in millimeters ? :)

image

@ghost ghost mentioned this pull request Jul 30, 2022
Frenzie pushed a commit that referenced this pull request Jul 30, 2022
@ghost ghost mentioned this pull request Jun 20, 2024
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants