#467 changed font unit to em, finalised changes for webview

This commit is contained in:
Daniel 2018-10-12 20:39:32 +02:00
parent 7f7af9ca37
commit ff0a80a127
2 changed files with 17 additions and 10 deletions

View file

@ -1,7 +1,7 @@
:root {
--fontsize-body: 18px;
--fontsize-header: 18px;
--fontsize-subscript: 13px;
--fontsize-body: 1.1em;
--fontsize-header: 1.1em;
--fontsize-subscript: 0.7em;
}
@font-face {

View file

@ -12,6 +12,7 @@ import com.nostra13.universalimageloader.core.ImageLoader;
import org.apache.commons.lang3.StringEscapeUtils;
import java.io.File;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
@ -28,6 +29,10 @@ import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
public class RssItemToHtmlTask extends AsyncTask<Void, Void, String> {
private static final double BODY_FONT_SIZE = 1.1;
private static final double HEADING_FONT_SIZE = 1.1;
private static final double SUBSCRIPT_FONT_SIZE = 0.7;
public interface Listener {
/**
* The RSS item has successfully been parsed.
@ -121,17 +126,19 @@ public class RssItemToHtmlTask extends AsyncTask<Void, Void, String> {
// font size scaling
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
float scalingFactor = Float.parseFloat(mPrefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
double scalingFactor = Float.parseFloat(mPrefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
DecimalFormat fontFormat = new DecimalFormat("#.#");
builder.append("<style type=\"text/css\">");
builder.append(String.format(
":root { \n" +
"--fontsize-body: %spx; \n" +
"--fontsize-header: %spx; \n" +
"--fontsize-subscript: %spx; \n" +
"--fontsize-body: %sem; \n" +
"--fontsize-header: %sem; \n" +
"--fontsize-subscript: %sem; \n" +
"}",
Math.round(18*scalingFactor), // body font size
Math.round(18*scalingFactor), // heading font size
Math.round(13*scalingFactor) // subscript font size
fontFormat.format(scalingFactor*BODY_FONT_SIZE),
fontFormat.format(scalingFactor*HEADING_FONT_SIZE),
fontFormat.format(scalingFactor*SUBSCRIPT_FONT_SIZE)
));
builder.append("</style>");