mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
default font size depends on display DPI
This commit is contained in:
parent
07f495a585
commit
20f5428e9e
5 changed files with 18 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
===== 0.7.15 (??? ??, 2010) =====
|
||||
* Ukrainian localization (by Dmytro Shevchenko) has been added
|
||||
* Default font size depends on display DPI
|
||||
|
||||
===== 0.7.14 (Nov 03, 2010) =====
|
||||
* Screen brightness adjustment has been implemented (idea was taken from Aldiko and https://github.com/cujo/FBReaderJ)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DefaultStyles>
|
||||
<base family="DroidSerif" fontSize="18"/>
|
||||
<base family="sans-serif" fontSize="18"/>
|
||||
<style id="0" name="Regular Paragraph" firstLineIndentDelta="20" allowHyphenations="true"/>
|
||||
<style id="1" name="Title" fontSizeDelta="10" bold="true" spaceBefore="2" spaceAfter="7" alignment="center" allowHyphenations="false"/>
|
||||
<style id="3" name="Poem Title" fontSizeDelta="2" bold="true" spaceBefore="6" spaceAfter="6" leftIndent="40" allowHyphenations="false"/>
|
||||
|
|
|
@ -39,5 +39,6 @@ public abstract class ZLibrary {
|
|||
abstract public String getCurrentTimeString();
|
||||
abstract public void setScreenBrightness(int percent);
|
||||
abstract public int getScreenBrightness();
|
||||
abstract public int getDisplayDPI();
|
||||
abstract public void openInBrowser(String reference);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
package org.geometerplus.zlibrary.text.view.style;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.*;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
|
||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
|
||||
import org.geometerplus.zlibrary.text.model.ZLTextAlignmentType;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextStyle;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextHyperlink;
|
||||
|
||||
public class ZLTextBaseStyle extends ZLTextStyle {
|
||||
private static final String GROUP = "Style";
|
||||
|
@ -49,6 +50,7 @@ public class ZLTextBaseStyle extends ZLTextStyle {
|
|||
public ZLTextBaseStyle(String fontFamily, int fontSize) {
|
||||
super(null, ZLTextHyperlink.NO_LINK);
|
||||
FontFamilyOption = new ZLStringOption(GROUP, "Base:fontFamily", fontFamily);
|
||||
fontSize = fontSize * ZLibrary.Instance().getDisplayDPI() / 320 * 2;
|
||||
FontSizeOption = new ZLIntegerRangeOption(GROUP, "Base:fontSize", 0, 72, fontSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.content.res.AssetFileDescriptor;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
||||
|
@ -132,6 +133,16 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
|||
return (myActivity != null) ? myActivity.getScreenBrightness() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayDPI() {
|
||||
if (myActivity == null) {
|
||||
return 0;
|
||||
}
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
myActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
return (int)(160 * metrics.density);
|
||||
}
|
||||
|
||||
private final class AndroidAssetsFile extends ZLResourceFile {
|
||||
AndroidAssetsFile(String path) {
|
||||
super(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue