Skip to content

change int to double in font size#141

Open
buihongvinh wants to merge 2 commits into
Notalib:mainfrom
buihongvinh:VinhBui/fix-bug-font-size-setting-not-work
Open

change int to double in font size#141
buihongvinh wants to merge 2 commits into
Notalib:mainfrom
buihongvinh:VinhBui/fix-bug-font-size-setting-not-work

Conversation

@buihongvinh
Copy link
Copy Markdown

The app stores reader font size as a percentage for UI/persistence, but Readium Android/Web expects fontSize as a scale value. Passing 100.0 compiles but does not behave correctly; it should be sent as 1.0. iOS currently divides fontSize by 100 in the native bridge, so it still receives the percentage value. typeScale should also be updated from the same scale so the rendered text actually changes with the slider.

EPUBPreferences buildPreferences(TextSettingsState settings) {
final clampedFontSize = settings.fontSize.clamp(70, 200);
final fontScale = clampedFontSize / 100.0;

return EPUBPreferences(
// UI stores font size as percent: 70, 100, 150, 200.
// Android/Web Readium expects scale: 0.7, 1.0, 1.5, 2.0.
// iOS bridge currently divides fontSize by 100 internally.
fontSize: defaultTargetPlatform == TargetPlatform.iOS
? clampedFontSize.toDouble()
: fontScale,

// Keep typeScale in sync with the selected font size.
typeScale: fontScale,

publisherStyles: false,
fontFamily: settings.fontFamily,
lineHeight: settings.lineHeight,
letterSpacing: settings.letterSpacing,

);
}

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.

2 participants