Skip to content

Commit

Permalink
bump crengine: monospace and fallback fonts tweaks (#1503)
Browse files Browse the repository at this point in the history
Includes:
- Text: fix possible overflow with "white-space: pre"
- Fonts: getFontFileNameAndFaceIndex(): return family type
- Fonts: account for _bias in Font hash
- epub.css, fb2.css: remove hardcoded monospace font names
- Fonts: allow scaling monospace fonts
- Fonts: allow adjusting fallback font sizes to x-height
- HTML parser: trust xml encoding before html charset

cre.cpp: make setAsPreferredFontWithBias() a global
function (as it is not a per-document setting)
  • Loading branch information
poire-z committed Jul 17, 2022
1 parent 7f0bc23 commit e3e0e3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions cre.cpp
Expand Up @@ -1415,11 +1415,13 @@ static int getFontFaceFilenameAndFaceIndex(lua_State *L) {

lString8 filename;
int faceindex = -1;
bool found = fontMan->getFontFileNameAndFaceIndex(lString32(facename), bold, italic, filename, faceindex);
int family = -1;
bool found = fontMan->getFontFileNameAndFaceIndex(lString32(facename), bold, italic, filename, faceindex, family);
if (found) {
lua_pushstring(L, filename.c_str());
lua_pushinteger(L, faceindex);
return 2;
lua_pushboolean(L, family == css_ff_monospace);
return 3;
}

return 0;
Expand Down Expand Up @@ -1510,12 +1512,11 @@ static int setFontFace(lua_State *L) {
}

static int setAsPreferredFontWithBias(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *face = luaL_checkstring(L, 2);
int bias = luaL_checkint(L, 3);
const char *face = luaL_checkstring(L, 1);
int bias = luaL_checkint(L, 2);
bool clearOthersBias = true;
if (lua_isboolean(L,4)) {
clearOthersBias = lua_toboolean(L, 4);
if (lua_isboolean(L,3)) {
clearOthersBias = lua_toboolean(L, 3);
}

fontMan->SetAsPreferredFontWithBias(lString8(face), bias, clearOthersBias);
Expand Down Expand Up @@ -3747,6 +3748,7 @@ static const struct luaL_Reg cre_func[] = {
{"setGammaIndex", setGammaIndex},
{"registerFont", registerFont},
{"regularizeRegisteredFontsWeights", regularizeRegisteredFontsWeights},
{"setAsPreferredFontWithBias", setAsPreferredFontWithBias},
{"getHyphDictList", getHyphDictList},
{"getSelectedHyphDict", getSelectedHyphDict},
{"setHyphDictionary", setHyphDictionary},
Expand Down Expand Up @@ -3805,7 +3807,6 @@ static const struct luaL_Reg credocument_meth[] = {
{"setHeaderFont", setHeaderFont},
{"setHeaderProgressMarks", setHeaderProgressMarks},
{"setFontFace", setFontFace},
{"setAsPreferredFontWithBias", setAsPreferredFontWithBias},
{"setFontSize", setFontSize},
{"setDefaultInterlineSpace", setDefaultInterlineSpace},
{"setStyleSheet", setStyleSheet},
Expand Down

0 comments on commit e3e0e3f

Please sign in to comment.