Skip to content

Commit

Permalink
bump crengine: more granular font weights (#1363)
Browse files Browse the repository at this point in the history
Includes:
- MathML: a few minor fixes
- (Upstream) lvtext: fix possible index out of range
- Fonts: RegisterExternalFont() should take a documentId
- Fonts: fix: letter-spacing should not be applied on diacritic
- (Upstream) Fonts: more granular synthetic weights
- Fonts: synthesized weights: tweak some comments
- Fonts: keep hinting with synthetic weight
- Fonts: fix synthesized weight inconsitencies
- Fonts: fix getFontFileNameAndFaceIndex()
- Fonts: adds LVFontMan::RegularizeRegisteredFontsWeights()
- Fonts: handle synth_weight tweaks in glyph/glyphinfo slots
- (Upstream) Fonts: fix some compiler warnings
- Fix hyphenation on Armenian and Georgian text
  • Loading branch information
poire-z committed Apr 28, 2021
1 parent a28e09a commit 85dacfb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
33 changes: 24 additions & 9 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,19 @@ static int getFontFaceFilenameAndFaceIndex(lua_State *L) {
return 0;
}

static int getFontFaceAvailableWeights(lua_State *L) {
const char *facename = luaL_checkstring(L, 1);

LVArray<int> weights;
fontMan->GetAvailableFontWeights(weights, lString8(facename));
lua_createtable(L, weights.length(), 0);
for ( int i=0; i<weights.length(); i++ ) {
lua_pushinteger(L, weights[i]);
lua_rawseti(L, -2, i+1);
}
return 1;
}

static int setViewMode(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
LVDocViewMode view_mode = (LVDocViewMode)luaL_checkint(L, 2);
Expand Down Expand Up @@ -1697,14 +1710,6 @@ static int setEmbeddedFonts(lua_State *L) {
return 0;
}

static int toggleFontBolder(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");

doc->text_view->doCommand(DCMD_TOGGLE_BOLD);

return 0;
}

static int cursorRight(lua_State *L) {
//CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");

Expand Down Expand Up @@ -3304,6 +3309,15 @@ static int registerFont(lua_State *L) {
return 0;
}

static int regularizeRegisteredFontsWeights(lua_State *L) {
bool print_updates = false;
if (lua_isboolean(L, 1)) {
print_updates = lua_toboolean(L, 1);
}
fontMan->RegularizeRegisteredFontsWeights(print_updates);
return 0;
}

// ported from Android UI kpvcrlib/crengine/android/jni/docview.cpp

static int findText(lua_State *L) {
Expand Down Expand Up @@ -3488,10 +3502,12 @@ static const struct luaL_Reg cre_func[] = {
{"newDocView", newDocView},
{"getFontFaces", getFontFaces},
{"getFontFaceFilenameAndFaceIndex", getFontFaceFilenameAndFaceIndex},
{"getFontFaceAvailableWeights", getFontFaceAvailableWeights},
{"getGammaLevel", getGammaLevel},
{"getGammaIndex", getGammaIndex},
{"setGammaIndex", setGammaIndex},
{"registerFont", registerFont},
{"regularizeRegisteredFontsWeights", regularizeRegisteredFontsWeights},
{"getHyphDictList", getHyphDictList},
{"getSelectedHyphDict", getSelectedHyphDict},
{"setHyphDictionary", setHyphDictionary},
Expand Down Expand Up @@ -3573,7 +3589,6 @@ static const struct luaL_Reg credocument_meth[] = {
{"gotoPos", gotoPos},
{"gotoXPointer", gotoXPointer},
{"zoomFont", zoomFont},
{"toggleFontBolder", toggleFontBolder},
//{"cursorLeft", cursorLeft},
//{"cursorRight", cursorRight},
{"drawCurrentPage", drawCurrentPage},
Expand Down

0 comments on commit 85dacfb

Please sign in to comment.